Custom User Attributes you can use to control Dialogflow from Chatfuel blocks
The Janis API provides you with a complete set of User Attributes to control the flow of data from Chatfuel to Dialogflow
Click here for the complete guide to building Dialogflow + Chatfuel bots
One of the benefits of using Janis to manage your integration between Chatfuel and Dialogflow is the seamless exchange of data between systems.
User Attributes created in Chatfuel become Context Parameters in Dialogflow, and Dialogflow Context Parameters magically become User Attributes you can access and use in Chatfuel.
Here is list of Custom User Attributes that you‘ll find valuable in setting up a variety of connections between your Chatfuel bot and Dialogflow
{{user input}}
This is a required User Attribute that you will need to include in any instance of the JSON API. The{{user input}}
User Attribute captures everything the user says to your Chatfuel bot and sends that data to Dialogflow. In your Default answer block, you’ll want to make sure you have a User input card.
{{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. 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.
In a Dialogflow intent, include janis in the context and include a context that matches your User Attribute value for {{context}}
in 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 (in addition to the “janis” context).
{{reset contexts}}
Context won’t reset, or expire unless you manually control the context, but you can do that 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 resetContexts set to true. (Learn more https://dialogflow.com/docs/reference/agent/query)
{{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.
{{event}}
if you send an {{event}} attribute, then the value will be used in the Dialogflow query. The value needs to match an event in an Intent(Learn more https://dialogflow.com/docs/events)
{{lang}}
While you can include the built-in {{locale}}
User Attribute in the JSON API to make a language request from Chatfuel, you will find you have even more control and reliability when you use our custom {{lang}}
User Attribute and set the value of the User Attribute to a language code that is recognized by Dialogflow.
A good example of this can be found in this tutorial which shows you how to create a multi-language Chatfuel bot using both Dialogflow and uses the {{lang}}
User Attribute to control which language to deliver messages to your users.
{{dialogflow speech}}
There may be times you want to use a text response from Dialogflow, but you want the UI capabilities of Chatfuel. For example, Dialogflow doesn’t provide typing dots but you may want to include these in your intelligent Dialogflow responses so your responses appear more natural. In your Dialogflow response, include a text response as well as a redirect to a Chatfuel block.
While I have shows these as two responses in Dialogflow, you can create one payload response as well like this:
{
“messages”: [
{“text”: “This message will appear in a Chatfuel block named test”}
],
“redirect_to_blocks”: [“test”, “Default answer”]
}
In a Chatfuel block set a User Attribute of {{dialogflow speech}}
, then drop this custom User Attribute into a text card just below some typing dots. Your Dialogflow text response will be included in the Chatfuel card.
Next Steps
🤖 Need an easy way to connect Dialogflow to Chatfuel?
👉 https://www.janis.ai
🤖 Training Dialogflow NLP takes time. Need a Dialogflow template?
👉 https://janis.ai/dialogflow-templates/
🤖 Learn more how to build chatbots with Chatfuel and Dialogflow
👉 https://janis.ai/chatfuel