user9582192
user9582192

Reputation: 31

What is the benefit of the using cosmos db as a storage of state in bot framework instead of using memory storage

I am little confused with the use of comosdb or any other storage for user state in bot framework other then memory storage. As I read in the documentation that memory storage will be deleted after refresh.and it will remain in cosmos db.

But how to get the same state from the comosdb which is used by the same user earlier.

If I would not able to get the state of the user after refresh of the bot then what is the use of comosdb storage.as I want to use the saved state in my conversation so that I will not ask the question which is asked earlier from user.

Please help me In clarification of this. Hope my query is understandable.

Thanks .

Upvotes: 2

Views: 695

Answers (1)

mdrichardson
mdrichardson

Reputation: 7241

CosmosDb is separate from the bot, so if the bot restarts, it just reads the state information from the CosmosDb and it's right back where it left off. So long as the user has the same UserId as before, the bot will read their Dialog, Conversation, and User State from Cosmos.

Maybe it would help to think of it differently. When the bot uses Memory Storage, user data is stored in RAM, like if you were working in a Word Document. If your computer crashed in the middle of writing your Word Document, you would lose everything because the data is not persisted. However, if you click Save, it saves the information to the hard drive. When you restart the computer, you can load your saved Word Doc from the hard drive. Similarly, if the bot restarts, it can load the saved information from Cosmos.

Please read Implementing Custom Storage for more information.

Note that any persistent storage will work. The other "approved" option is Azure Blob Storage which is a cheaper option, although less performant when you have a large number of users. You could use any external database, really, so long as you have a storage adapter for it.

Upvotes: 1

Related Questions