Define the Dialog to Collect and Confirm Required Information

To simplify your code for collecting and confirming slot values, create a dialog model. This identifies required slots and the prompts to collect and confirm the slot values. To use these prompts in a dialog with the user, respond to an incoming IntentRequest with the Dialog.Delegate directive. Alexa then determines the next step in the dialog and uses the appropriate prompts to ask the user for the information.

Dialog model components

There are four components to the dialog model:

  • Required slots and prompts: A required slot represents information that your skill must have in order to fulfill the user's request. For instance, the PlanMyTrip intent requires, at a minimum, the starting city (fromCity), destination city (toCity), and date (travelDate) to save trip details to a list. You can control the order in which Alexa asks for the slot values.
  • Slot confirmation prompts: You can optionally designate a required slot as requiring confirmation. This means that the user must also confirm the slot value with a yes/no response before proceeding. Use confirmation sparingly, as users may find it annoying to be asked for confirmation frequently.
  • Intent confirmation prompts: You can specify that the entire intent requires confirmation. This is common for skills that order products or make reservations. A confirmation prompt typically repeats back to the user all the information previously provided for the user to confirm. Again, use confirmations sparingly to avoid annoying users.
  • Slot validation rules and prompts: You can configure a set of validation rules that the slot value provided by the user must pass to be considered valid. If the value fails validation, Alexa can use your prompts to ask for a corrected value. You can use slot validation rules with both required and non-required slots.

Note that interaction model cannot include the deprecated AMAZON.LITERAL built-in slot type. To add a dialog model with an older skill that still uses AMAZON.LITERAL, update the skill to use a custom slot type first.

For more about dialog scenarios, see About Managing the Conversation with the User.

Identify required slots and prompts

If a slot is required, your skill must get a valid value for it before you can complete the user's request.

Define prompts and utterances to collect these values. To use these prompts and utterances in a dialog with the user, return the Dialog.Delegate directive.

Section Description Examples

Alexa Speech Prompt

Questions that Alexa speaks to ask the user for the slot value.

  • The prompts should be specific to collecting just this one slot.
  • If you provide more than one prompt, Alexa chooses one at random. This gives Alexa a more conversational, human style.
  • Write the prompts using a conversational style.
  • For general tips for prompts, see What Alexa Says
  • If you include SSML, enclose the entire prompt in <speak></speak> tags.

For the fromCity slot, you could have prompts like this:

What city are you leaving from?

Where are you starting your trip?

From where did you want to start your trip?

User utterances

Utterances users can say to answer the questions provided in the prompts.

  • When Alexa asks the user to fill the slot, the service biases the speech models to listen for the response utterances you provide here. This occurs when you return either Dialog.Delegate or Dialog.ElicitSlot.
  • Make sure the utterances represent the most likely ways you expect users to answer the question.
  • Use the standard curly bracket ({ }) slot notation to identify the slot name.
  • You can include an utterance consisting of just a slot value with no surrounding text – again, use the curly bracket notation.

For the fromCity slot, you might have utterances like this:

{fromCity}

i'm leaving from {fromCity}

flying out of {fromCity}

traveling from {fromCity}

my trip starts in {fromCity}

The above examples would support a conversation like this for the fromCity slot:

User: Alexa, tell Plan My Trip that I'm going on a trip on Friday (This utterance includes a value for one required slot (travelDate), but is missing fromCity and toCity.)
Plan My Trip: What city are you leaving from? (One of the Alexa prompts defined for fromCity.)
User: I'm leaving from Seattle

To edit the prompts and utterances for a required slot:

  1. In the left-hand navigation, find the intent and its list of slots, then click the slot name.

    Alternatively, from the page for a particular intent, find the slot in the Intent Slots section below the sample utterances and click the Edit Dialog link.

  2. Under Slot Filling, enable the Is the slot required to fulfill the intent option.
  3. Fill in the Alexa Speech Prompt and User utterances sections.

Enable confirmation for a slot

If a slot requires confirmation, your skill needs to ask the user to confirm the slot value with "yes" or "no".

Define a set of prompts to get this confirmation from the user. To use these prompts in a dialog with the user, return the Dialog.Delegate directive.

Section Description Examples

Alexa Speech Prompt

Questions that Alexa speaks to ask the user to confirm the slot value.

  • The prompts should be specific to confirming just this one slot. See intent confirmation if you need to do a final confirmation for the entire intent.
  • The prompts should be worded such that the user can respond with "yes" or "no".
  • If you provide more than one prompt, Alexa chooses one at random. This gives Alexa a more conversational, human style.
  • Include the slot name in the prompt in curly brackets ({ }). When speaking the prompt, Alexa replaces this token with the value the user previously provided.
  • If you include SSML, enclose the entire prompt in <speak></speak> tags.

For the fromCity slot, you could have confirmation prompts like this:

