Dialog Interface Reference | Alexa Skills Kit (original) (raw)

Alexa > Documentation > Alexa Skills Kit > Custom Skill Interface Reference > Interfaces >


The Dialog interface provides directives for managing a multi-turn conversation between your skill and the user. You can use the directives to ask the user for the information you need to fulfill their request.

Dialog directive requirements (dialog model)

To use most of the Dialog directives, your skill must include a dialog model. The dialog model is a structure that identifies:

How the dialog model is used when a user interacts with your skill depends on how you choose to manage the conversation.

You can use the developer console to create the create a dialog model. You can also define the dialog model in JSON in your interaction model schema.

Steps of a multi-turn dialog or conversation

In an Alexa skill, a dialog with the user is a conversation with multiple turns in which Alexa asks questions and the user responds with the answers. The conversation is tied to a specific intent representing the user's overall request. The questions and answers are intended to gather, validate, and confirm slot values. The conversation continues until all slots needed for the intent are filled and confirmed according to the rules defined in the dialog model.

The questions Alexa asks during the conversation fall into four categories:

The dialog for a particular intent might include all of these steps or only some of them. For instance, a dialog could include slot elicitation, but not use slot or intent confirmation.

A dialog can also involve multiple intents. The handler for the intent that started the dialog can pass control to a second intent that continues the dialog with a different set of questions.

About managing the conversation with the user

There are three main scenarios for handling a multi-turn conversation with the user in your skill:

  1. Delegate the dialog to Alexa. In this case, Alexa uses the prompts defined in the dialog model.
  2. Control each step of the dialog yourself using Dialog.ElicitSlot, Dialog.ConfirmSlot, and Dialog.ConfirmIntent.
  3. Combine both options. In this case, you delegate the dialog on some turns, but take control on others when necessary.

Delegate the dialog to alexa

This option lets you focus most of your coding efforts on the logic for fulfilling the user's request, rather than writing all the code to ask the user for slot values yourself. You can delegate the dialog automatically, or handle it manually with the Dialog.Delegate directive.

With auto delegation, Alexa completes all the dialog steps based on the dialog model, then sends your skill a single IntentRequest when it is done. With this option, you do not need to use the Dialog directives.

With manual delegation, Alexa sends your skill an IntentRequest for each turn of the conversation. The request includes a dialogState property that indicates whether there may be additional steps in the dialog (STARTED or IN_PROGRESS) or if all the steps are complete (COMPLETED). If the dialog is COMPLETED, this means that the IntentRequest has all the required slot values and confirmations from the user and all slot values are validated according to your defined rules. If the dialog is not yet complete, you return the Dialog.Delegate directive. Alexa determines the next step in the dialog and uses the prompts defined in the dialog model to elicit slot values, confirm slot values, validate slot values, or confirm the entire intent.

You cannot combine the Dialog.Delegate directive with any APL directives or APL requests. To display visuals on a screen during the dialog, control the dialog manually in your skill code.

Once the conversation is complete, the incoming IntentRequest has a dialogState of COMPLETED. All required information is now available in the intent's slot values. Your skill can fulfill the user's request at this point.

Control the dialog in your skill code

In this option, your code checks for slot values and confirmation status, determines the next step in the conversation, and returns the appropriate directives (Dialog.ElicitSlot, Dialog.ConfirmSlot, or Dialog.ConfirmIntent).

You need to determine the status and next steps in your own code. If your skill meets the requirements to use the Dialog directives, the IntentRequest sent to your skill does include dialogState. However, this is set to either STARTED (when the intent is invoked) or IN_PROGRESS. The COMPLETED status is only possible when you use Dialog.Delegate or auto delegation.

Note that the directives do not use the prompts defined in your dialog model in this scenario. For instance, when you return Dialog.ElicitSlot, you must include the prompt in your response. Dialog.ElicitSlot does use the utterances you provide for the slot. Alexa biases the interaction model to listen for the utterances defined for the slot, so it is important to provide good utterances when you define the dialog model.

Also note that Dialog.ElicitSlot does not perform any slot validation. If you want to define slot validation rules and prompt the user when they provide incorrect values, delegate the dialog to Alexa.

