05 How to mimic Dialogflow CX session variables in Dialogflow ES

Dialogflow ES Quickstart Templates

In the previous article I explained how you can mimic the behavior of follow up intents to move to the next intent.

One disadvantage of this approach is that you cannot access the information collected from 2 or more steps prior in the current response.

The way around this is to use the concept of session variables.

What are session variables?

In the entry intent (that is one which does not have an input context), add an output context which has a very large lifespan, like 50 or 100. You can now use this output context for the next 50 (or 100) steps in your conversation flow and access user input values

Example

Let us take the example of the lead capture bot, and extend it to use session variables.

Add an intent called add.website.chatbot intent with the following details. Add an output context called session-vars with a context lifespan of 50

Add an intent called user.provides.name with the following details

Add an intent called user.provides.email with the following information

Add an intent called user.provides.url with the following information

The user.provides.url intent ends the conversation. So we display a thank you message and also summarize the user’s input.

Notice that I use the prefix #session-vars followed by the parameter name. That is how you can access parameters stored in the session-vars context.

However, the last parameter $url will only be added into the session-vars in the next step. So you need to just access it via the regular parameter name.

Now test the bot using the Dialogflow Messenger integration

Note: This is my old website and is in maintenance mode. I am publishing new articles only on my new website. 

If you are not sure where to start on my new website, I recommend the following article:

Is Dialogflow still relevant in the era of Large Language Models?

Leave a Reply