Search code examples
.netbotframework

How to save MS Teams conversation references in a database?


I want to persist conversation references in a database in order to send notifications to users.

Is there a tutorial on how to store them? do I just add a "conversation reference" object to the database? (on AWS DynamoDB)

"In a real-world scenario you would persist conversation references in a database instead of using an object in memory."

https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-proactive-message?view=azure-bot-service-4.0&tabs=csharp


Solution

  • I see you tagged as ".net", so you're writing your bot in C# I guess? If so, all the things you need come in on the turncontext.activity object. You need things like the Conversation Id, the ServiceUrl, and so on. In addition, you need to use your bot's App Id and App Password to construct the "pro active" conversation later on. I've discussed it more here, with some sample code to get you started.

    In terms of your original question, these value (e.g. conversation id) are just basic text/string values, so you can save them to a database just like you'd save anything in any normal .net application. For instance, you could save them to SQL Azure, Azure Blob storage, Cosmos DB, Mongo DB, etc. I assume you've done something like that before? If not, let me know and I'll give you some starting points, but again just to be clear, that's kind of "standard" .net data access, nothing special to "Bots" at that point.