Tutorial 3 - Automatic human handoff with fallback intent
Add automatic human handoff using fallback intent to your Dialogflow Agent
NOTE: this tutorial uses Dialogflow just as an example for a programmatic external chatbot integration. If you instead need to easily embed your Dialogflow Agent in your conversations, please use the Tiledesk Dialogflow Connector, the out-of-the-box Dialogflow integration that doesn't require programming skills.
Fork the tutorial code
We'll start from Dialogflow Tutorial 1, just adding a small library to our original endpoint.
You must use the code in Tutorial 1. The code is available on Github here.
Fork the tutorial code using the Fork button. Now you have a copy of the tutorial on your own repo.
Introduction
This time we'll give a try to the second endpoint already embedded into our nodejs app:
As in Dialogflow Tutorial 1 you have to create a Dialogflow agent, train the same Agent following the instructions in this tutorial, then go to Tiledesk and create an external bot and connect it to Routing (or to a Department).
How this code works
As you can see this new end point starts with thse two lines of code
The first variable consecutive_fallback_count saves the current number of fallbacks for every conversation. The second variable MAX_FALLBACKS represents the maximum number of consecutive fallbacks in a conversation.
In this tutorial, every time there is a fallback the number of consecutive fallbacks for the same conversation in incrememnted by one unit.
As soon as the total number of consecutive fallbacks reaches MAX_FALLBACKS a couple of messages is sent back to the client. The first message is shown to the client and is a custom message that you can send to indicate that the conversation is switching to humans. The second message \agent is intercepted by Tiledesk and drives the system to remove the bot and invite an agent to the conversation, following the Department rules.
To hide a message simply add a sub-property subtype: 'info' to the attributes property of a message.
Enjoy Tiledesk!
Do you have feedback on this article? Please send us your feedback writing an email to info@tiledesk.com
Last updated