I follow up an intent for intent let's say "master intent" to have a child intent follow as yes and no response intent
If it's yes i want to get the parameters from the master intent I am trying to access it using context like this :
var name = agent.context.get('saveContact.saveContact-yes').params['name'];Cannot read property 'get' of undefined
but I don't know what to put in the get Is it the context name ? or intent name for the master or the specific child intent name ? I tried the both and get Null
I've got Cannot read property 'get' of undefined in the log .
Libraries :
"firebase-functions": "^2.0.2",
"firebase-admin": "^5.13.1",
"googleapis": "^27.0.0",
"actions-on-google": "2.2.0",
"dialogflow-fulfillment": "^0.4.1"
rest of the code :
function SaveContact(agent){
//var name = agent.parameters.name;
var name = agent.context.get('saveContact.saveContact-yes').params['name'];
var email = agent.context.get('saveContact.saveContact-yes').params['email'];
// var email=agent.parameters.email;
return admin.database().ref('/contacts').push({name: name,email:email}).then((snapshot) => {
// Redirect with 303 SEE OTHER to the URL of the pushed object in the Firebase console.
agent.add('added sucessfully');
// console.log('database write sucessful: ' + snapshot.val());
});
}
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response }); /// Thid is to handle the communication with dialogflow
let intentMap = new Map();
intentMap.set('makeAppointment', makeAppointment); // It maps the intent 'Make Appointment' to the function 'makeAppointment()'
intentMap.set('saveContact-yes', SaveContact);
agent.handleRequest(intentMap);
});