Intents and QnAs

This document will explain how Botfuel Dialog processes intents and QnAs.

Definition

Intents and QnAs are defined by the user in the Botfuel Trainer. The trainer uses the Classification Service for training and classification.

  • Intent defines an action that the user is looking to perform. Each intent has a list of training phrases that are used to detect if the user input (i.e., an utterance) corresponds to the intent.
  • QnA consists of several paraphrases of a question and the corresponding answer. If the user input is similar to one of those questions then the QnA answer will be sent back to the user.

We can think of QnA as a special intent where the example questions are training phrases. The difference between intents and QnAs is that for a QnA we have predefined answers to send back to the users, whereas each Intent must be handled by a Dialog to generate bot messages.

Your bot can have only intents, only QnAs, or both.

Processing

Given an utterance, the Classification Service computes a list of a maximum of three Intents or QnAs along with their probabilities as well as relevant data. The Dialog Manager then uses this list to execute dialogs. There are three possible cases:

Case 1: only one intent

Example: the user sentence is I want a ticket to Paris next Friday and the Classification Service returns:

[
  {
    "type": "Intent",
    "label": "trip",
    "probability": 0.9,
    "resolvePrompt": "You want to book a trip?"
  }
]

In this example the Classification Service returns 1 intent and there is no confusion.

In this case, the DialogManager will execute the dialog with the same name as the intent label, which is trip-dialog.js or trip-dialog.<adapter>.js in this example. See dialogs reference for more details on dialogs and dialog resolution.

Case 2: only one QnA

The user sentence is What is your opening time? and the Classification Service returns:

[
  {
    "type": "QnA",
    "title": "Opening time",
    "probability": 0.9,
    "resolvePrompt": "You want to know our opening time?",
    "answers": [
      [
        { "value": "We are open from 9am to 7pm from Monday to Saturday." },
      ]
    ]
  },
]

In this example the Classification Service returns 1 QnA and there is no confusion.

In this case, the DialogManager calls the QnasDialog, which in turn calls the QnasView, which returns the QnA answer.

class QnasView extends View {
  /** @inheritDoc */
  render(userMessage, { answers }) {
    logger.debug('render', userMessage, { answers });

    return answers[0].map(message => new BotTextMessage(message.value));
  }
}

Case 3: more than one intent or QnA

The user sentence is refund! and the Classification Service returns:

[
  {
    "type": "QnA",
    "title": "Refund policy",
    "probability": 0.9,
    "resolvePrompt": "You want to know our refund policy?",
    "answers": [
      [
        { "value": "You can return a product for up to 30 days from the date you purchased it." }
      ]
    ]
  },
  {
    "type": "Intent",
    "label": "refund",
    "probability": 0.8,
    "resolvePrompt": "You want to refund a product?"
  }
]

In this example the Classification Service detects that the user message can correspond to the "refund" intent where the user wants to return a product and get a refund, or to the "Refund policy" QnA where the user just wants to know about the refund policy.

In this case the bot will ask the user to clarify by calling the ClassificationDisambiguationDialog, which in turn calls the ClassificationDisambiguationView that asks the user to select among different choices using the USER PROMPT parameters defined in the Botfuel Trainer.

Note: as with QnasView, you can redefine the ClassificationDisambiguationView to better fit your needs.