When you control the dialog in this way, you can include the Alexa.Presentation.APL.RenderDocument directive alongside the Dialog.ElicitSlot, Dialog.ConfirmSlot, or Dialog.ConfirmIntent directives, so you can display information relevant to the dialog on the screen. You can also return these directives from APL requests, so your overall dialog can incorporate both touch events and voice.

Both delegate and control the dialog manually

You can combine the two main options. Depending on the incoming IntentRequest, your code would take one of these actions:

For an example of this scenario, see Manually delegate to alter the conversation at run-time.

Change the intent or update slot values during the dialog

Each of the Dialog directives includes an updatedIntent property that can take an Intent object. Use this to:

Pass a new intent

When you use updatedIntent to change to a different intent, the directive acts against the new intent instead of the original:

…earlier dialog for the BookFlight intent
Alexa: OK, I've booked your flight. Do you want to also reserve a rental car?
User: Yes (Skill receives an AMAZON.YesIntent.)

Skill returns Dialog.Delegate with updatedIntent set to BookRentalCar.
Alexa: OK, lets book your car. What size car would you like, compact, mid-size, or full-size? (Slot elicitation dialog step for sizeOfCar slot on the BookRentalCar intent.)

When you use updatedIntent like this, note the following:

Set or change data on the original intent

When you use updatedIntent to set or change data on the original intent, make sure that the intent name and full set of slots matches the intent sent to your skill. You can update the Intent object originally sent to your skill with the new slot values or confirmation status values and then just pass it back to the directive. Include all of the slots, including any empty slots you are not changing.

For an example of this scenario, see Manually delegate the dialog to set default values.

Directives

The following table summarizes the Dialog directives. See the sections below for details about each directive.

If your skill does not meet the requirements to use the Dialog directives, returning any of these directives causes an error.

Directive Description
Dialog.Delegate Sends Alexa a command to handle the next turn in the dialog with the user. This directive is a valid return type depending on the combination of dialogState and updatedIntent: When dialogState is either STARTED OR IN_PROGRESS, updatedIntent can be set to either the original intent or a new intent. When dialogState is COMPLETED, you must also set updatedIntent to a different intent. If updatedIntent is not present or is set to the original intent, returning Dialog.Delegate for a COMPLETED dialog causes an error.
Dialog.ElicitSlot Sends Alexa a command to ask the user for the value of a specific slot. Specify the name of the slot to elicit in the slotToElicit property. Provide a prompt to ask the user for the slot value in an OutputSpeech object in the response.
Dialog.ConfirmSlot Sends Alexa a command to confirm the value of a specific slot before continuing with the dialog. Specify the name of the slot to confirm in the slotToConfirm property. Provide a prompt to ask the user for confirmation in an OutputSpeech object in the response. Be sure repeat back the value to confirm in the prompt.
Dialog.ConfirmIntent Sends Alexa a command to confirm the all the information the user has provided for the intent before the skill takes action. Provide a prompt to ask the user for confirmation in an OutputSpeech object in the response. Be sure to repeat back all the values the user needs to confirm in the prompt.
Dialog.UpdateDynamicEntities Adapts your interaction model at runtime. This directive augments your skill's predefined static catalogs by allowing your skill to dynamically create new entities.

Delegate directive

Sends Alexa a command to handle the next turn in the dialog with the user. This directive is a valid return type depending on the combination of dialogState and updatedIntent:

Syntax

{
  "type": "Dialog.Delegate",
  "updatedIntent": {
    "name": "string",
    "confirmationStatus": "NONE",
    "slots": {
      "SlotName": {
        "name": "SlotName",
        "value": "string",
        "resolutions": {},
        "confirmationStatus": "NONE"
      }
    }
  }
}

Note that a Slot object for an intent may or may not include the resolutions property shown in the JSON syntax. This depends on the slot type. The presence or absence of the resolutions property has no effect on any of the Dialog directives.

