Use Slot Types in Alexa Conversations
In Alexa Conversations, all variables that pass between user utterances, Alexa responses, and APIs must have a slot type. As with intent-based interaction models, slot types define how Alexa recognizes and passes data between components.
To get started with Alexa Conversations, you can step through a pet match skill-building tutorial, download the code for a pizza-ordering reference skill, or use an Alexa-hosted sample skill template that includes an Alexa Conversations skill configuration and back-end skill code.
- Decide which slot type to use
- Built-in slot types
- Create a custom slot type
- Single slot types
- List slot types
- Related topics
When you annotate a dialog in the developer console, you assign slot types to the variables in the user utterances and utterances, responses, and API definitions. For example, a weather skill might have the following exchange between the user and Alexa:
User: What's the weather in Seattle tomorrow?
Alexa: Tomorrow in Seattle, you can expect a high of 71 degrees and a low of 57 degrees.
When you annotate the dialog, you might use the following slot types:
- User utterances and utterance set – In the user utterance "What's the weather tomorrow in Seattle?" you label "tomorrow" as slot type
AMAZON.DATEand "Seattle" as slot type
AMAZON.US_CITY. Both are built-in slot types.
- API definition input arguments – A
GetWeatherAPI might have two input arguments:
dateof slot type
cityNameof slot type
- API definition return value – For the
GetWeatherAPI return value, you might define a custom slot type called
returnedWeatherthat contains properties
- Response arguments – When you define how Alexa responds to the user, you specify
returnedWeatheras the argument passed to the response.
Decide which slot type to use
After you identify the need for a variable or argument, you need to consider various factors when you decide which slot type to use. The following table summarizes the choices that you make.
Built-in versus custom slot type
You can use built-in slot types for common data types such as the date (
Built-in slot types:
Custom slot types:
Single versus list slot types
Alexa Conversations supports list slot types, with up to five items in the list.
Single slot types:
List slot types:
Built-in slot types
Built-in slot types are slot types that Alexa already supports. You can use built-in slot types for common data types such as the date (
AMAZON.DATE) and time (
AMAZON.TIME). For a list of built-in slot types, see Slot Type Reference.
Alexa Conversations supports Alexa entities for
en-US. An Alexa entity represents a real-world person, place, or thing. Built-in slot types that support entity resolution disambiguate user utterances into specific, known entities. For details, see Alexa Entity Reference.
Create a custom slot type
If there isn't a built-in slot type that meets your needs, you can create a custom slot type. Custom slot types can have properties.
You can create a custom slot type with properties by using the developer console as follows.
To create a slot type that accepts a string for API definitions and responses, create a Custom Slot Type with Values but do not provide any values. (This doesn't work with utterance sets.)
To create a custom slot type with properties
- Log in to the developer console, and then navigate to your Alexa Conversations skill.
- In the left pane, expand Assets, and then click Slot Types.
- Click Add Slot Type.
- Select Create a custom slot type with properties, enter a slot name, and then click Next.
- Click Add a new property, enter the property name, and then select a slot type.
- Repeat the previous step for any additional properties.
- In the header bar, click Save.
Single slot types
If a user request includes a variable that is only going to have one value at a time, you just need a single slot type. For example, if Alexa asks "What size pizza do you want?" you expect the user to respond with one size, not a list of sizes.
List slot types
Alexa Conversations supports list slot types, with up to five items in the list. You can use list slot types for user requests such as, "I want to order a pizza with pepperoni, green peppers, and olives." List slot types have the following restrictions:
- The items in the list must be of the same slot type. For example, a list can't include both an
AMAZON.US_CITYslot type and an
- You can only construct lists for built-in slot types. Custom slot types (such as slot types returned from APIs) can't be in lists.
- You can have multiple slot lists within a dialog as long as the slot lists are in separate turns.