Vielen Dank für deinen Besuch. Diese Seite ist nur in Englisch verfügbar.

Create and Edit Custom Slot Types

This document describes how you create custom slot types and how you extend built-in slot types.

Overview of Custom Slot Types

A custom slot type defines a list of representative values for the slot. Custom slot types are used for lists of items that are not covered by Amazon's built-in set of types. When using a custom type, you define the type and its values, and specify the name of the type as part of the intent definition.

In the PlanMyTrip intent example, you might define a custom slot type of travel activities to use with the activity slot type. The type could be named LIST_OF_ACTIVITIES and have these values:

bicycling
bike
biking
camp
camping
hike
hiking
race
run
shop
shopping
ski
skiing
surf
surfing
swim
swimming

This would support utterances such as "I'm visiting Portland to go hiking," and "I'm visiting Portland to hike."

The set of custom values can be anything supported by your skill's handling of the slot as long as it can be spoken by a user, although words not found in a typical dictionary for the skill's language may not be recognized.

Slot values are sent to your skill in written format. For example, both "fire h. d. 7" and "fire h. d. seven" would be sent to your skill as "Fire HD7". For better recognition, acronyms and other phrases involving spoken letters should either be all caps ("HD") or separated by periods and a space ("h. d. "). Using lowercase for initialisms may lead to unreliable recognition since the spoken form may not correctly be detected. See examples.

Note that a custom slot type is not the equivalent of an enumeration. Values outside the list are still returned if recognized by the spoken language understanding system. Although input to a custom slot type is weighted towards the values in the list, it is not constrained to just the items on the list. You can either perform validation and error checking in your own code, or define slot validation rules and use Dialog.Delegate to prompt the user for acceptable values.

For recommendations for custom slot type values, see Recommendations for Custom Slot Type Values.

The same custom slot type can be used for multiple slots in the same skill.

View Slot Types Used in Your Skill

The Slot Types section in the left-hand navigation displays all of the slot types you've added to your skill. This includes:

To change a slot type name or update its values, select the slot type in the left-hand navigation to open the slot detail page. The Slots using… section shows all of the slots and intents currently using that type.

Add or Edit a Custom Slot Type

Slot type names: The name of a custom slot type can contain alphabetic characters and the underscore ("_") only. The dot character (.) is allowed only for built-in types (such as AMAZON.US_CITY).

To add a new custom slot type:

  1. From the left-hand navigation, click Add next to Slot Types.
  2. Select the Create custom slot type option.
  3. Enter a name for the slot type and click Create custom slot type.
  4. Enter each value and click the plus or press Enter. For recommendations for slot type values, see Custom Slot Type Values.
  5. You can add slot value IDs and synonyms to a slot value after you save the value:
    • Click in the ID column for a value to edit its ID.
    • Click in the Synonyms column for a value to enter a synonym, then click the plus or press Enter to save it.

    For more about using IDs and synonyms for a slot type value, see Define Synonyms and IDs for Slot Type Values (Entity Resolution).

  6. Be sure to save your work as you make changes.

To edit slot type values:

  1. Click the name of the slot type under Slot Types to open the detail page for the slot type.
  2. Enter each value and click the plus or press Enter. For recommendations for slot type values, see Custom Slot Type Values.
  3. Click in the ID column for a value to edit its ID.
  4. Click in the Synonyms column for a value to enter a synonym, then click the plus or press Enter to save it.
  5. Be sure to save your work as you make changes.

To change the name of a custom slot type:

  1. From the left-hand navigation, click Add next to Slot Types.
  2. Click into the field for the slot type name. Edit the name and click Save Model.

Synonyms and Unique Identifiers for Slot Type Values

Each value in a custom slot type can have a unique identifier and a set synonyms. This lets you tie multiple possible utterances together and get a common ID and value in the IntentRequest, regardless of which value the user says. For example, for a MEDIA_TYPE slot intended to collect a particular type of media, a user might say "song", "track", or "single". All three of these utterances can be tied to the single slot value "song" with the unique identifier SONG.

For more about how synonyms and IDs work, see Define Synonyms and IDs for Slot Type Values (Entity Resolution).

Extend a Built-in Slot Type with Additional Values

You can add your own custom values to a subset of the built-in list slot types. This appends the values you provide to the built-in values defined by Amazon. For example, AMAZON.US_CITY provides recognition for cities commonly used by speakers in the United States. If you need to collect additional cities – such as smaller towns that might not be included – you could add them to the list by extending the type. The slot would then recognize both the original set of values as well as the custom ones you added.

You can also define synonyms and identifiers for values you add to a built-in slot type. For details, see Entity Resolution for Built-in Slot Types.

Extending a built-in slot type only applies to the specific skill. For instance, if you extend AMAZON.US_CITY with additional cities for one skill, those changes do not apply to any other skills that also use AMAZON.US_CITY.

