【发布时间】:2018-07-01 09:33:25
【问题描述】:
我正在使用 DialogFlow 的内联编辑器。在 webhook 中,我通过 WebhookClient.add() API 将来自谷歌助手的语音响应发送给用户。但它现在似乎没有工作。我知道 V2 API 已经发布并且现在正式发布。我以为我正在使用 V2 API。看起来不是。请告诉我WebhookClient.add() 的替代方案。我尝试使用conv,但它也不起作用。这是我的使用方法:
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({request, response});
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
const conv = agent.conv();
function welcome(agent) {
agent.add('Welcome to MY AGENT');//This and the next line are not sending speech output.Earlier it was working fine
agent.add('This is the Webhook');
conv.ask('Welcome to My agent');
conv.ask('This is the Webhook!');
}
let intentMap = new Map(); // Map functions to Dialogflow intent names
intentMap.set('Default Welcome Intent', welcome);
agent.handleRequest(intentMap);
}
请帮我看看这是怎么回事。 更新:添加意图映射
【问题讨论】:
-
您能否详细说明“它现在似乎不起作用”?你有任何错误吗?
-
我没有收到任何错误。我检查了日志。即使是Dialog flow(温度转换器)给出的样本也不起作用。
-
您的代码 sn-p 非常混乱。我不确定你为什么同时使用
agent.add和conv.ask,因为我认为你应该只使用其中一个。
标签: node.js webhooks actions-on-google dialogflow-es