docs/docs/unexpected-input.mdx
Unexpected input is a deviation from the happy path that you have defined. For example:
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.
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.
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:
<Chat caption="A contextual interjection"> <ChatUserText>Hi</ChatUserText> <ChatBotText>Hello! I am restaurant search assistant! How can I help?</ChatBotText> <ChatUserText>I'm looking for a restaurant</ChatUserText> <ChatBotText>What cuisine?</ChatBotText> <ChatUserText>French</ChatUserText> <ChatBotText>How many people?</ChatBotText> <ChatUserText>Why do you need to know that?</ChatUserText> <ChatBotText>I need to know how many people are in your party to ensure the restaurant can accomodate you.</ChatBotText> <ChatBotText>How many people?</ChatBotText> </Chat>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:
slots:
requested_slot:
type: categorical
values:
- cuisine
- num_people
- outdoor_seating
- preferences
- feedback
influence_conversation: true
mappings:
- type: custom
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:
stories:
- story: cuisine interjection
steps:
- intent: request_restaurant
- action: restaurant_form
- active_loop: restaurant_form
- slot_was_set:
- requested_slot: cuisine
- intent: explain
- action: utter_explain_cuisine
- action: restaurant_form
- story: number of people interjection
steps:
- intent: request_restaurant
- action: restaurant_form
- active_loop: restaurant_form
- slot_was_set:
- requested_slot: num_people
- intent: explain
- action: utter_explain_num_people
- action: restaurant_form
How you handle unexpected input depends on whether the response should be context sensitive or not.
For generic interjections:
For contextual interjections:
requested_slot a categorical slot (for forms)