Reputation: 21
I am using below code to save user state.It is getting saved in cosmos but while I am trying to retrieve it in next turn it is giving null.Is there any way to make it persistent for whole conversation.
private IStatePropertyAccessor<ChatState> _maindialogState;
_maindialogState = userState.CreateProperty<ChatState>(nameof(ChatState));
var _statemain = await _maindialogState.GetAsync(stepContext.Context, () => new ChatState());
_statemain.Email = "XXXXXX";
_statemain.DisplayName = "Ankit";
await _maindialogState.SetAsync(stepContext.Context, _statemain, cancellationToken);
Upvotes: 1
Views: 289
Reputation: 2885
It appears you are not actually saving the state in your code above, only setting the value. In nodejs the syntax would be
await this.conversationState.saveChanges(context);
await this.userState.saveChanges(context);
I'm not sure what you have called the user or conversation state. You want to use that variable, not the state accessor (which appears to be _maindialogState) or your state variable (which appears to be _statemain).
Upvotes: 1