Luis Dialog Sample不等待用户输入

时间:2019-11-13 14:52:49

标签: c# botframework

因此,我试图调用与Luis对话框不同的对话框。当我这样做时,我希望luis对话框可以等到另一个对话框结束。

由于我无法向您展示我的真实项目,因此我使用了Luis Dialog Sample重现了我的问题。我向PromptWaterfallDialog添加了另一步,现在看起来像这样:

public PromptWaterfallDialog()
        : base(nameof(PromptWaterfallDialog))
    {
        // This array defines how the Waterfall will execute.
        var waterfallSteps = new WaterfallStep[] // 20190813 FPI diese Schritte werden jedes Mal ausgeführt wenn ein PromptWaterfallDialog aufgerufen wird
        {
            this.AskQuestionStepAsync,
            this.ReturnResultStepAsync,
            this.TestStepAsync
        };

        // Add named dialogs to the DialogSet. These names are saved in the dialog state.
        this.AddDialog(new WaterfallDialog(nameof(WaterfallDialog), waterfallSteps));
        this.AddDialog(new TextPrompt(nameof(TextPrompt)));

        // The initial child Dialog to run.
        this.InitialDialogId = nameof(WaterfallDialog);
    }

    private async Task<DialogTurnResult> AskQuestionStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
    {
        var options = stepContext.Options as PromptDialogOptions;
        return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(options.Prompt) }, cancellationToken);
    }

    private async Task<DialogTurnResult> ReturnResultStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
    {
        return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Hi") }, cancellationToken);
    }

    private async Task<DialogTurnResult> TestStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
    {
        var options = stepContext.Options as PromptDialogOptions;
        options.Result = stepContext.Result as string;

        await stepContext.Context.SendActivityAsync(MessageFactory.Text("This is just a test"));

        return await stepContext.EndDialogAsync(new DialogTurnResult(DialogTurnStatus.Complete, options));
    }

如您所见,我已经添加了TestStepAsync。我希望对话框像这样:

  1. 启动:PromptMessage(AskQuestionStepAsync)

  2. 用户:一些答案...

  3. Bot:您好(ReturnResultStepAsync)

  4. 用户:一些输入...

  5. Bot:这只是一个测试(TestStepAsync)

但是显然,机器人会跳过等待第二个用户输入的过程,而直接转到TestStepAsync,如您在此处看到的:here

有人知道这种行为是否故意吗?以及如何使机器人像我期望的那样工作?

我正在使用Bot Emulator 4.6.0版。

1 个答案:

答案 0 :(得分:1)

代替

提示= MessageFactory.Text(“ Hi”)

将其更改为:

提示= MessageFactory.Text(“ Hi”,InputHints.ExpectingInput);