Use Slot Types in Alexa Conversations
• GA:
en-US
, en-AU
, en-CA
, en-IN
, en-GB
, de-DE
, ja-JP
, es-ES
, es-US
• Beta:
it-IT
, fr-CA
, fr-FR
, pt-BR
, es-MX
, ar-SA
, hi-IN
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.
Overview
When you annotate a dialog in the developer console, you assign slot types to the variables in user utterances, responses, and API definitions. Let's look at the following example from a weather skill.
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.
- User utterances – You write the user utterance "What's the weather in Seattle tomorrow?" as
What's the weather in {city} {date}?
In the utterance set, you might label{city}
as theAMAZON.US_CITY
slot type, and{date}
as theAMAZON.DATE
slot type. Both are built-in slot types. - API definition input arguments – A
GetWeather
API might have two input arguments:date
of slot typeAMAZON.DATE
andcity
of slot typeAMAZON.US_CITY
. - API definition return values – For the
GetWeather
API return value, you must define a custom slot type. In this example, you might call the custom slot typereturnedWeather
and give it properties forcity
,date
,highTemperature
, andlowTemperature
. - Response arguments – When you define how Alexa responds to the user, you must create a type that you can specifically use to pass the weather result to the audio response of a successful call to the
GetWeather
API. In the APLA and APL documents for the response, the payload is based on that type. Continuing theGetWeather
example, the APLA document would include the following text.
${payload.returnedWeather.date} in ${payload.returnedWeather.city}, you can expect a high of ${payload.returnedWeather.highTemperature} degrees and a low of ${payload.returnedWeather.lowTemperature} degrees.
For more examples, see Step 2: Create custom slot types in Tutorial: Annotate a Dialog for Alexa Conversations.
Decide which slot type to use
After you identify the need for a variable or argument, you must decide which slot type to use. Slot types determine how data is recognized and handled.
Built-in slot types
AMAZON.SearchQuery
.Built-in slot types are slot types that Alexa already supports. Some built-in slot types capture common data types, such as dates (AMAZON.DATE
). Others handle lists of values, such as the names of major companies (AMAZON.Corporation
).
Built-in slot types that support entity resolution disambiguate user utterances into specific, known entities. An Alexa entity represents a real-world person, place, or thing. Alexa Conversations supports Alexa entities for en-US
.
Single slot types
Use a single slot type when the variable holds only one value at a time. For example, Alexa might ask, "What size pizza would you like?" The user would 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. For example, a user might choose several pizza toppings ("I want to order a pizza with pepperoni, green peppers, and olives"). The following restrictions apply to list slot types:
- The items in the list must be of the same slot type. For example, a list can't include both an
AMAZON.US_CITY
slot type and anAMAZON.US_STATE
slot type. - You can construct lists only for built-in slot types. Custom slot types (such as slot types returned from APIs) can't accept list values.
- You can have multiple slot lists within a dialog as long as they're in separate turns.
Custom slot types with properties
If no built-in slot type meets your needs, consider adding a custom slot type. In the intent definition, specify the name of the slot type and supply a list of representative values. Keep in mind that this list is not an enumeration or array of acceptable responses. The list values serve as training data for Alexa's natural language processing (NLP) system. NLP helps Alexa recognize and respond appropriately to words and phrases that are not included in your list of representative values.
Adding properties to your custom slot types can make them even more useful. For example, you could add properties like price
, amount
, or vegan
to the toppings
slot type in a pizza-ordering skill. To create a custom slot type with properties, log in to the developer console. Navigate to your Alexa Conversations skill, and follow these steps:
- In the left pane, expand Assets, click Slot Types, and choose Add Slot Type.
- Select Create a custom slot type with properties, and enter a slot name.
- Click Add a new property, enter the property name, and select a slot type from the drop-down menu.
-
Set the
LIST
toggle for the property.Tip: By default, theLIST
toggle switch isoff
(false
). If the slot type accepts a list of values, move the switch to theon
(true
) position. - Repeat steps 3 and 4 for any additional properties.
- In the header bar, choose Save.
Summary
The following table summarizes the differences between built-in and custom slot types. It also compares single slot types with list slot types.
Choice | Description | Example |
---|---|---|
Built-in versus custom slot type |
Built-in slot types handle common data types, such as the date ( |
Built-in slot types: Custom slot types: |
Single versus list slot type |
Alexa Conversations supports list slot types with up to five user input values. |
Single slot types: List slot types: |
Related topics
- Tips for Using Built-in Slots for Your Skill
- Best Practices for Sample Utterances and Custom Slot Type Values
- Create and Edit Custom Slot Types
Last updated: Nov 27, 2023