When i am trying to set context for fetching user parameters,it is throwing error on agent.context.set method.
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));
agent.context.set({
'name':'test-context',
'lifespan': '5'});
function getUserInfo(agent) {
// Get Actions on Google library conv instance
const [fullname, email, age, disease, city, hospital, beneficiary_name, beneficiary_name_relation] = [agent.parameters.fullname,
agent.parameters.email,
agent.parameters.age,
agent.parameters.disease,
agent.parameters.city,
agent.parameters.hospital,
agent.parameters.beneficiary_name,
agent.parameters.beneficiary_name_relation];
I am getting following error:
TypeError: Cannot read property 'set' of undefined
at exports.dialogflowFirebaseFulfillment.functions.https.onRequest (/srv/index.js:26:17)
at cloudFunction (/srv/node_modules/firebase-functions/lib/providers/https.js:57:9)
at /worker/worker.js:783:7
at /worker/worker.js:766:11
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
It is supposed to test test context but throwing this error. what should I do?