C# BotFramework Prompt.Confirm displays too many attempts exception

前端 未结 2 474
一个人的身影
一个人的身影 2020-12-20 04:35

I was recently developing a chatbot using Microsoft\'s botframework. I am using prompt.confirm to take user\'s yes/no input but it shows too many attempts exception when I

相关标签:
2条回答
  • 2020-12-20 05:23

    I resolved this issue by overriding the PromptOptions constructor, Thanks to ezequiel. I used PromptDialog.Choice to achieve it however I could also have done it with confirm. Here's what I did

        List<string> questions = new List<string>();
        questions.Add("Yes"); // Added yes option to prompt
        questions.Add("No"); // Added no option to prompt
        string QuestionPrompt = "Are you sure?";
        PromptOptions<string> options = new PromptOptions<string>(QuestionPrompt, "", "", questions, 1); // Overrided the PromptOptions Constructor.
       PromptDialog.Choice<string>(context, NextQuestionAsync, options);
    
    0 讨论(0)
  • 2020-12-20 05:28

    You can just override the TooManyAttempts message by passing your own string in the PromptOptions constructor, which is later used here to display the message.

    Also, have in mind that in the case of the TooManyAttempts exception, the way to handle it is in the try/catch of the ResumeAfter method (in this case your NextQuestionAsync method), surrounding the await and not in the caller method.

    0 讨论(0)
提交回复
热议问题