【问题标题】:Waterfall Dialog Not Running One At A Time瀑布对话框一次不运行一个
【发布时间】:2019-05-30 12:03:10
【问题描述】:

我有以下代码:

this.dialogs.add(new TextPrompt("tp"));
this.dialogs.add(new TextPrompt("tp2"));
this.dialogs.add(new TextPrompt("tp3"));
this.dialogs.add(
    new WaterfallDialog("send_email", [
        this.promptStep.bind(this),
        async step => await step.prompt("tp", "Who do you want to email?"),
        async step => await step.prompt("tp2", "What's the subject line?"),
        async step => await step.prompt("tp3", "And what's the message?"),
        async step => await OAuthHelpers.sendMail(step.context, step.result, step.result)
    ])
);

当我在机器人模拟器中运行它时,会立即显示前两个文本提示。它甚至不等待我的回应。如何告诉它在继续之前等待用户响应?

【问题讨论】:

  • 你能分享一下你的实际机器人的 onTurn 处理程序的实现是什么样的吗?
  • @DrewMarsh 确定:i.imgur.com/o1sXJEG.png
  • 啊,好吧,所以你正在处理对话更新活动......这很好,但现在我需要看看你的 processInput 方法。如果您可以将整个文件放在一个要点或可能是最快的方法中。 :)
  • 当然:gist.github.com/AskYous/5f8da20bccc42ad6d33bce49b73d250a FYI 它是用打字稿写的。

标签: botframework


【解决方案1】:

好的,所以根据您在 cmets 中链接的要点,我相信您的问题可能是由于 the processStep function 内部正在进行的一些对话处理。具体来说,我发现关于如何启动"send_email" 瀑布对话框的两个问题。

line 98 开始,您有:

const dc = await this.dialogs.createContext(step.context);
await dc.beginDialog("send_email");

首先,您不应该在这里调用createContext 创建一个全新的DialogContext。您已经在该步骤中有一个上下文,您只想使用beginDialog 将另一个对话框推送到堆栈中。

第二件事是,当你 await 时,你没有 return 并且逻辑将流向 line 112,然后它将调用 endDialog 你不想这样做这种情况下,它只会杀死您刚刚放入堆栈的当前对话框。

最终,这两行应该改为:

return await step.beginDialog("send_email");

这将启动"send_email" 对话流程并允许它适当地向前移动。最终,当该流程完成时,它将返回到您的 "graphDialog" 以执行下一步,但由于没有更多步骤,它只会自动完成该对话框并将您返回到您的 onTurn 逻辑已经处理的空堆栈再次开始"graphDialog"。现在,如果您想避免这种情况,则需要对流程进行一些其他更改,但希望这能让您继续前进。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-11
    • 2023-04-04
    • 2020-03-23
    • 1970-01-01
    • 1970-01-01
    • 2014-09-24
    相关资源
    最近更新 更多