Bot IStatePropertyAccessor occasionally not working after production release.

Raj Gohel 21 Reputation points
2021-06-08T11:40:34.747+00:00

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.
103451-botwhereerr.png

Please let me know if any suggestions for the same.
Thank you.

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
826 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. YutongTie-MSFT 50,856 Reputation points
    2021-06-09T01:50:49.567+00:00

    Hello,

    Thanks for reaching out to us here. It's a bit difficult to reproduce your issue on my side. I can give two suggestion here.

    1. Debug your bot in ngrok to check the issue
      https://learn.microsoft.com/en-us/azure/bot-service/bot-service-debug-channel-ngrok?view=azure-bot-service-4.0

    2, If you still have no idea after the debugging and have no support plan, I can enable you a one-time-free ticket for your issue. There will be a support engineer to help you find your issue step by step. Please let me know the Azure subscription ID if you don't have a support plan.

    Regards,
    Yutong


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.