我正在使用DialogFlow的嵌入式编辑器。在webhook中,我通过WebhookClient.add()
API将Google语音助手的语音响应发送给用户。但它现在似乎无法正常工作。我知道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);
}
请帮助我这有什么问题。 更新:添加了意图映射
答案 0 :(得分:2)
好的,您正在尝试使某些意图包括通过实现的响应,因此您需要确保为要包括agent.add的所有意图启用切换Enable webhook call for this intent
。 ()方法。
另外,您只应针对特定于Google的功能使用conv进行操作。
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = 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 welcome (agent) {
agent.add(`Hey buddy, welcome to my agent!`);
}
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
agent.handleRequest(intentMap);
});