简体   繁体   中英

Microsoft Bot Framework multiple users

I'm developing an app using Microsoft Bot Framework V4 using the NodeJS SDK. The bot uses a basic waterfall dialog to authenticate the users, and access microsoft graph api in the backend. 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?

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
  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'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?

Handled automatically via User IDs. Most channels set the User ID automatically. Newer versions of WebChat should provide random User IDs. 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”.

And then you can access it in any step. This will solve the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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