Comment on page
We’ve already discussed a simple example of a restaurant chatbot, with two different skills triggered by the same utterance – “How much will it be?”. One skill, to calculate the delivery cost, should be triggered only in the context of arranging the delivery order, and another, calculating the reservation cost, should be triggered only when the user is asking about the reservation.
Let’s build this in Dialogflow and Activechat!
We’ll be creating two different intents with the same set of training phrases. The only difference will be the contexts: we’ll set “reservation” as input context for the first one, and “delivery” as input context for another.
Setting up input contexts in the Dialogflow intent
Second intent with the same training phrases and different context
If you test one of your training phrases in the Dialogflow console, you may be surprised. Even when you type the phrase exactly as it’s entered in the intent definition, Dialogflow does not recognize it and throws “Default Fallback” intent instead. How can it be?
Intents are not triggered outside of their contexts
The reason is that we have input contexts set in both of these intents. To make your chatbot able to recognize the “How much will it be?” utterance outside of any of these two contexts, you will need another intent – with the same training phrases but no contexts set.
When you specify input context for the intent, this intent will be triggered only when this context is present!
Let’s store the current conversation context in the $context attribute. When you are in the “reservation” skill, it should be set to “reservation” (use the DATA block to set the value), and when your chatbot user switches to the “delivery” skill, set it to “delivery”.
Here is how this can be done when choosing the skill from the chatbot menu:
Setting the context before triggering the skill
Passing the conversation context from Activechat to Dialogflow
Now, when you type “What’s the cost?” in the chatbot, one of your intents will be triggered – depending on what is the current conversation context.