[Question] Private Conversation Data Not Available in IDialog
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.
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
@neetgupta7 did @nrobert's answer help with your question?
Yes it did . Closing the issue. Thanks