Context

Context is what Dialogflow uses to represent context of the user’s message. This can be helpful for differentiating phrases which may be vague or have different meanings depending on the user’s preferences, geographic location, or the topic of conversation. For example, if a user says "I'm interested", you wouldn't know what they are interested in unless you knew the context of that message. In a Chatfuel block, you can add a Setup User Attribute card and add a {{context}} User Attribute. Set any value for your context that represents your context, then include the {{context}} User Attribute in the JSON API so Janis can send your context to Dialogflow.

Dialogflow Context for Chatfuel

In a Dialogflow intent, include the value that matches your User Attribute value for {{context}} in Chatfuel.

Dialogflow Context for Chatfuel

You can pass multiple contexts to Dialogflow from Chatfuel by setting the User Attribute value to be a comma separated string. for example: “buyer, renter” would result in two contexts being sent.

Clear Context

If you set context in one Chatfuel block, you can clear the context as well in another block. You can do that by including {{context}} at the top of a Chatfuel Block and setting the value to Not Set. This will tell Janis to ignore a specific context in Dialogflow.

Dialogflow Context for Chatfuel

Reset Contexts

Context won’t reset, or expire unless you manually control the context, and you can also clear all contexts from Chatfuel by using {{reset contexts}} By default, the value is set to false, but if the value is set to true, all current contexts in a session will be reset before the new ones are set. Janis will query Dialogflow with {{reset contexts}} set to true.

Context Lifespan

Context can have a lifespan so that you can maintain a dialog with your users around a specific topic for a period of time. You can maintain context for up to a maximum of 5 user requests, but you may also choose to limit the context with a lower number, or expire the context immediately by setting a value of 0. In Chatfuel, add a Set User Attribute card to a block and add a {{context lifespan}} User Attribute. Enter a number from 1 to 5 as a value for this User Attribute, then include the {{context lifespan}} User Attribute in the JSON API so that Janis can process your request.

Dialogflow Context for Chatfuel

Contextual Fallback Messages

While Dialogflow has a Default Fallback Intent and that serves as your new Default Message for Chatfuel, you can also create multiple Fallback Intents in Dialogflow, with each one differentiated by the addition of a context to an Intent. You can see in this video how you can set and clear context in Chatfuel and create a contextual Default Fallback in Dialogflow to respond to users when they send you unrecognizable, or unrelated messages in specific situations like a marketing funnel.


More Resources

Here are more Janis resources that will help you understand what you can do with Dialogflow Context and Chatfuel:

Understanding Dialogflow Context

A strategy for managing Dialogflow Intents when you want to add Context