Parameter Description Type Required
type Set to Dialog.Delegate. string Yes
updatedIntent An intent object. Use this to change intents during the dialog or set slot values and confirmation status. See Change the intent or update slot values during the dialog. If you don't need to change the intent, slot values, or confirmation statuses, you can leave this property out of your response. Returning Dialog.Delegate with a different intent in updatedIntent is equivalent to the user invoking the intent directly. If auto delegate is enabled, your skill receives a single IntentRequest once the dialog for the new intent is complete. If auto delegate is not enabled, your skill receives an IntentRequest for each turn of the dialog. If the new intent uses the same slots as the original, be sure to set any filled slot values on the new intent to prevent Alexa from asking the user for the same values again. object No

Details

Alexa determines the next step in the dialog based on the dialog model. In a dialog for an intent with multiple slots, Alexa elicits, validates values, and confirms (if necessary) each slot in the order defined in the dialog model. Intent confirmation (when configured) happens once all required slots have values.

You can use slot validation with slots that are not required, so you can validate optional values if they are provided, but not force the user to fill those slots. In this case, Dialog.Delegate accepts a blank slot value and does not perform any validation or elicitation on the non-required slot. If the user does provide a value for the slot, Dialog.Delegate uses the validation rules and prompts normally.

When you include OutputSpeech in your response, Alexa speaks the outputSpeech before the prompts defined in the dialog model. This can be a useful way to create a transition when you change intents, although you can use outputSpeech even when not changing intents. Any speech included in the reprompt is ignored. Alexa uses the prompts in the dialog model to re-prompt during the dialog.

Delegate and Alexa Presentation Language

Example interaction

An intent for planning a trip (PlanMyTrip) could have an interaction like the following:

User: Alexa, tell Plan My Trip I want to visit Portland.

Alexa sends the skill a PlanMyTrip intent with:

dialogState: STARTED
fromCity: null
toCity: Portland
travelDate: null
travelMode: null
activity: null
confirmationStatus: NONE

The skill returns a Dialog.Delegate directive with: updatedIntent.slots.fromCity: Seattle and the other slots unchanged (this defaults the fromCity to a value)
Alexa: You wanted to fly out of Seattle, right? (Confirmation prompt for the fromCity slot, as defined in the dialog model.)
User: Yes.

Alexa sends the PlanMyTrip intent with:

dialogState: IN_PROGRESS
fromCity: Seattle (now with confirmationStatus: CONFIRMED)
toCity: Portland
travelDate: null
travelMode: null
activity: null
confirmationStatus: NONE

Skill returns a Dialog.Delegate directive.
Alexa: When did you want to travel? (This elicitation prompt for travelDate comes from the dialog model.)
User: On Friday

Alexa sends the PlanMyTrip intent with:

dialogState: IN_PROGRESS
fromCity: Seattle (confirmationStatus: CONFIRMED)
toCity: Portland
travelDate: 2017-04-21
travelMode: null
activity: null
confirmationStatus: NONE

Skill returns a Dialog.Delegate directive. (in this example, the travelMode and activity slots are not required, so Alexa does not prompt for them.)

Alexa: I'm saving your trip from Seattle to Portland on April 21st. Is that OK? (Intent confirmation prompt from the dialog model.)
User: Yes.

Alexa sends the PlanMyTrip intent with:

dialogState: COMPLETED
fromCity: Seattle (confirmationStatus: CONFIRMED)
toCity: Portland
travelDate: 2017-04-21
travelMode: null
activity: null
confirmationStatus: CONFIRMED

Skill now has all needed information and can handle the PlanMyTrip intent. Since the dialogState is COMPLETED, the skill can return Dialog.Delegate again only if it also passes a new intent in updatedIntent.

If the user denied the confirmation in the final turn, the dialog would still be considered COMPLETE, but the intent.confirmationStatus would be DENIED:

…earlier interaction to invoke PlanMyTrip and set the fromCity, toCity, and travelDate slots.
Alexa: I'm saving your trip from Seattle to Portland on April 21st. Is that OK? (Intent confirmation prompt from the dialog model.)
User: No.

Alexa sends the PlanMyTrip intent with:

dialogState: COMPLETED
fromCity: Seattle (confirmationStatus: CONFIRMED)
toCity: Portland
travelDate: 2017-04-21
travelMode: null
activity: null
confirmationStatus: DENIED

The dialog is considered complete since all information was gathered. Since the dialogState is COMPLETED, the skill can no longer return the Dialog.Delegate directive.

(Back up to Dialog Directives)

ElicitSlot directive

