【发布时间】:2018-02-13 12:55:08
【问题描述】:
我正在使用 Dialogflow 开发一个聊天机器人,当聊天机器人连续三次不理解用户输入并且第四次使用自定义消息(不是那个在对话框流界面上声明的选项)
我的一个想法是在输入未知操作中创建一个计数器,如下所示:
var counter = 1;
// The default fallback intent has been matched, try to recover (https://dialogflow.com/docs/intents#fallback_intents)
'input.unknown': () => {
// Use the Actions on Google lib to respond to Google requests; for other requests use JSON
if (requestSource === googleAssistantRequest) {
sendGoogleResponse('I\'m having trouble, can you try that again?'); // Send simple response to user
} else {
if (counter == 3) {
counter = 1;
sendResponse('Custom message');
} else {
counter++;
sendResponse('I\'m having trouble, can you try that again?'); // Send simple response to user
}
}
},
这可行,但如果这将同时适用于多个用户,我正在考虑创建一个存储来存储由唯一 ID 附加的请求,并为每个请求设置不同的计数器!
您对在 Dialogflow 中实现这样的事情有更好的想法吗?
【问题讨论】:
标签: javascript bots google-cloud-functions chatbot dialogflow-es