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
yesandnointents and train them with expressionsIn the bot dialog
Confirm bookinggo 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 Bookingbot dialog with required contextconfirm_bookingand intentyesin the NLP tab. When theyesintent is returned by the NLP model and the user has the contextconfirm_booking, he will be redirected to this bot dialog.

Add the
Cancel bookingbot dialog with the required contextconfirm_bookingand intentnoAdd output context
who_are_youin the bot dialogWho are you.

Add the
Yes book ticketbot dialog with required contextwho_are_youand intentyes.Add the
No book ticketbot dialog with required contextwho_are_youand 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 youto view the received information after sending this user message.

The context
who_are_youhas been added to the user session with an initial lifespan value of1as 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?