Я пытаюсь интегрировать Alexa с Dialogflow и использую диалоговый поток для выполнения намеренного запроса.Для ответа статического намерения я могу получить ответ правильно, но когда я пытаюсь интегрировать webhook для полного заполнения, я получаю ниже диалоговое окно исключения:
TypeError: Невозможно прочитать свойство 'source' undefined в 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:19)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 (внутренняя / process / next_tick.js: 73: 7) в process._tickDomainCallback (внутренняя / 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);
});