Reputation: 272
I am using DialogFlow's inline editor. In webhook, I send the speech response from google assistant to the user via the WebhookClient.add()
API. But it doesnt seem to be working now. I know that the V2 APIs have been launched and its official now. I thought i was using the V2 API. Looks like its not. Please tell me the alternative for WebhookClient.add()
. I tried using conv
but its not working either. Here's how i used it:
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);
}
Please help me what's wrong with this. UPDATE:Added intent mapping
Upvotes: 0
Views: 773
Reputation: 529
Okay, you're trying to make certain intents include a response via fulfillment so you'll need to make sure you enable the toggle Enable webhook call for this intent
for all the intents where you'd like to include the agent.add() method.
Also, you should only use conv for Actions on Google-specific features.
'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);
});
Upvotes: 2