Create Intelligent Bots with Context Handling
This article will present practical examples of context handing and how this can make your bot smarter and increase the positive experience of your users.Our previous articles, focused on Dialog Management, provide a top-level explanation of this topic and should be reviewed before you continue with this practical guide.
From the text below, you’ll learn how to apply context-related features to your bot’s conversations. The following conversations are samples to demonstrate key features.
What went wrong?
The bot did not keep the full context of the conversation. The information that should be in context are a trip to Barcelona and roaming. The user mentions a reference to the trip’s location with there which should be resolved by the bot.
How can we implement this?
A Global Pre-Listener can be used to pick up and store the general topic of the conversation (roaming). It should be able to store the reference to a location. In the example below, you can see how this can be done with Entities and Propagation Scripts.
We may also want to limit the lifetime of the conversation context storage to a certain number of subsequent interactions. In the example above, we have added a lifespan limitation of 3 interactions, which means that our context will be available within the current interactions and the next two with the bot. As you see, this is fully customized, and the lifespan can be shortened or extended for each use case. You can read all about the Lifespan setting of a variable here.
We can now add an additional trigger to our Roaming Issues flow. This trigger will have two Match requirements: a ML Class Match to match on the natural language input from the user, and a Global Variable Context Match that uses the topic variable we updated in our listener to check if the context of the conversation is roaming. Finally, we would need an answer to the user with the desired response.
Now that our first example is handled correctly by the bot, let’s take a look at another example.
What went wrong?
In this case, our bot receives a direct follow up to the just finalized conversation flow but it no longer has context about the topic of the last interaction, and the input therefore ends in a SafetyNet answer.
How can we implement this?
Here we can also use the approach discussed in the previous example, but we can also make use of one of the Predefined Context Restrictions which come with the Teneo Dialog Resources out of the box.
The Follow up of Flow and Follow up of Folder contexts are designed to handle exactly these kind of situations – direct follow ups on the same topic. Whether you need to choose the Follow up of Flow or Follow up of Folder depends on the solution structure of your project. The latter would be an option if you organized your flows in topic-dependent (sub-)folders. The Follow up Flow finds its usage often when it is expected that the user could repeat the question just around another object.
In the below image, you can see a Flow context follow up, which means that the previous interaction with the bot must have triggered the same flow as the one being evaluated now for this trigger to match. Additionally, it needs to match on a NUMBER Entity here, as it is the case in our previous conversation example.
If we think of human and bot conversations, the likelihood to receive a direct follow up on the same context is a pretty common scenario, while a change of the topic even in an interaction between humans would need a kind of reactivation of the topic (e.g. By the way, back on roaming, I also want to…). Thus, the Follow up of Flow scripted context can be very helpful to handle this kind of direct follow-ups.
You can easily create further Scripted Contexts for your project. You can find some ideas in this article here.
Again, a trigger which handles a direct follow up could have easily handled the situation and explained the user if necessary that this information cannot be given by the bot. It’s still a much better user experience if the bot understands this follow up even if no final answer can be given.
Conclusion
Maintaining conversational context and applying it to new situations is essential for intelligent bot development.
Teneo provides multiple features that are available out of the box, making it easy to expand upon logic and improve the performance of your solution.
By implementing the features highlighted in this guide, your bots will be able to deliver a significantly better experience for your customers.
What has your experience been so far regarding Context when designing bot conversations?
.