I have one intent "Buy-Car" where I ask some basic information like color, size, region. These are saved in parameter. Then I trigger another intent called "TriggerBot" which will call my backend process to fulfill the order via fulfillment. How do I pass the parameter information from one intent to the other one?
Here I define the parameters in Buy-Car intent:
Here I define the TriggerBot intent:
Here is my code for fulfillment:
function TriggerBot(agent) {
console.log("Parameters: "+JSON.stringify(agent.parameters));
const color = agent.parameters.color;
const size = agent.parameters.size;
const region = agent.parameters.region;
}
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));
let intentMap = new Map();
intentMap.set('Default Welcome Intent', Welcome);
intentMap.set('Default Fallback Intent', Fallback);
intentMap.set('Trigger Bot', TriggerBot);
agent.handleRequest(intentMap);
}
Everything is undefined in this case, however if I use just one intent, it works fine. So the value is lost when transferring from one intent to another.
There are 3 main ways to pass parameters between intents in Dialogflow ES
You can use follow-up intents to automatically set contexts for pairs of intents. A follow-up intent is a child of its associated parent intent.
Followup intents are helpful for keeping track of what happened in the conversation. They also help you pass parameters between intents.
Declare something called a session variable in each of your Dialogflow entry intents.
This has the added benefit of being able to pass parameters between intents even if the conversation takes an unexpected turn.
It was described in another stackoverflow thread - How to save data between conversations in Dialogflow?.
In addition I think you could also find some additional information in the below links