notice
This is documentation for Rasa Documentation v2.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (3.x).
Handling Unexpected Input
One thing you can count on when building a conversational assistant is that users will say unexpected things. This page is a guide on handling unexpected input.
Unexpected input is a deviation from the happy path that you have defined. For example:
- A user walks away in the middle of a conversation about their subscription, then comes back and says "hi!"
- A user asks "Why do you need to know that?" when the bot asks for their email address.
This page is a guide on methods for handling unexpected input that is still within your bot's domain. Depending on what kind of unexpected input you're trying to handle, some or all of the methods describe may be applicable for you. This guide is not about disambiguating user input or handling out-of-scope questions; for these cases see the guide on fallback and human handoff.
User Interjections
There are two kinds of unexpected input: generic interjections, and contextual interjections. Generic interjections are interruptions that should always get the same response regardless of the conversation context. If you already have a rule defining the response to an intent, you don't need to do anything else to handle it as an interruption. FAQs and chitchat are common generic interjections. A contextual interjection is one whose response depends on the conversation context. For example, if a user asks "Why do you need that?", the answer will depend on what the bot just asked for.
Contextual Interjections
Handling contextual interjections is similar to handling contextual conversations in general.
One common case of contextual interjections is during slot filling for form, where the user asks “Why do you need to know that?” or "Can you explain that?". The response should differ for each slot. For example:
Since we want the requested_slot
to influence the conversation,
we need to set the property influence_conversation
of the slot requested_slot
to true
, and assign it the categorical type:
This means that the dialogue model will pay attention to the value of the slot when making a prediction (read more about how slots influence the assistant's behaviour).
You can then write stories for specific responses to interjections based on the value of requested_slot
, for example:
Summary
How you handle unexpected input depends on whether the response should be context sensitive or not.
For generic interjections:
- Define rules for single-turn interactions
- Use the ResponseSelector for FAQ and chitchat interruptions
For contextual interjections:
- Make
requested_slot
a categorical slot (for forms) - Write stories for context-specific responses to interjections, using slot values where applicable