Skip to content

Instantly share code, notes, and snippets.

@r4hulp
Created December 29, 2017 08:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save r4hulp/f2dbaddc9c84aad8c8b28c07cf628fdf to your computer and use it in GitHub Desktop.
CRD BotData
//In your dialog
Activity message = result as Activity;
//Create scope with respect to activity
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
{
//Resolve scope for IBotDataStore<BotData>
IBotDataStore<BotData> stateStore = scope.Resolve<IBotDataStore<BotData>>();
/* Retrieve user address. Address key holds information about Bot, Channel, User and conversation */
Address key = Address.FromActivity(message);
//Load user data with the help of key
BotData userData = await stateStore.LoadAsync(key, BotStoreType.BotUserData, CancellationToken.None);
//Get value by key
string getUserLanguagePreference = userData.GetProperty<string>("language_preference");
//Set value of type string
userData.SetProperty<string>("language_preference", "en_US");
//Remove value
userData.RemoveProperty("language_preference");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment