Home / Dialogflow CX / How to replicate contexts in Dialogflow CX?
Dialogflow CX

How to replicate contexts in Dialogflow CX?

I got this question on my YouTube channel:

I have a question about the context equivalent in CX. In ES, there was a concept of contexts. How can we achieve the same in CX? I tried one way with using condition routes with page transitions and it worked in a way. But are there other ways?

First of all, the approach mentioned by the reader is correct. But it isn’t the full picture. There are some things you can do in CX which aren’t really possible in ES. For example, the concept of session variables is built into CX, so there is no need to explicitly declare a context for that in your CX chatbot. Similarly, fallbacks don’t push your conversation into an unexpected state, so you don’t have to worry quite as much that your conversation might go off track. Explicit retry handling inside CX slot filling means that it is not a problematic feature like it was in Dialogflow ES.

I will also add a few more notes to complete this picture.

In ES, you can use input and output contexts to manage the state of the conversation, but it is quite tedious. But Dialogflow CX is a ground-up rewrite of Dialogflow, and uses the state machine as a fundamental primitive. So creating state machine based conversation flows is much easier in Dialogflow CX.

In practice, this is what it means – you should try to use CX only after you identify the state machine in your conversation flow. This might sound complex, but my beginner tutorial can help you get started with this. Also, remember that your chatbot might not even need Dialogflow CX.

Once you build your state machine/conversation flowchart, then just use CX features and forget about input and output contexts.

For example, in my Learn Dialogflow CX course, I show how to convert an existing ES bot which uses input and output contexts (the decision tree chatbot) into the equivalent CX bot.

This is a part of the flowchart for the ES bot:

And this is the equivalent transition route for CX:


1 You need to understand how state machines work

2 In my opinion, creating a flowchart in Mindomo helps you create your bot in CX more easily

3 Look for places where you can reuse intents in Dialogflow CX

4 Use conditional expressions so that you can add more logic into the conversation layer

<— 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

Similar Posts