Search code examples
microsoft-teamsteams-toolkit

TeamsToolkit Bot App Reboot Problem (VSCode, TeamsFx)


I implemented a Teams bot app using the TeamsFx library. The app I created can send messages using the API to users who have installed the app or group chat rooms, and has a function that responds to the user's messages. I implemented the app using TypeScript in VsCode and deployed it to Azure AppService using the deployment function.

However, a problem occurs the moment you reboot Azure AppService. All group chat rooms and user lists registered in My Bot will be removed. Notifications cannot be sent to any user.

Currently, we have implemented a function that stores all user and group chat room information in the DB and restores the information by retrieving it from the DB when the app is newly launched.

Why is all user information removed when I reboot AppService, and how can I fix it? Or, can't I get a list of all users who have installed my app and their group chat rooms from the Teams server?


Solution

  • You can get the names and other details of apps installed for the user: https://learn.microsoft.com/en-us/graph/api/userteamwork-list-installedapps?view=graph-rest-1.0&tabs=http#example-2-get-the-names-and-other-details-of-apps-installed-for-the-user

    Currently we don't have any API to get all the users who installed a particular app.

    A bot is inherently stateless. Once your bot is deployed, it may not run in the same process or on the same machine from one turn to the next. However, your bot may need to track the context of a conversation so that it can manage its behavior and remember answers to previous questions. The state and storage features of the Bot Framework SDK allow you to add state to your bot. Bots use state management and storage objects to manage and persist state.

    Reference links:

    Save user and conversation data: https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-state?view=azure-bot-service-4.0&tabs=csharp

    Managing state: https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-concept-state?view=azure-bot-service-4.0

    Sample link: https://github.com/Microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/45.state-management