You wanted to leave from {fromCity}, right?

I heard you want to leave from {fromCity}, right?

You said you're leaving {fromCity}, right?

Please verify that you want to start your trip in {fromCity}

The above examples would support a conversation like this for the fromCity slot:

User: Alexa, tell Plan My Trip that I want to travel from Seattle to Portland on Friday (This utterance includes values for all the required slots (fromCity, toCity and travelDate).)
Plan My Trip: You said you're leaving from Seattle, right? (Confirmation prompt for fromCity slot value.)
User: Yes.
Dialog continues…

To enable confirmation for a required slot:

  1. In the left-hand navigation, find the intent and its list of slots, then click the slot name.

    Alternatively, from the page for a particular intent, find the slot in the Intent Slots section below the sample utterances and click the Edit Dialog link.

  2. Under Slot Confirmation, enable the Does this slot require confirmation? option.

  3. Fill in the Alexa Speech Prompt section with your prompts.

Enable confirmation for an intent

If the entire intent requires confirmation, your skill needs to ask the user to confirm the action the intent will take with "yes" or "no".

Define a set of prompts to get this confirmation from the user. To use these prompts in a dialog with the user, return the Dialog.Delegate directive.

Section Description Examples

Alexa Speech Prompt

Questions that Alexa speaks to ask the user to confirm the entire intent.

  • The prompts should be specific to confirming the entire intent.
  • The prompts should be worded such that the user can respond with "yes" or "no".
  • If you provide more than one prompt, Alexa chooses one at random. This gives Alexa a more conversational, human style.
  • Include all of the required slots in the prompt in curly brackets ({ }). When speaking the prompt, Alexa replaces these tokens with the slot values previously provided.
  • If you include SSML, enclose the entire prompt in <speak></speak> tags.

For the PlanMyTrip intent, you might have confirmation prompts like this:

I'm saving your trip from {fromCity} to {toCity} on {travelDate}, Is that OK?

Please confirm that you want to travel from {fromCity} to {toCity} on {travelDate}

Are you sure you want me to save a trip from {fromCity} to {toCity} on {travelDate}?

The above examples would support a conversation like this for the PlanMyTrip intent:

…previous interaction to invoke the intent and ask the user for fromCity, toCity, and travelDate.

Plan My Trip: I'm saving your trip from Seattle to Portland on April 21st. Is that OK? (Confirmation prompt for the intent)
User: Yes.

To enable confirmation for an intent:

  1. Click an intent from the left-hand navigation to open the detail page for the intent.
  2. Under Intent confirmation, enable Does this intent require confirmation?.
  3. Fill in the Alexa Speech Prompt for the intent.

Define slot validation rules

Slot validation lets you create validation rules for your slot values. Alexa can then check the user's response against these rules and prompt the user if the user provides an unacceptable value.

There are several possible rules for the different types of slots. For details about all of the rules and how slot validation works, see Validate Slot Values.

To use the validation prompts in a dialog with the user, return the Dialog.Delegate directive.

To create slot validation rules:

  1. In the left-hand navigation, find the intent and its list of slots, then click the slot name.

    Alternatively, from the page for a particular intent, find the slot in the Intent Slots section below the Sample Utterances and click the Edit Dialog link.

  2. Under slot type field, select Validations.
  3. Under Create Validation Rule, select the rule you want to use and click the plus.
    • The list shows just the validators that are relevant for the slot's type.
    • For details about the rules, see Validation rules.
  4. Fill in any additional fields specific to the rule, such as the value to compare to. This depends on the rule. See Validation rules.
  5. Below the rule, enter at least one prompt that Alexa should say to ask the user for a new value.

    You can include the slot name in curly brackets ({ }) so that Alexa speaks back the value that failed validation.

  6. Be sure to save and build the interaction model.

Set the intent slot order

You can control the order in which Alexa asks for each required slot value. This order is shown in the Intent Slots section of the intent detail page.

  1. In the left-hand navigation, find the intent and its list of slots, then click the slot name.
  2. In the Intent Slots section , note the order of the slots. Drag the slots to change the order.

When you return the Dialog.Delegate directive, Alexa uses the slot order to determine the next step in the dialog.

JSON for the dialog model (Interaction Model Schema)

You can see and edit the JSON representation of your dialog model in the JSON Editor. The interactionModel.dialog.intents property contains an array of objects representing the dialog settings for each intent with a dialog model. The interactionModel.prompts property contains an array of objects representing the provided prompts. Note that the user utterances for a slot are not part of these structures. The utterances are defined as part of the interactionModel.languageModel.intents

This example shows the dialogs and prompts for a PlanMyTrip intent that has several required slots. The fromCity slot also uses slot confirmation, and the intent as a whole uses intent confirmation.

For brevity, the languageModel property is not shown. For details about the interaction model JSON, see Interaction Model Schema.

