I'm using the default dialogflow code provided in the inline editor, based on dialogflow-fulfillment ^0.5.0 to collate all the parameters given over several follow up intents. I have a setup where follow up intents ask questions, resulting in a final intent that has all questions asked.
Pulling data from previous intents inside the dialogflow console to include in a response would just be using i.e. #order-cream-followup.chocolate-type
to get a parameter from a previous intent or $quantity
to get a parameter from the current intent. But while agent.parameters['quantity']
works like $quantity
, I can't find the way to do the equivalent of #order-cream-followup.chocolate-type
within dialogflow-fulfillment
Apologies if this is an obvious answer, I'm getting lost in the various different documentation for dialigflow and action on google in general.
My code:(currently just logging to console before adding code to handle pushing out that data)
// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
'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 placeOrder(agent) {
console.log('placing order:');
console.log(agent.context.get('order-cream-followup').parameters['choctype']);
agent.add('Thanks ' + agent.parameters['name'] + ', please collect your order from the window.');
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('order - cream - marshmallow - check - yes - name - submit', placeOrder);
agent.handleRequest(intentMap);
});