我的机器人有一个提示,要求用户输入:
builder.Prompts.choice(session, "Is it ok?", ["Yes", "No"]);现在,当用户使用“是”或“否”以外的其他内容进行响应时,程序将始终使用以下内容进行答复:
I did not understand. Please choose an option from the list和以前一样的选择。
如果用户键入“是”或“否”以外的其他内容(并将提示堆栈重置为"Yes“或"No”),我希望bot不再要求输入。
发布于 2016-11-21 07:13:18
您可以为提示符更改maxRetries选项,如下所示(默认值为无限)
builder.Prompts.choice(session, "Is it ok?", ["Yes", "No"],maxRetries:'2'); 您可以在提到的网址中看到IPrompt选项
发布于 2016-11-21 21:37:54
还可以使用触发器操作(例如“帮助”)在提示符期间捕获其他特定输入:
// Add default dialog
bot.dialog('/', function (session) {
builder.Prompts.choice(session, "Is it ok?", ["Yes", "No"]);
});
// Add help dialog with a trigger action bound to a regular
// expression looking for the users to ask for help.
bot.dialog('/help', function (session) {
session.endDialog("Type 'Yes' or 'No'");
}).triggerAction({ matches: /^(help|options)/i });注意,您需要安装BotBuilder的预发布版本:
npm install --save botbuilder@nexthttps://stackoverflow.com/questions/40656556
复制相似问题