问题
When I have two instances of the bot (can be two emulator windows or two browsers if I deploy the bot to Azure), the first name enter is persistent for all the other instances.
Instance One
https://imgur.com/sa7AAbn
Instance Two
https://imgur.com/Ct20HE5
I would expect the bot ask my name again, it does not matter how many instances I have, the bot always identifies me as Brunno. How can I change this behavior?
I followed this tutorial
回答1:
If you don't provide WebChat with a unique id for each conversation, it will reference the same data objects in storage. So to the resolve this issue, you should generate a random id for each user or conversation instance. See the code snippet below for an example.
const userID = Date.now() + Math.random().toString(36);
...
window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({ token }),
store,
userID
}, document.getElementById('webchat'));
Hope this helps!
回答2:
Also check latest README.md of webchat WEBCHAT API reference It states
If userID is not specified, it will default to a random user ID
Might be more efficient.
来源:https://stackoverflow.com/questions/55690399/userprofile-state-persistent-between-users-in-bot-v4