Reusing intents with context
When the intent 'who are you' is recognised our train traveling assistant introduces himself and asks if the user would like to order a ticket.

In a totally different part of the conversation, at the end of the Book train ticket
conversation flow the chatbot asks for a booking confirmation.

Both bot questions expect a user intent answer of yes or no. To support reuse of intents we can define a bot dialog intent linked to a certain context. The user will only be redirected to the linked bot dialog if the intent is recognized and the user is in a specific context.
Add the
yes
andno
intents and train them with expressionsIn the bot dialog
Confirm booking
go to the NLP tab.Add an output context
confirm_booking
. Press enter to create the output context.When a user reaches this bot dialog the output context is added to the user session context.

Add the
Confirmed Booking
bot dialog with required contextconfirm_booking
and intentyes
in the NLP tab. When theyes
intent is returned by the NLP model and the user has the contextconfirm_booking
, he will be redirected to this bot dialog.

Add the
Cancel booking
bot dialog with the required contextconfirm_booking
and intentno
Add output context
who_are_you
in the bot dialogWho are you
.

Add the
Yes book ticket
bot dialog with required contextwho_are_you
and intentyes
.Add the
No book ticket
bot dialog with required contextwho_are_you
and intentno
Test the flow in the emulator
Click on the Emulator tab to test your flow. Let us ask our traveling assistent who he is.

Go to the debug mode and select the first message in the messages list
who are you
to view the received information after sending this user message.

The context
who_are_you
has been added to the user session with an initial lifespan value of1
as you can see in the context section.The user is redirected to the bot dialog
The NLP result section shows that the who are you intent has been recognised as top scoring intent.
In the Message Data section we see the message being sent by the bot as answer

In the User Session section we see the context list of the user with name and lifespan

The next tutorial teaches us how to redirect the user to a specific bot dialog depending on the conditions on the values in session variables.
Last updated
Was this helpful?