【发布时间】:2018-11-21 19:23:31
【问题描述】:
我正在尝试将 Alexa 与 Dialogflow 集成并使用 Dialogflow 来满足意图请求。对于静态意图响应,我能够正确获得响应,但是当我尝试集成 webhook 以实现完整时,我遇到了异常对话框流:
TypeError:无法读取未定义的属性“源” 在 V2Agent.processRequest_ (/user_code/node_modules/dialogflow-fulfillment/src/v2-agent.js:108:86) 在新的 WebhookClient (/user_code/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:193:17) 在exports.dialogflowFirebaseFulfillment.functions.https.onRequest (/user_code/index.js:26:18) 在 cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:26:47) 在 /var/tmp/worker/worker.js:684:7 在 /var/tmp/worker/worker.js:668:9 在 _combinedTickCallback (内部/进程/next_tick.js:73:7) 在 process._tickDomainCallback (internal/process/next_tick.js:128:9)
以下是我用于实现 webhook 的代码:
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
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));
function orcacall () {
response.setHeader('Content-Type','application/json');
response.send(JSON.stringify({'speech':'myMessage','displayText':'myMessage','data':[],'contextOut':[]}));
}
let intentMap = new Map();
intentMap.set('Orca', orcacall);
agent.handleRequest(intentMap);
});
【问题讨论】:
-
请添加您尝试过的代码sn -p。仅仅堆栈跟踪是不够的
-
抱歉,添加代码
-
您使用的库版本是什么。因为有类似问题的修复 github.com/dialogflow/dialogflow-fulfillment-nodejs/pull/51 。尝试更新到最新版本的 dialogflow-fulillment 。
-
感谢@Himanshu,更新到最新版本的 dialogflow-fullfilment 就像一个魅力
标签: node.js alexa dialogflow-es