There are two types of dialogs to consider when building voice interaction scenarios:
- Linear dialogs - the aim of which is to collect the information necessary to complete the required action (e.g. find the best hotel, turn on the right light bulb, or play the desired song)
- Non-linear dialogs - which may have several branches, depending on users’ answers
To build linear dialogs, we use a feature known as slot filling. The following example is an agent for a hotel booking app.
Since our app understands natural language, our travelers can request a hotel in many ways. Depending on how they word their request, there may be several different search parameters:
- “I need to book a hotel."
- “Find a cheap hotel in Rome.”
- “Book a hotel in New York, check in November 10, check out November 15.”
Let’s say our app requires at least three parameters to start the search:
- check-in date
- check-out date
This is where the slot filling feature comes in. Even before you start listing examples in the User Says section, you can list all of the parameters your app can use to perform a search, both required and optional.
When you mark a parameter as Required, you’ll be asked to write prompts that your app will address to your user when they make a request that does not include that parameter.
You can change the order in which your agent will ask these questions by dragging and dropping the parameters in the list.
Your agent will continue to ask these prompts until it has collected information for all required parameters. At any time, users can say "Cancel" and start from the beginning.
Let’s look at an example of a non-linear dialog. In this example, our agent handles a customer satisfaction survey for a hotel.
It starts with these two questions:
- How would you rate the location of the property?
- How would you rate the facilities at the hotel?
For each question, there are four accepted answers:
To build this dialog we’ll need to use contexts. Here’s how it’s done:
First, we create an intent which reacts to the “start” command and triggers the dialog. In this intent we’ll ask the first question and set the outgoing context as “location-question”. As a result, the preferred intents for the answers to this question will have this as the incoming context.
Next we create intents for each of the four expected response variations, with the incoming context “location-question”. These four questions will work only while this context is active.
Now we need setup moving to the next question. To do this we make the following changes to the intents we just created:
- Remove "location-question" as the output context and add "facilities-question"
- Set the Action to
- Add a parameter with the name as "Rate" and the value as the corresponding rating (
- Add a text response for the next question ("How would you rate the facilities at the hotel?")
Then we create four more intents for the possible responses, and we mark “facilities-question” as the incoming context so that these answers will match our new question.
Once again, we mark the action and parameters we want to receive when these new intents are matched, and add the final response in the Speech Response field.