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.

Get Started

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 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.DATE and "Seattle" as slot type AMAZON.US_CITY. Both are built-in slot types.
  • API definition input arguments – A GetWeather API might have two input arguments: date of slot type AMAZON.DATE and cityName of slot type AMAZON.US_CITY.
  • API definition return value – For the GetWeather API return value, you might define a custom slot type called returnedWeather that contains properties cityName, date, highTemperature, and lowTemperature.
  • Response arguments – When you define how Alexa responds to the user, you specify returnedWeather as 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.

Choice Description Example

Built-in versus custom slot type

You can use built-in slot types for common data types such as the date (AMAZON.DATE) and time (AMAZON.TIME). If there isn't a built-in slot type that represents what you need, you can create a custom slot type.

Built-in slot types:
User: What's the weather in Seattle tomorrow? (For "Seattle," you can use built-in slot type AMAZON.US_CITY.)

Custom slot types:
User: Add mushrooms to my pizza. (For "mushrooms," you might create a slot type called Topping.)

Single versus list slot types

Alexa Conversations supports list slot types, with up to five items in the list.

Single slot types:
User: What's the weather tomorrow? ("Tomorrow" only needs a single slot type.)

List slot types:
User: I want to order a pizza with pepperoni, green peppers, and olives. (A user might want more than one item on a pizza, so use a list of AMAZON.FOOD 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.

Tip

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

  1. Log in to the developer console, and then navigate to your Alexa Conversations skill.
  2. In the left pane, expand Assets, and then click Slot Types.
  3. Click Add Slot Type.
  4. Select Create a custom slot type with properties, enter a slot name, and then click Next.
  5. Click Add a new property, enter the property name, and then select a slot type.
  6. Repeat the previous step for any additional properties.
  7. 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_CITY slot type and an AMAZON.US_STATE slot type.
  • 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.