简体   繁体   English

Microsoft Bot Framework 多用户

[英]Microsoft Bot Framework multiple users

I'm developing an app using Microsoft Bot Framework V4 using the NodeJS SDK.我正在使用 NodeJS SDK 使用 Microsoft Bot Framework V4 开发应用程序。 The bot uses a basic waterfall dialog to authenticate the users, and access microsoft graph api in the backend.该机器人使用一个基本的瀑布对话来验证用户,并在后端访问微软图形 API。 I use a lot of local variables to store transient data and don't have a need to maintain any state.我使用了很多局部变量来存储瞬态数据,不需要维护任何状态。 My question is我的问题是

  1. When multiple users use my bot, will the sessions interfere?当多个用户使用我的机器人时,会话会干扰吗? (note that I'm not using any bot user/conversation storage. (请注意,我没有使用任何机器人用户/对话存储。

  2. Since there is only one instance of the bot running in Azure, do I need to do anything from my side to handle multiple users or will the bot framework handle it for me automatically?由于只有一个机器人实例在 Azure 中运行,我是否需要从我这边做任何事情来处理多个用户,还是机器人框架会自动为我处理?

I'm seeing some erratic behavior when multiple users are trying to access the bot but not sure what the issue could.当多个用户尝试访问机器人但不确定问题可能是什么时,我看到了一些不稳定的行为。

When multiple users use my bot, will the sessions interfere?当多个用户使用我的机器人时,会话会干扰吗? (note that I'm not using any bot user/conversation storage. (请注意,我没有使用任何机器人用户/对话存储。

No. As long as:不会。只要:

  1. The users have different User IDs用户有不同的用户 ID
  2. You follow good coding practices.您遵循良好的编码习惯。 "I use a lot of local variables to store transient data" This part is a little concerning if the variables are at all "global". "I use a lot of local variables to store transient data"这部分有点担心变量是否完全是“全局的”。 I've definitely seen this cause multi-user issues.我肯定已经看到这会导致多用户问题。

Since there is only one instance of the bot running in Azure, do I need to do anything from my side to handle multiple users or will the bot framework handle it for me automatically?由于只有一个机器人实例在 Azure 中运行,我是否需要从我这边做任何事情来处理多个用户,还是机器人框架会自动为我处理?

Handled automatically via User IDs.通过用户 ID 自动处理。 Most channels set the User ID automatically.大多数频道会自动设置用户 ID。 Newer versions of WebChat should provide random User IDs.较新版本的 WebChat 应提供随机用户 ID。 However, be sure that you're not accidentally setting a static one with something like:但是,请确保您不会意外地使用以下内容设置静态:

window.WebChat.renderWebChat(
            {
               directLine: window.WebChat.createDirectLine({
                  token: 'YOUR_DIRECT_LINE_TOKEN'
               }),
               userID: 'A_Static_Id', // DO NOT DO THIS
            },
            document.getElementById('webchat')
         );

If you believe you're following these guidelines but still running into issues, please post your code and I can help further.如果您认为自己遵循了这些准则但仍然遇到问题,请发布您的代码,我可以提供进一步的帮助。

One biggest mistake can be using Global variable.一个最大的错误可能是使用全局变量。 If you are using any then just remove them and try to pass those values to step context.. ex: stepContext.values.yourVariableName = “value”.如果您正在使用任何,那么只需删除它们并尝试将这些值传递给步骤上下文.. 例如:stepContext.values.yourVariableName = “value”。

And then you can access it in any step.然后您可以在任何步骤中访问它。 This will solve the problem.这将解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM