Reputation: 51
Team, In DialogFlow, I getting a value from the user in intent A; (let's say it's the employee ID). In next Intent B, I want to use the Employee ID (collected in previous intent A) and provide a response and execute a webhook.
I am able to collect the value in Intent A and display in same intent. When tried to pass it to another Intent, I am failing miserably.
Appreciate ayny help in this regard.
Tnx Sathiya
Upvotes: 2
Views: 1602
Reputation: 5256
You will need to use contexts to store the parameters and access these parameters through the context in the other intent.
Check out my full answer here
{
"fulfillmentText":"This is a text response",
"fulfillmentMessages":[ ],
"source":"example.com",
"payload":{
"google":{ },
"facebook":{ },
"slack":{ }
},
"outputContexts":[
{
"name":"<Context Name>",
"lifespanCount":5,
"parameters":{
"<param name>":"<param value>"
}
}
],
"followupEventInput":{ }
}
from NodeJS code
save in first Intent
let param1 = [];
let param2 = {};
let ctx = {'name': '<context name>', 'lifespan': 5, 'parameters': {'param1':param1, 'param2': param2}};
agent.setContext(ctx);
Access in other Intent as
let params = agent.getContext("<context name>").parameters;
let param1 = params.param1;
let param2 = params.param2;
Upvotes: 3