Sends Alexa a command to ask the user for the value of a specific slot. Specify the name of the slot to elicit in the slotToElicit property. Provide a prompt to ask the user for the slot value in an OutputSpeech object in the response.

If your skill does not meet the requirements to use the Dialog directives, returning Dialog.ElicitSlot causes an error.

Syntax

{
  "type": "Dialog.ElicitSlot",
  "slotToElicit": "string",
  "updatedIntent": {
    "name": "string",
    "confirmationStatus": "NONE",
    "slots": {
      "SlotName": {
        "name": "SlotName",
        "value": "string",
        "resolutions": {},
        "confirmationStatus": "NONE"
      }
    }
  }
}

Note that a Slot object for an intent may or may not include the resolutions property shown in the JSON syntax. This depends on the slot type. The presence or absence of the resolutions property has no effect on any of the Dialog directives.

This example illustrates returning Dialog.ElicitSlot to ask for the fromCity slot value. Note that the OutputSpeech object is used for the prompt.

{
  "version": "1.0",
  "sessionAttributes": {},
  "response": {
    "outputSpeech": {
      "type": "PlainText",
      "text": "From where did you want to start your trip?"
    },
    "shouldEndSession": false,
    "directives": [
      {
        "type": "Dialog.ElicitSlot",
        "slotToElicit": "fromCity",
        "updatedIntent": {
          "name": "PlanMyTrip",
          "confirmationStatus": "NONE",
          "slots": {
            "toCity": {
              "name": "toCity",
              "confirmationStatus": "NONE"
            },
            "travelDate": {
              "name": "travelDate",
              "confirmationStatus": "NONE",
              "value": "2017-04-21"
            },
            "fromCity": {
              "name": "fromCity",
              "confirmationStatus": "NONE"
            },
            "activity": {
              "name": "activity",
              "confirmationStatus": "NONE"
            },
            "travelMode": {
              "name": "travelMode",
              "confirmationStatus": "NONE"
            }
          }
        }
      }
    ]
  }
}
Parameter Description Type Required
type Set to Dialog.ElicitSlot. string Yes
slotToElicit The name of the slot to elicit. string Yes
updatedIntent An intent object. Use this to change intents during the dialog or set slot values and confirmation status. See Change the intent or update slot values during the dialog. If you don't need to change the intent, slot values, or confirmation statuses, you can leave this property out of your response. When you switch intents with this parameter, Alexa attempts to elicit the specified slot value on the new intent. The next IntentRequest to your skill will be the new intent, not the original. object No

Details

You must include the prompt to ask the user for the slot value in the OutputSpeech object. The directive does not use the prompts defined in the dialog model.

Dialog.ElicitSlot uses the user utterances you provide for the slot in your dialog model. Alexa biases the interaction model to listen for the utterances defined for the slot, so it is important to provide good utterances when you define the dialog model.

ElicitSlot and Alexa Presentation Language

Example interaction

An intent for planning a trip (PlanMyTrip) could have an interaction like the following:

User: Alexa, tell Plan My Trip I want to go on a trip.

Alexa sends the skill a PlanMyTrip intent with no slot values:

fromCity: null
toCity: null
travelDate: null
travelMode: null
activity: null

Skill sends a Dialog.ElicitSlot directive with slotToElicit set to fromCity.
Alexa: From where did you want to start your trip? (This elicitation prompt comes from the outputSpeech included in the response.)
User: Seattle.

Alexa sends the PlanMyTrip intent with:

fromCity: Seattle
toCity: null
travelDate: null
travelMode: null
activity: null

Skill sends a Dialog.ElicitSlot directive with slotToElicit set to toCity.
Alexa: Where are you traveling to?
User: Portland.

Alexa sends the PlanMyTrip intent with:

fromCity: Seattle
toCity: Portland
travelDate: null
travelMode: null
activity: null

(Dialog continues as the skill sends ElicitSlot directives to collect remaining slots for the intent.)

(Back up to Dialog Directives)

ConfirmSlot directive

Sends Alexa a command to confirm the value of a specific slot before continuing with the dialog. Specify the name of the slot to confirm in the slotToConfirm property. Provide a prompt to ask the user for confirmation in an OutputSpeech object in the response. Be sure repeat back the value to confirm in the prompt.

