0

I've manage to send notification to Teams users through the Chatbot. In order to send notification, you need to persist the conversation in order to have a channel to push the message or anything else. The persistence of the conversation are done in memory, so, after i restart the chatbot, i'm not able anymore to notify any user until they come back to chat with the bot and store the conversation again.

It's possible to save the conversation on a storage like CosmosDB or BlobStorage using this library https://github.com/microsoft/botbuilder-js/tree/main/libraries/botbuilder-azure? What i understand about this library, it has been developed to persist some state of the conversation, not the conversation itself.

Maybe there is another way to retrieve conversations (or create from scratch with some stored data)?

1 Answers1

2

The samples you see online store the data in memory because they are -just- samples, and it's much easier to keep the sample self-contained if it doesn't have a dependency on you setting up a database just to get the sample running.

In the real world the data -must- be kept somewhere else, for all practical purposes, such as Cosmos, Blob or other. In addition, you actually don't need the -entire- conversation reference - see here a more detailed answer I wrote a few months ago with some further references: Sending proactive messages from an outside process to organizational users via Teams chat bot

Also worth noting, the samples and docs show to get the data you need in the conversationUpdate from the user (i.e. when they install your bot), which is definitely easiest, but if you've lost it now (because your bot has reset), you get the same data from the user every time they send a message to your bot - you can save it at that time if you haven't saved it already.

Hilton Giesenow
  • 9,809
  • 2
  • 10
  • 24