Are you sure you want to delete this access key?
A stateless sample bot tracking context of a conversation using a custom storage provider.
The minimum prerequisites to run this sample are:
The Bot Framework provides several ways of persisting data relative to a user or conversation. Behind the scenes the Bot Framework uses the Bot State Service for tracking context of a conversation. This allows the creation of stateless Bot web services so that they can be scaled.
There might be times when a custom storage wants to be used. Reasons for wanting this could be many, however the most common ones are:
This bot is based on the State bot, with the addition that it uses a custom storage for tracking the context of a conversation. In this case, we are storing the bot state in DocumentDB by using the AzureBotStorage
along with a DocumentDbClient
instance, both provided by the BotBuilder Azure Extensions for Node.js package.
Check out the creation of the AzureBotStorage
and DocumentDbClient
instances in the app.js. Also, see how to configure the bot to use this new custom storage:
// Azure DocumentDb State Store
var docDbClient = new azure.DocumentDbClient({
host: process.env.DOCUMENT_DB_HOST,
masterKey: process.env.DOCUMENT_DB_MASTER_KEY,
database: process.env.DOCUMENT_DB_DATABASE,
collection: process.env.DOCUMENT_DB_COLLECTION
});
var botStorage = new azure.AzureBotStorage({ gzipData: false }, docDbClient);
// Set Custom Store
bot.set('storage', botStorage);
The DocumentDbClient
requires a few settings that can be obtained when you create a DocumentDB account. The sample looks for these settings in the Environment variables and, by default, is configured to use the DocumentDB Emulator. Checkout the .env file for the emulator configuration.
The sample itself will behave exactly as the State bot with the difference that the bot state is being stored in DocumentDB.
After running the sample, go to the Azure DocumentDB Emulator Data Explorer to check the documents that were stored in DocumentDB. Different Documents are created depending on the bot store type being used.
The samples uses the three bot store types (UserData, ConversationData and PrivateConversationData), so three documents will appear in the DocumentDB collection.
Each of the documents contains the information related to the bot store type:
UserData | ConversationData | PrivateConversationData |
---|---|---|
![]() |
![]() |
![]() |
To get more information about how to get started in Bot Builder for .NET and State please review the following resources:
Press p or to see the previous file or, n or to see the next file
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?