Bot Framework: Prompt 和 retry 提示信息同时出现

Bot Framework: Prompt and retry prompt messages appear at the same time

我向用户显示的提示包含提示消息和重试提示消息,请参见下文:

return await ctx.PromptAsync(CancelCurrentDialogsPrompt, new PromptOptions
{
    Prompt = MessageFactory.Text("Are you sure you'd like to cancel?"),
    Choices = ChoiceFactory.ToChoices(confirmationOptionsList),
    RetryPrompt = MessageFactory.Text("Please select or type yes/no")
}, cancellationToken);

当我运行模拟器中的BOT时,提示信息和重试提示信息同时出现,这是我没想到的,见下图:

当我输入错误的选项时,重试提示按预期显示。从列表中选择正确的值后,对话将按预期继续,没有错误的对话。

---更新---

我正在使用 bot.cs class

中的以下代码调用取消对话框
await dialogContext.BeginDialogAsync(nameof(CancelDialog));

调用时对话框堆栈上没有任何内容。这是我 CancelDialog.cs

中的代码
public class CancelDialog : ComponentDialog
    {
        public readonly BotDialogSet DialogSet;

        private const string CancelWaterfallDialogs = "CancelWaterfallDialogs";
        private const string CancelCurrentDialogsPrompt = "CancelCurrentDialogsPrompt";

        public CancelDialog(BotDialogSet dialogSet) : base(nameof(CancelDialog))
        {
            DialogSet = dialogSet;

            var waterfallSteps = new WaterfallStep[]
            {
                WouldYouLikeToCancel,
                CompleteUsersSelectedAction
            };

            AddDialog(new WaterfallDialog(CancelWaterfallDialogs, waterfallSteps));
            AddDialog(new ConfirmPrompt(CancelCurrentDialogsPrompt));
        }

        private static async Task<DialogTurnResult> WouldYouLikeToCancel (WaterfallStepContext ctx, CancellationToken cancellationToken)
        {
            return await ctx.PromptAsync(CancelCurrentDialogsPrompt, new PromptOptions
            {
                Prompt = MessageFactory.Text("Are you sure you'd like to cancel?"),
                RetryPrompt = MessageFactory.Text("Are you sure you'd like to cancel? Please select or type yes/no")
            }, cancellationToken);
        }

        private static async Task<DialogTurnResult> CompleteUsersSelectedAction(WaterfallStepContext ctx, CancellationToken cancellationToken)
        {
            if ((bool)ctx.Result)
            {
                await ctx.Parent.CancelAllDialogsAsync(cancellationToken);
                return await ctx.EndBotDialogAsync(cancellationToken);
            }

            return await ctx.EndDialogAsync(cancellationToken: cancellationToken);
        }
    }

1- 定义如下:

 AddDialog(new TextPrompt("YNValidator", YesNoValidator);

-在:

之后添加
  AddDialog(new ConfirmPrompt(CancelCurrentDialogsPrompt));

2- 定义 YesOrNValidator:

private Task<bool>YorNValidator (PromptValidatorContext<string> promptContext, CancellationToken cancellationToken)
{
  //Test the value... and pass true or false
    Task.FromResult(true);
 }

3- 接下来重写 WouldYouLikeToCancel

private static async Task<DialogTurnResult> WouldYouLikeToCancel (WaterfallStepContext ctx, CancellationToken cancellationToken)
    {
        var options= new PromptOptions
        {
            Prompt = MessageFactory.Text("Are you sure you'd like to cancel?"),
            RetryPrompt = MessageFactory.Text("Are you sure you'd like to cancel? Please select or type yes/no")
        }, cancellationToken);
    return await stepContext.PromptAsync("YNValidator",options,cancellationToken);
    }