UserProfile state persistent between users in bot v4

让人想犯罪 __ 提交于 2019-12-30 13:40:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!