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. 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 the AMAZON.US_CITY slot type, and {date} as the AMAZON.DATE slot type. 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 city of slot type AMAZON.US_CITY.
  • API definition return value – For the GetWeather API return value, you must define a custom slot type. In this example, you might call the custom slot type returnedWeather, and give it properties for city, date, highTemperature, and lowTemperature.
  • 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 the GetWeather 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 choose either a built-in slot type or a custom slot type. Built-in slot types let you use single or list values. Custom slot types let you include values not defined by any built-in slot type.

Built-in slot types

Built-in slot types are predefined and prepopulated with values. Some built-in slot types capture common data, such as dates (AMAZON.DATE). Others handle lists of values, such as major companies (AMAZON.Corporation). You can extend built-in slot types with additional values. You cannot, however, use built-in slot types for API return values. You must instead create a custom slot type with values.

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 a 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

Use a list slot type when a variable captures multiple values. For example, a user might choose several pizza toppings ("I want to order a pizza with pepperoni, green peppers, and olives"). List slot types range in size from catalogs with thousands of values, like AMAZON.Movie, to much smaller catalogs, such as AMAZON.DayOfWeek. List slot types can accept up to five user input values, with 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 construct lists only for built-in slot types. Custom slot types can't accept list values.
  • You can have multiple slot lists within a dialog as long as the slot lists are 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:

  1. In the left pane, expand Assets, click Slot Types, and choose Add Slot Type.
  2. Select Create a custom slot type with properties, and enter a slot name.
  3. Click Add a new property, enter the property name, and select a slot type from the drop-down menu.
  4. Set the LIST toggle for the property.

  5. Set the OPTIONAL toggle for the property.

  6. Repeat steps 3, 4, and 5 for any additional properties.
  7. In the header bar, click 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 (AMAZON.DATE) and time (AMAZON.TIME). If no built-in slot type 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 user input values.

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 you might use a list of AMAZON.FOOD slot types.)


Was this page helpful?

Last updated: Nov 27, 2023