UserProfile 状态在 bot v4 中的用户之间持续存在

UserProfile state persistent between users in bot v4

当我有两个机器人实例时(如果我将机器人部署到 Azure,可以是两个模拟器 windows 或两个浏览器),输入的名字对于所有其他实例都是持久的。

实例一

https://imgur.com/sa7AAbn

实例二

https://imgur.com/Ct20HE5

我希望机器人再次询问我的名字,无论我有多少实例,机器人总是将我标识为 Brunno。我怎样才能改变这种行为?

我关注了this tutorial

如果您不为每个对话提供 WebChat 唯一 ID,它将引用存储中的相同数据对象。因此,要解决此问题,您应该为每个用户或对话实例生成一个随机 ID。有关示例,请参见下面的代码片段。

const userID = Date.now() + Math.random().toString(36);

...

window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({ token }),
store,
userID
}, document.getElementById('webchat'));

希望对您有所帮助!

同时查看最新的 README.md 网络聊天 WEBCHAT API reference 它指出

If userID is not specified, it will default to a random user ID

可能会更有效率。