botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Question] Private Conversation Data Not Available in IDialog

Open neetgupta7 opened this issue 9 years ago • 3 comments

Hello I m trying standard template solution for BOT. In MessageController.cs I am adding a private conversation data string as below- StateClient stateClient = activity.GetStateClient(); BotData userData = await stateClient.BotState.GetPrivateConversationDataAsync(activity.ChannelId, activity.Conversation.Id, activity.From.Id); userData.SetProperty<string>("UserLanguage", "English");

Then in my Root Dialog file I am trying to extract this data by doing below- string userLanguage = "Lang Not Found"; context.PrivateConversationData.TryGetValue("UserLanguage", out userLanguage); await context.PostAsync("Language Identified : " + userLanguage);

But this is always returning null. Can someone please help. Am I doing something wrong.

neetgupta7 avatar Jun 22 '17 12:06 neetgupta7

After your userData.SetProperty<string>("UserLanguage", "English");, you have to call await stateClient.BotState.SetPrivateConversationDataAsync(activity.ChannelId, activity.Conversation.Id, activity.From.Id, userData); to log your changes

nrobert avatar Jun 22 '17 12:06 nrobert

@neetgupta7 did @nrobert's answer help with your question?

stevengum avatar Jun 27 '17 18:06 stevengum

Yes it did . Closing the issue. Thanks

neetgupta7 avatar Jun 27 '17 23:06 neetgupta7