I have used bot from Angular web application. I am using bot state accessors in my code it works fine in bot emulator. I am setting value of IsWhatToWhereKeywords
which is a property of askState
in AskDialog
. After release in production sometime state variables are not giving correct value. Below is my code for reference.
// In Dialogbot class
private readonly IStatePropertyAccessor<AskState> _askStateAccessor;
private readonly UserState _userState;
protected readonly ConversationState _conversationState;
// In Dialogbot constructor
_userState = userState ?? throw new ArgumentNullException(nameof(userState));
_askStateAccessor = _userState.CreateProperty<AskState>(nameof(AskState));
Dialogs = new DialogSet(_dialogStateAccessor);
Dialogs.Add(new AskDialog(_askStateAccessor, _spService, _dataStateAccessor, loggerFactory));
// In OnTurnAsync method
var valueAskState = await _askStateAccessor.GetAsync(turnContext, () => new AskState());
if (valueAskState.IsWhatToWhereKeywords != null)
{
// logic
}
await _conversationState.SaveChangesAsync(turnContext);
await _userState.SaveChangesAsync(turnContext);
// In AskDialog
public IStatePropertyAccessor<AskState> UserProfileAccessor { get; }
// In AskDialog's PromptForEntitiesStepAsync method
var askState = await UserProfileAccessor.GetAsync(stepContext.Context);
if(condition)
{
askState.IsWhatToWhereKeywords = keyword; // setting state variable
}
As per below is a screenshot "aaa" which is keyword
should be stored into IsWhatToWhereKeywords
.
Please let me know if any suggestions for the same.
Thank you.