google-cloud-platform - 后续意图未触发 intentMap.set 中的处理程序方法 - Dialogflow
问题描述
我有几个嵌套的后续意图,如下所示:
然后在履行功能的代码中,我有这个数字 70 正在触发giveChoice
但其余的没有被触发。为什么?如何使用后续意图执行此操作?
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
//Intent - 70
intentMap.set('0068 - Intents - 70', giveChoice);
intentMap.set('0068 - Intents - 70 - no', giveFirstNextQuestion);
intentMap.set('0068 - Intents - 70 - no - no', giveSecondNextQuestion);
intentMap.set('0068 - Intents - 70 - no - no - no', giveThirdNextQuestion);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
解决方案
我设法重现您的问题并解决了它。我将总结以下几点:
为您要使用的所有意图和后续意图启用此意图的 webhook 调用(在履行部分中)。
您创建的要使用的函数“giveChoice”、“giveFirstNextQuestion”...应遵循以下结构:
function givechoice(agent){
agent.add(`Would you like this response to be recorded?`);
agent.setContext({
name: 'first-call',
lifespan: 2,
});
}
function afirmative(agent){
agent.getContext('first-call');
agent.add(`Thank you for accepting`);
}
请注意,在上述情况下,我只做一个后续意图。例如,如果你做第三个,那么第二个函数必须有一个 getContext 和一个 setContext 才能正常工作。
最后一部分和你做的完全一样。就我而言:
let intentMap = new Map();
intentMap.set('0068 - Intents - 70',givechoice);
intentMap.set('0068 - Intents - 70 - yes',afirmative);
agent.handleRequest(intentMap);
推荐阅读
- azure - Azure Function : Function AutoScale 时,多次调用函数
- java - 在不同语言的进程之间有效地共享数据
- .net-core - Atlassian 管道 MSB3026 等上的 dotnet 测试错误
- excel - Excel VBA 代码不会在多个工作簿表“后面”运行:更好的方法?
- nvidia - 如何安装最新版rapids,无需指定版本号
- c# - 通过脚本生成自动新 guid 时,为什么新 guid 是一个长 0 位?
- bash - 将屏幕输出重定向到文件
- python - 如何调用python脚本并将输出图像返回给View
- android - 通知没有声音也没有振动
- excel - 当单元格具有逗号分隔值时如何使用 VLOOKUP 或 XLOOKUP