{
  "interactionModel": {
    "dialog": {
      "intents": [
        {
          "name": "PlanMyTrip",
          "confirmationRequired": true,
          "prompts": {
            "confirmation": "Confirm.Intent.1096343369896"
          },
          "slots": [
            {
              "name": "travelDate",
              "type": "AMAZON.DATE",
              "confirmationRequired": false,
              "elicitationRequired": true,
              "prompts": {
                "elicitation": "Elicit.Slot.924477721275.367201351270"
              },
              "validations": [
                {
                  "type": "isInDuration",
                  "prompt": "Slot.Validation.792776084863.1060909439418.1047786686510",
                  "start": "P1D",
                  "end": ""
                }
              ]
            },
            {
              "name": "toCity",
              "type": "AMAZON.US_CITY",
              "confirmationRequired": false,
              "elicitationRequired": true,
              "prompts": {
                "elicitation": "Elicit.Slot.924477721275.885841590425"
              }
            },
            {
              "name": "fromCity",
              "type": "AMAZON.US_CITY",
              "confirmationRequired": true,
              "elicitationRequired": true,
              "prompts": {
                "confirmation": "Confirm.Slot.186469474087.1029396093044",
                "elicitation": "Elicit.Slot.924477721275.191955839720"
              }
            },
            {
              "name": "travelMode",
              "type": "LIST_OF_TRAVEL_MODES",
              "confirmationRequired": false,
              "elicitationRequired": true,
              "prompts": {
                "elicitation": "Elicit.Slot.924477721275.266137038000"
              }
            },
            {
              "name": "activity",
              "type": "LIST_OF_ACTIVITIES",
              "confirmationRequired": false,
              "elicitationRequired": true,
              "prompts": {
                "elicitation": "Elicit.Slot.924477721275.1297414747229"
              }
            }
          ]
        }
      ]
    },
    "prompts": [
      {
        "id": "Elicit.Slot.924477721275.367201351270",
        "variations": [
          {
            "type": "PlainText",
            "value": "When is this trip?"
          },
          {
            "type": "PlainText",
            "value": "When will you travel?"
          },
          {
            "type": "PlainText",
            "value": "On what date will you travel?"
          }
        ]
      },
      {
        "id": "Elicit.Slot.924477721275.885841590425",
        "variations": [
          {
            "type": "PlainText",
            "value": "Tell me the city you want to travel to."
          },
          {
            "type": "PlainText",
            "value": "What city are you going to?"
          },
          {
            "type": "PlainText",
            "value": "Where are you going?"
          }
        ]
      },
      {
        "id": "Elicit.Slot.924477721275.191955839720",
        "variations": [
          {
            "type": "SSML",
            "value": "<speak><emphasis level='strong'>From where</emphasis> did you want to start your trip</speak>"
          },
          {
            "type": "PlainText",
            "value": "Where are you starting your trip?"
          },
          {
            "type": "PlainText",
            "value": "What city are you leaving from?"
          }
        ]
      },
      {
        "id": "Elicit.Slot.924477721275.266137038000",
        "variations": [
          {
            "type": "PlainText",
            "value": "How are you going to get to {toCity}?"
          }
        ]
      },
      {
        "id": "Elicit.Slot.924477721275.1297414747229",
        "variations": [
          {
            "type": "PlainText",
            "value": "What activities are you planning for this trip?"
          },
          {
            "type": "PlainText",
            "value": "What do you plan to do in {toCity}"
          }
        ]
      },
      {
        "id": "Confirm.Intent.1096343369896",
        "variations": [
          {
            "type": "PlainText",
            "value": "Are you sure you want me to save a trip from {fromCity} to {toCity} on {travelDate}?"
          },
          {
            "type": "PlainText",
            "value": "Please confirm that you want to travel from {fromCity} to {toCity} on {travelDate}"
          },
          {
            "type": "PlainText",
            "value": "I'm saving your trip from {fromCity} to {toCity} on {travelDate}, is that OK?"
          }
        ]
      },
      {
        "id": "Confirm.Slot.186469474087.1029396093044",
        "variations": [
          {
            "type": "PlainText",
            "value": "Please verify that you want to start your trip in {fromCity}"
          },
          {
            "type": "PlainText",
            "value": "I heard you want to leave from {fromCity}, right?"
          },
          {
            "type": "PlainText",
            "value": "You wanted to leave from {fromCity}, right?"
          },
          {
            "type": "PlainText",
            "value": "You said you're leaving from {fromCity}, right?"
          }
        ]
      },
      {
        "id": "Slot.Validation.792776084863.1060909439418.1047786686510",
        "variations": [
          {
            "type": "PlainText",
            "value": "I cannot plan a trip for a date that has past, so please tell me a date in the future"
          },
          {
            "type": "PlainText",
            "value": "Please tell me a date in the future"
          }
        ]
      }
    ]
  }
}