Grato por sua visita. Neste momento esta página está apenas disponível em inglês.

Define the Dialog to Collect and Confirm Required Information

A dialog model identifies the prompts and user utterances to collect, validate, and confirm slot values and intents. You use a dialog model to let Alexa determine the next step in a conversation and ask the user for more information. A dialog model also improves accuracy when you manage the dialog manually with the Dialog directives such as Dialog.ElicitSlot.

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.

The dialog model also includes flags indicating whether to automatically delegate the dialog to Alexa. This lets Alexa use these prompts to collect all the required information from the user before sending your skill the request.

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.

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 required slot values. To use these prompts and utterances to collect the slot values from the user, delegate the dialog to Alexa.

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 around writing prompts, see Voice.
  • 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, delegate the dialog to Alexa.

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, delegate the dialog to Alexa.

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 rules and prompts in a dialog with the user, delegate the dialog to Alexa.

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.

Enable or disable auto delegation for the skill and intents

For more about how delegation works and examples, see Delegate the dialog to Alexa

Every skill has a skill-level Auto Delegation setting. This option can be either enabled or disabled. Auto Delegation is enabled by default for a new skill.

Each intent that has a dialog model has an Dialog Delegation Strategy setting. This can be set to one of three options:

  • enable auto delegation: use auto delegation for this intent, regardless of the overall skill delegation strategy.
  • disable auto delegation: do not use auto delegation for this intent, regardless of the overall delegation strategy.
  • fallback to skill strategy: use the Auto Delegation setting for the overall skill. This is the default for an intent when you initially add a dialog model to the intent.

The Dialog Delegation Strategy setting for an intent always takes precedence over the skill-level Auto Delegation setting. For example, if Auto Delegation is enabled for the skill, but the Dialog Delegation Strategy is disabled for a particular intent, delegation is not used for that intent.

Set the overall auto delegation option for the skill

Set the skill-level Auto Delegation option to the setting you plan to use for the majority of your intents, then override it at the intent level where necessary.

  1. In the developer console, navigate to Build > Custom > Interfaces.
  2. Enable or disable the Auto Delegation option, then click Save Interfaces. Be sure to click Build Model to re-build your interaction model.

You can also set the auto delegation option in the JSON for your interaction model.

The skill-level Auto Delegation setting is ignored for intents that do not have a dialog model.

Override the skill auto delegation strategy for an intent

The Dialog Delegation Strategy option is disabled for intents that do not have a dialog model.

  1. Click an intent from the left-hand navigation to open the detail page for the intent.
  2. Under Dialog Delegation Strategy, select the strategy you want to use for this intent.

You can also set the auto delegation option for an intent in the JSON for your 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 delegate the dialog to Alexa, 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": {
      "delegationStrategy": "SKILL_RESPONSE",      
      "intents": [
        {
          "name": "PlanMyTrip",
          "delegationStrategy": "ALWAYS",          
          "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"
          }
        ]
      }
    ]
  }
}