If your skill does not meet the requirements to use the Dialog directives, returning Dialog.ConfirmSlot causes an error.

Syntax

{
  "type": "Dialog.ConfirmSlot",
  "slotToConfirm": "string",
  "updatedIntent": {
    "name": "string",
    "confirmationStatus": "NONE",
    "slots": {
      "string": {
        "name": "string",
        "value": "string",
        "resolutions": {},       
        "confirmationStatus": "NONE"
      }
    }
  }
}

Note that a Slot object for an intent may or may not include the resolutions property shown in the JSON syntax. This depends on the slot type. The presence or absence of the resolutions property has no effect on any of the Dialog directives.

This example illustrates returning Dialog.ConfirmSlot to confirm the fromCity slot value. Note that the OutputSpeech object is used for the prompt.

{
  "version": "1.0",
  "sessionAttributes": {},
  "response": {
    "outputSpeech": {
      "type": "PlainText",
      "text": "You said you're leaving Seattle, right?"
    },
    "shouldEndSession": false,
    "directives": [
      {
        "type": "Dialog.ConfirmSlot",
        "slotToConfirm": "fromCity",
        "updatedIntent": {
          "name": "PlanMyTrip",
          "confirmationStatus": "NONE",
          "slots": {
            "toCity": {
              "name": "toCity",
              "confirmationStatus": "NONE"
            },
            "travelDate": {
              "name": "travelDate",
              "confirmationStatus": "NONE",
              "value": "2017-04-21"
            },
            "fromCity": {
              "name": "fromCity",
              "value": "Seattle",
              "confirmationStatus": "NONE"
            },
            "activity": {
              "name": "activity",
              "confirmationStatus": "NONE"
            },
            "travelMode": {
              "name": "travelMode",
              "confirmationStatus": "NONE"
            }
          }
        }
      }
    ]
  }
}
Parameter Description Type Required
type Set to Dialog.ConfirmSlot. string Yes
slotToConfirm The name of the slot to confirm. string Yes
updatedIntent An intent object. Use this to change intents during the dialog or set slot values and confirmation status. See Change the intent or update slot values during the dialog. If you don't need to change the intent, slot values, or confirmation statuses, you can leave this property out of your response. When you switch intents with this parameter, Alexa attempts to confirm the specified slot value on the new intent. Be sure the intent object you pass to updatedIntent has a value in the slot you want to confirm. The next IntentRequest to your skill will be the new intent, not the original. string No

Details

When you return Dialog.ConfirmSlot, include the prompt to ask the user for confirmation in the OutputSpeech object. The directive does not use the prompts defined in the dialog model.

After Alexa speaks your prompt from the OutputSpeech, the user can respond with "yes" or "no." Alexa then sends your skill the intent with an updated confirmationStatus property on the specific slot to indicate the user's response (CONFIRMED or DENIED).

The user can deny the confirmation twice, after which the session ends.

ConfirmSlot and Alexa Presentation Language

Example interactions

An intent for planning a trip (PlanMyTrip) could have an interaction like the following:

User: Alexa, tell Plan My Trip to plan a trip from Seattle

Alexa sends the skill a PlanMyTrip intent with:

fromCity: Seattle (confirmationStatus is NONE since the user has not confirmed this value)
toCity: null
travelDate: null
travelMode: null
activity: null

