Bot Framework:退出 PromptDialog 而不给出答案
Bot Framework: Exit PromptDialog without giving an answer
我问用户一个 yes/no 问题使用:
PromptDialog.Confirm(context, AfterChoice_OpenServiceRequest, "Do you want to open a service request?");
用户可以给出 yes/no 答案。但是,如果用户根本不想回答这个问题,而是问一个不同的问题怎么办?直到并且除非用户回复 yes/no,它会一直问他们相同的问题 'n' 次。
我可以将 n=0 传递给 attempts 参数,但这仍然需要用户至少回答一次 yes/no 才能提出问题否则。
用户是否可以不继续并询问其他内容作为回应?我该如何处理?
SDK的预发布版本包含"triggerActions"的概念。您可以使用这些来中断任何对话。在下面的示例中,用户可以通过键入 "weather":
来中断颜色提示
代码:
bot.dialog('/', function (session) {
builder.Prompts.choice(session, "What color?", "Red|White|Blue");
});
bot.dialog("weather", function (session) {
session.send("It's cold and rainy");
session.endDialog();
}).triggerAction({ matches: /^weather/i});
获取预发布:
npm install -save botbuilder@next
在 Lars 提到的功能发布之前,唯一的选择是创建一个新的 class 继承自 PromptDialog
,或者手动实现您的对话逻辑。
我问用户一个 yes/no 问题使用:
PromptDialog.Confirm(context, AfterChoice_OpenServiceRequest, "Do you want to open a service request?");
用户可以给出 yes/no 答案。但是,如果用户根本不想回答这个问题,而是问一个不同的问题怎么办?直到并且除非用户回复 yes/no,它会一直问他们相同的问题 'n' 次。
我可以将 n=0 传递给 attempts 参数,但这仍然需要用户至少回答一次 yes/no 才能提出问题否则。
用户是否可以不继续并询问其他内容作为回应?我该如何处理?
SDK的预发布版本包含"triggerActions"的概念。您可以使用这些来中断任何对话。在下面的示例中,用户可以通过键入 "weather":
来中断颜色提示代码:
bot.dialog('/', function (session) {
builder.Prompts.choice(session, "What color?", "Red|White|Blue");
});
bot.dialog("weather", function (session) {
session.send("It's cold and rainy");
session.endDialog();
}).triggerAction({ matches: /^weather/i});
获取预发布:
npm install -save botbuilder@next
在 Lars 提到的功能发布之前,唯一的选择是创建一个新的 class 继承自 PromptDialog
,或者手动实现您的对话逻辑。