Version: Latest

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.

NLU-based assistants

This section refers to building NLU-based assistants. If you are working with Conversational AI with Language Models (CALM), this content may not apply to you.

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:

User: Hi

Bot: Hello! I am restaurant search assistant! How can I help?

User: I'm looking for a restaurant

Bot: What cuisine?

User: French

Bot: How many people?

User: Why do you need to know that?

Bot: I need to know how many people are in your party to ensure the restaurant can accomodate you.

Bot: How many people?

A contextual interjection

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:

domain.yml
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.yml
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

Summary

How you handle unexpected input depends on whether the response should be context sensitive or not.

For generic interjections:

For contextual interjections:

  • Make requested_slot a categorical slot (for forms)
  • Write stories for context-specific responses to interjections, using slot values where applicable