Sometimes I see questions like these in the Dialogflow forum.
So, I got one intent working. How can I now "move" the conversation to the next intent?
In Intent1, declare an output context called contextA. In the next intent you want to fire, use contextA as the input context. You have now chained Intent1 and Intent2 using contextA.
Is that all?
There is quite a bit more. But that's the basic idea for every intent you are trying to chain into the conversation.
A practical example
I need to get three values from the user - their given name, their last name and their zip code.
I will be using the naming convention I mentioned in my previous post.
Step 1: The Welcome Intent
As soon as the user says Hi, the Default Welcome Intent will respond with a question asking for the user's given name. The output context is set to awaiting_first_name
Step 2: Get first name
In the next intent, we get the first name. We use awaiting_first_name as the input context, and set awaiting_last_name as the output context.
When the user types in their first name, since the awaiting_first_name input context has already been set, and considering that the user's input matches the expected pattern (i.e. they typed in something which can be recognized as the first name), it triggers the UserProvidesFirstName intent.
Can some other intent possibly fire during this step?(Hint: Yes) Read my article about intent candidate selection and leave a comment on what you think.
Step 2: Get last name
In the next intent, we get the last name. So here, we set awaiting_last_name as the input context and set awaiting_zip_code as the output context.
Just like in the previous step, if the user types in something which can be identified as a last name, the UserProvidesLastName intent will be triggered.
Step 4: Get Zip Code
Finally, we will get the zip code in the next intent. Here, we set awaiting_zip_code as the input context, and since we don't wish to collect any more inputs from the user, the output context will be left blank.
We used a very simple example to see how to chain intents to receive multiple user inputs. Note that we could have used slot filling for the same purpose, but I have chosen to do it using only contexts.
There are some good reasons to avoid slot filling, and I have already written about it. In this case, however, my goal is to show how to chain intents together in a conversation.
In a future article, I will build on what we discussed in this post to handle the exceptions.
- Dialogflow Messenger Quiz Bot
- Dialogflow Zobot: Selection Triggers the next intent
- Integrating Dialogflow with Zoho live chat
- 5 things you cannot do using the Dialogflow Messenger integration
- Dialogflow Architecture
- Dialogflow Python webhook tutorial
- Dialogflow training
- Dialogflow vs Lex vs LUIS vs Watson vs Chatfuel
- Convert your WordPress website into a Dialogflow FAQ chatbot
- Dialogflow Messenger Interactive Learning Bot