考虑以下是对话框。
bot.dialog('/beer', [
function (session) {
builder.Prompts.number(session, "How many mugs would you like?");
},
function (session, results) {
if (results.response && results.response.entity != '(quit)') {
// Launch demo dialog
session.endDialog("Beer" + (results.response == 1 ? " is on the" : "s are on their") + " way, enjoy!");
} else {
// Exit the menu
session.endDialog("Goodbye, See you later..");
}
}
]);
如果用户输入文本(例如&#39;测试&#39;)而不是有效数字,则会向用户提示,机器人会提供 default_number 等响应。< / p>
数字的默认错误消息是 default_number ,选项是 default_choice ,文字 default_error 等。我尝试了不同的方法弄清楚如何控制它并定义像bot这样的默认行为&#34;我不认识它,请再试一次&#34; 而不是给出错误,而不是#39 ; t对用户有意义。
有人可以对此有所了解吗?
参考链接 https://docs.botframework.com/en-us/node/builder/chat/prompts/#promptsnumber
答案 0 :(得分:4)
(总是欢迎更好的答案。)
经过大量搜索后发现了以下内容。
默认情况下,它在模拟器中处理错误消息&amp;展示一些东西
“糟糕。出了点问题我们需要重新开始。”
或
“我不明白。”。
但是在Direct Line API / Skype等其他频道上。显示的实际机器人响应类似于“ default_error ”,“ default_choice ”等。
要更改默认错误消息,我们只需在文件夹中添加名为'BotBuilder.json'的文件
BotProject/locale/<languageCode>/BotBuilder.json
因此该文件包含覆盖默认错误的文本消息,如下所示:
{
"default_error": "I did not recognize it. Please try again."
}
<小时/> 更新:希望这是可以覆盖的所有可能列表。
{
"default_text": "I didn't understand. Please try again.",
"default_number": "I didn't recognize that as a number. Please enter a number.",
"default_confirm": "I didn't understand. Please answer 'yes' or 'no'.",
"default_choice": "I didn't understand. Please choose an option from the list.",
"default_time": "I didn't recognize the time you entered. Please try again using a format of (MM/DD/YYYY HH:MM:SS).",
"default_file": "I didn't receive a file. Please try again.",
"default_error": "Oops. Something went wrong and we need to start over."
}