C# C BotFramework提示符。确认显示尝试次数过多异常

C# C BotFramework提示符。确认显示尝试次数过多异常,c#,botframework,C#,Botframework,我最近使用微软的僵尸网络框架开发了一个聊天机器人。我正在使用prompt.confirm接受用户的yes/no输入,但当我写入基本yes/no时,它会显示太多尝试异常。我不希望我的bot显示太多尝试异常,而是希望在内部处理它。这是我的密码 [LuisIntent("None")] public async Task NoneIntent(IDialogContext context, LuisResult result) { try { PromptDialog.

我最近使用微软的僵尸网络框架开发了一个聊天机器人。我正在使用prompt.confirm接受用户的yes/no输入,但当我写入基本yes/no时,它会显示太多尝试异常。我不希望我的bot显示太多尝试异常,而是希望在内部处理它。这是我的密码

[LuisIntent("None")]
public async Task NoneIntent(IDialogContext context, LuisResult result)
{
    try
    {
        PromptDialog.Confirm(context, NextQuestionAsync, QuestionPrompt, attempts: 1, promptStyle: PromptStyle.Auto);
    }
    catch (Exception ex)
    {
        await context.PostAsync("Something really bad happened.");
    }
}

public async Task NextQuestionAsync(IDialogContext context, IAwaitable<bool> result)
{
    try
    {
        if (await result)
        {
            await context.PostAsync($"Ok, alarm 0 disabled.");
            //context.Wait(NoneIntent);
        }
        else
        {
            await context.PostAsync("You Said No");
        }
    }
    catch (Exception e)
    {

    }
}
您可以通过在中传递自己的字符串来覆盖ToomAnyAttents消息,该字符串稍后用于显示消息

另外,请记住,在ToomAnyAttents异常的情况下,处理该异常的方法是在ResumeAfter方法的try/catch中,在本例中,是您的NextQuestionAsync方法,它围绕着Wait,而不是调用方方法。

您可以通过在,稍后用于显示消息


另外,请记住,在ToomanyAttributes异常的情况下,处理该异常的方法是在ResumeAfter方法的try/catch中,在本例中,是您的NextQuestionAsync方法,它围绕着Wait,而不是调用方方法。

多亏了ezequiel,我通过重写PrompOptions构造函数解决了这个问题。我使用了PromptDialog.Choice来实现它,但是我也可以用confirm来实现它。这就是我所做的

    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);

多亏了ezequiel,我通过重写PrompOptions构造函数解决了这个问题。我使用了PromptDialog.Choice来实现它,但是我也可以用confirm来实现它。这就是我所做的

    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);

PromptConfirm适用于是/否问题。这有点像我的答案的翻版。并且您没有覆盖构造函数;那是一个错误的说法。当然。。。和你在其他问题上做的一样。NevermindPromptConfirm用于是/否问题。这有点像我的答案的翻版。并且您没有覆盖构造函数;那是一个错误的说法。当然。。。和你在其他问题上做的一样。没有关系