Manage the state in Production in Bot FrameWork v4

Viewed 51

I create One Askstate and AskDialog in Bot FrameWork V4 After release in production sometime state variables are not giving correct value. Below is my code for reference. the Code Is Working Fine in Emulator though it Not Work Correctly in Production. following is code For referance.

// 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 one state variable.

https://i.stack.imgur.com/cJ12v.png

let me know if anyone has solution. thanks in Advance.

0 Answers
Related