When you are collecting a set of inputs from the user, you should use a context with a very large lifespan as a sort of a “session variable”. I refer to this as session-vars in many of my videos.
There are three things you should remember when using session variables.
1 You should not add the session-vars to all intents
For example, suppose you collect a set of inputs.
You will add the session-vars as output context to the first intent which collects a single input value.
And once you are done collecting the relevant information, you will send the data across to a webhook to process the collected data.
2 You should add a session-vars to all intents which “start” collecting data
For example, in the chart above, the intent where user says “I want to book a flight” is the starting point of that conversation flow. So it should have session-vars set as the output context.
3 Remember to clear session vars after all input is collected
In other words, in the image above, after the data is sent to the webhook, be sure to clear the session-vars lifespan to zero. This will help if user tries to reinitiate the whole flow (otherwise your old values may interfere with the new ones)
I show an example of this in my quickstart template which explains the “Start Over” patten.
4 Use different variable names if you are collecting different values of the same data type
For example, in the chart above you will collect two different dates – one for departure date and one for return date.
Make sure you use different params for these dates inside your intent. Otherwise the second value will overwrite the first value.
If you make sure you follow these guidelines, you will be able to use the session-vars context without much difficulty.
<— End of article —>
This website contains affiliate links. See the disclosure page for more details.
"The magic key I needed as a non-programmer" The custom payload generator was the magic key I needed (as a non-programmer) to build a good demo with rich responses in DialogFlow Messenger. I've only used it for 30 minutes and am thrilled. I've spent hours trying to figure out some of the intricacies of DialogFlow on my own. Over and over, I kept coming back to Aravind's tutorials available on-line. I trust the other functionalities I learn to use in the app will save me additional time and heartburn. - Kathleen R Cofounder, gathrHealth
"Much clearer than the official documentation to be honest" Thanks a lot for the advice (of buying and following your videos)! They helped a lot indeed. Everything is very clear when you explain, much clearer than the official documentation to be honest 🙂 Neuraz T Review for Learn Dialogflow CX
"I will strongly recommend this course because even I can learn how to design chatbot (no programming background)" I think Aravind really did a great job to introduce dialogflow to people like me, without programming background. He organizes his course in very clear manner since I have been a college professor for 20 years. It is very easy for me to recognize how great Aravind’s course is! Very use-friend and very easy to follow. He doesn’t have any strong accent when he gives the lectures. It is so easy for me to understand. Really appreciate it. Yes, I will strongly recommend this course because even I can learn how to design chatbot (no programming background) after studying Avarind’s course, you definitely can! Ann Cai Review for Learn Dialogflow ES