Skill sends a Dialog.ConfirmSlot directive with slotToConfirm set to fromCity.
Alexa: You said you're leaving from Seattle, right? This confirmation prompt comes from the outputSpeech included in the response.
User: Yes. (The user's "Yes" response does not send a normal AMAZON.YesIntent, but instead sends the PlanMyTrip intent with the fromCity slot set to "Seattle" and fromCity.confirmationStatus set to CONFIRMED.)

(Back up to Dialog Directives)

ConfirmIntent directive

Sends Alexa a command to confirm the all the information the user has provided for the intent before the skill takes action. Provide a prompt to ask the user for confirmation in an OutputSpeech object in the response. Be sure to repeat back all the values the user needs to confirm in the prompt.

If your skill does not meet the requirements to use the Dialog directives, returning Dialog.ConfirmIntent causes an error.

Syntax

{
  "type": "Dialog.ConfirmIntent",
  "updatedIntent": {
    "name": "string",
    "confirmationStatus": "NONE",
    "slots": {
      "string": {
        "name": "string",
        "value": "string",
        "resolutions": {},               
        "confirmationStatus": "NONE"
      }
    }
  }
}

Note that a Slot object for an intent may or may not include the resolutions property shown in the JSON syntax. This depends on the slot type. The presence or absence of the resolutions property has no effect on any of the Dialog directives.

This example illustrates returning Dialog.ConfirmIntent to confirm entire intent. Note that the OutputSpeech object is used for the prompt. In this example, the three required slots (toCity, fromCity, and travelDate) also used confirmation and were confirmed on previous turns of the dialog. The other two slots (activity and travelMode) have been filled, but did not need any confirmation.

{
  "version": "1.0",
  "sessionAttributes": {},
  "response": {
    "outputSpeech": {
      "type": "PlainText",
      "text": "I'm saving your trip from Seattle to Portland on April 21st. Is that OK?"
    },
    "shouldEndSession": false,
    "directives": [
      {
        "type": "Dialog.ConfirmIntent",
        "updatedIntent": {
          "name": "PlanMyTrip",
          "confirmationStatus": "NONE",
          "slots": {
            "toCity": {
              "name": "toCity",
              "value": "Portland",
              "confirmationStatus": "CONFIRMED"
            },
            "travelDate": {
              "name": "travelDate",
              "confirmationStatus": "CONFIRMED",
              "value": "2017-04-21"
            },
            "fromCity": {
              "name": "fromCity",
              "value": "Seattle",
              "confirmationStatus": "CONFIRMED"
            },
            "activity": {
              "name": "activity",
              "value": "hiking"
              "confirmationStatus": "NONE"
            },
            "travelMode": {
              "name": "travelMode",
              "value": "driving"
              "confirmationStatus": "NONE"
            }
          }
        }
      }
    ]
  }
}
Parameter Description Type Required
type Set to Dialog.ConfirmIntent. string yes
updatedIntent An intent object. Use this to change intents during the dialog or set slot values and confirmation status. See Change the intent or update slot values during the dialog. If you don't need to change the intent, slot values, or confirmation statuses, you can leave this property out of your response. When you switch intents with this parameter, Alexa attempts to confirm the new intent. Be sure to set any relevant slot values on the intent before you return the directive. The next IntentRequest to your skill will be the new intent with the confirmationStatus based on the user's response, not the original. object No

Details

Use this directive after your skill has gathered all the required slots you need to fulfill an intent, but you want to give the user one more opportunity to confirm that it is correct before continuing. This is common for skills that order products or make reservations.

When you return Dialog.ConfirmIntent, include the prompt to ask the user for confirmation in the OutputSpeech object. The directive does not use the prompts defined in the dialog model.

After Alexa asks the user to confirm the information, the user can respond with "yes" or "no." Alexa then sends your skill the intent with an updated intent.confirmationStatus property to indicate the user's response (CONFIRMED or DENIED).

ConfirmIntent and Alexa Presentation Language

Example interaction

An intent for planning a trip (PlanMyTrip) could have an interaction like the following:

…Previous interactions already collected the required fromCity, toCity, and travelDate slots. Alexa sends the skill a PlanMyTrip intent with all the slots filled in, but the overall intent confirmationStatus set to NONE.
Skill sends a Dialog.ConfirmIntent.
Alexa: I'm saving your trip from Seattle to Portland on April 21st. Is that OK? (This confirmation prompt comes from the outputSpeech included in the response.)
User: Yes. (The user's 'Yes' response does not send a normal AMAZON.YesIntent, but instead sends the PlanMyTrip intent with all slots filled in and a confirmationStatus set to CONFIRMED.)

(Back up to Dialog Directives)

UpdateDynamicEntities directive

Adapts your interaction model at runtime. This directive augments your skill's predefined static catalogs by allowing your skill to dynamically create new entities.

For details, see Use Dynamic Entities for Customized Interactions.

Service Interface Reference (JSON)

Request Format and Standard Request Types:

Interfaces:


Was this page helpful?

Last updated: Nov 28, 2023