Before you can extend a built-in type, you need to add it to your skill. In the left-hand navigation, note the types under Slot Types. If the slot type to extend is not included, add it to your skill:

  1. From the left-hand navigation, click Add next to Slot Types.
  2. Select the Use an existing slot type from Alexa's built-in library option.
  3. Find the built-in slot type you want to add. You can filter the slot types by name.
  4. Click Add Slot Type for each built-in type to add.
  5. Be sure to save your work as you make changes.

To extend a built-in slot type, add values to it just as you would a custom type. In the left-hand navigation, under Slot Types, select the slot type to edit. Enter each value and click the plus or press Enter.

Custom Slot Type Values

The slot values provided in requests to your service are provided in standard written form.

For example, the following table illustrates some example slot type values and how they are converted to written form when provided to your service. In this table, the Slot Value is the value you would provide in your list of custom slot values. The Spoken Form represents what the user says, and the Slot Value Output is the data sent to your service in the request.

Slot Value Spoken Form Slot Value Output
DJ d. j. DJ
PJ Harvey p. j. harvey PJ Harvey
two beers two beers 2 beers
four inch four inch 4"
4 inch four inch 4"
four star four star 4 star
4-star four star 4 star
all-in-one all in one all in 1
first amendment first amendment 1st amendment
John's john's John's
Ford Motor co. ford motor company ford motor company
Cambridge Univ. cambridge univ Cambridge univ
Seattle, Washington seattle washington Seattle Washington
R&B r. and b. R&B
r. and b. r. and b. R&B
amazon.com amazon dot com amazon dot com
joe@example.com joe at example dot com joe at example dot com
Fire HD fire h. d. fire HD
Fire h. d. fire h. d. fire HD
Fire HD7 fire h. d. seven fire HD7
Fire HD 7 fire h. d. seven fire HD7

Note that acronyms and initialisms are indicated using all caps. Alternatively, use lowercase letters separated by spaces and periods. Using lowercase without periods (such as "fire hd") may lead to unreliable recognition since the spoken form may not be correctly detected.

In all other cases, capitalization does not matter – you can use uppercase or lowercase. Numbers may be either spelled out or numeric (e.g. "seven" or "7").

Note that Umlauts (ä, ü, ö) and sharp S (ß) must not be spelled differently. For example, use "büro" not "buero", and "fußball" not "fussball", to prevent unreliable recognition. In some cases these different spellings might even change the meaning of words, for example "masse" vs. "maße".

Edit or Upload Slot Type Values in Bulk

You can use bulk edit to quickly enter or edit slot type values. This can be useful for copying and pasting values from other files.

When editing in bulk edit or importing values, each row becomes a separate slot value. You can use a comma-separated values format to provide identifiers and synonyms:

Slot value,identifier,synonym,synonym,...

You can provide any number of synonyms for a given slot value.

For example, this file would import two slot values: "driving", with the ID DRIVE and four synonyms, and "flying" with the ID FLY and two synonyms:

driving,DRIVE,auto,automobile,taking a road trip,road trip
flying,FLY,fly,airplane

To bulk edit or import sample values:

  1. Click the name of the slot type under Slot Types to open the detail page for the slot type.
  2. In the upper-right, above the Slot Values section, click Bulk Edit.
  3. Either edit the values in the edit box, or drag a CSV file to the window to import the contents.

    • Enter one slot value per line.
    • Importing a CSV file replaces the existing slot values shown in the edit box.
    • Select The CSV below contains headers to omit the top line shown in the text field.
    • Your changes to the values are not saved until you click Submit.
  4. Click Submit.

JSON for Slot Types (Interaction Model Schema)

You can see and edit the JSON representation of all of your slot types in the JSON Editor. The interactionModel.languageModel.types property contains an array of slot type objects. Each custom slot type and each extended built-in type is represented in this array.

This example shows the types property for a custom type (LIST_OF_TRAVEL_MODES) and a built-in type that has been extended (AMAZON.US_CITY). For brevity, other properties within interactionModel and languageModel are not shown. For details about the interaction model JSON, see Interaction Model Schema.

{
  "interactionModel": {
    "languageModel": {
      "types": [
        {
          "name": "LIST_OF_TRAVEL_MODES",
          "values": [
            {
              "id": "TRAIN",
              "name": {
                "value": "taking the train",
                "synonyms": [
                  "train",
                  "train ride"
                ]
              }
            },
            {
              "id": "FLY",
              "name": {
                "value": "flying",
                "synonyms": [
                  "jet",
                  "fly",
                  "on an airplane"
                ]
              }
            },
            {
              "id": "DRIVE",
              "name": {
                "value": "driving",
                "synonyms": [
                  "auto",
                  "automobile",
                  "taking a road trip",
                  "road trip"
                ]
              }
            }
          ]
        },
        {
          "name": "AMAZON.US_CITY",
          "values": [
            {
              "name": {
                "value": "custom city"
              }
            },
            {
              "name": {
                "value": "small town"
              }
            }
          ]
        }
      ]
    }
  }
}