Deine Alexa Dashboards Einstellungen
Vielen Dank für Ihren Besuch. Diese Seite ist momentan nur auf Englisch verfügbar. Wir arbeiten an der deutschen Version. Vielen Dank für Ihr Verständnis.

Migrate to the Improved Built-in and Custom Slot Types

The Alexa Skills Kit now provides improved built-in slot types (DATE, NUMBER, and so on) and new custom slot types for collecting custom values. These changes reduce the number of sample utterances you need to provide, and increase the overall accuracy of speech recognition.

This document explains how to update skills built with earlier versions of the Alexa Skills Kit to take advantage of these features. Note that the previous functionality is still available for backward compatibility.

For more about defining the voice interface for a skill, see Define the Interaction Model in JSON and Text.

Using the Improved Built-in Slot Types

How the Built-in Slot Types have Changed

The Alexa Skills Kit still supports the same set of built-in types for numbers, dates, times, and durations. These convert the user’s spoken input into the specified data type. In previous versions of the Alexa Skills Kit, it was necessary to include slot values showing different ways of phrasing the slot data in your sample utterances. For example, you might have created sample utterances for the slot MyDate with values such as today, next thursday and september sixteenth:

DateIntent schedule an event for {today|MyDate}
DateIntent schedule an event for {next thursday|MyDate}
DateIntent schedule an event for {september sixteenth|MyDate}

The above utterances are identical other than the sample slot value.

The new versions of the built-in types handle the different phrases automatically, so you no longer need to include multiple versions of the same utterance with different values. The three utterances shown above are condensed to a single sample utterance:

DateIntent schedule an event for {MyDate}

The built-in types are now designated with the AMAZON namespace to differentiate them from the previous version. For example, to declare the above MyDate slot as a date in an intent schema, you use AMAZON.DATE instead of just DATE:

{
  "intents": [
    {
      "intent": "DateIntent",
      "slots": [
        {
          "name": "MyDate",
          "type": "AMAZON.DATE"
        }
      ]
    }
  ]
}

Migrating to the Improved Built-in Slot Types

To use the improved built-in slot types, you need to edit the intent schema and sample utterances on the Interaction Model section of the developer portal.

  1. In your intent schema, update the type property to include the new AMAZON namespace. Be sure to enter both the namespace and the type name in all caps. For example:

    This: {"name":"MyDate","type":"date"}

    Becomes: {"name":"MyDate","type":"AMAZON.DATE"}

  2. In your sample utterances, remove all of the sample slot values. The slot should appear in the utterance as just the slot name within curly brackets. For example:

    This: DateIntent schedule an event for {today|MyDate}

    Becomes: DateIntent schedule an event for {MyDate}

  3. At this point, you may have numerous duplicate utterances. All of the duplicates can be deleted.

Enter the revised intent schema and sample utterances in the Interaction Model for your skill and save the changes, then re-test the skill.

Backward Compatibility

The previous version of the built-in types continue to work. To continue using the old functionality, leave the type specified without the AMAZON namespace and leave the slot values within the sample utterances.

Replacing LITERAL with Custom Slot Types

How Custom Slot Types are Different from LITERAL

Earlier versions of the Alexa Skills Kit provided the LITERAL slot type for collecting free-form data. This required you to specify possible slot values within the sample utterances. For good accuracy, it was necessary to include utterances with all the possible values for the slot. For instance, a horoscope skill using LITERAL for the horoscope sign would include twelve utterances like this:

GetHoroscope    give me the horoscope for {capricorn|Sign}
GetHoroscope    give me the horoscope for {aquarius|Sign}
GetHoroscope    give me the horoscope for {pisces|Sign}
GetHoroscope    give me the horoscope for {aries|Sign}
GetHoroscope    give me the horoscope for {taurus|Sign}
GetHoroscope    give me the horoscope for {gemini|Sign}
GetHoroscope    give me the horoscope for {cancer|Sign}
GetHoroscope    give me the horoscope for {leo|Sign}
GetHoroscope    give me the horoscope for {virgo|Sign}
GetHoroscope    give me the horoscope for {libra|Sign}
GetHoroscope    give me the horoscope for {scorpio|Sign}
GetHoroscope    give me the horoscope for {sagittarius|Sign}

The above utterances are identical other than the sample slot value. The same set of twelve would be repeated for different phrasing patterns as well (“tell me the horoscope…”, “what is the horoscope for…”, and so on).

The new custom slot type replaces LITERAL and provides an easier way to define possible values and use them within utterances. You can now define a custom slot type and include all the possible values as part of that type. For example, for the horoscope skill you might create a custom type called LIST_OF_SIGNS that has the following values:

Capricorn
Aquarius
Pisces
Aries
Taurus
Gemini
Cancer
Leo
Virgo
Libra
Scorpio
Sagittarius

In your sample utterances, you reference just the name of the slot with no slot values. You no longer need to include multiple versions of the same utterance with different values. The twelve sample utterances for the horoscope skill are condensed to a single sample utterance

GetHoroscope    give me the horoscope for {Sign}

In addition, you can use the same custom slot type for multiple slots in the same skill, so you only need to define the set of values once. In this sample intent schema, the same LIST_OF_SIGNS custom slot type is used for three different slots in two different intents:

{
  "intents": [
    {
      "intent": "GetHoroscope",
      "slots": [
        {
          "name": "Sign",
          "type": "LIST_OF_SIGNS"
        },
        {
          "name": "Date",
          "type": "AMAZON.DATE"
        }
      ]
    },
    {
      "intent": "MatchSign",
      "slots": [
        {
          "name": "FirstSign",
          "type": "LIST_OF_SIGNS"
        },
        {
          "name": "SecondSign",
          "type": "LIST_OF_SIGNS"
        }
      ]
    },
    {
      "intent": "GetLuckyNumbers"
    }
  ]
}

Replacing LITERAL with a Custom Slot Type in an Existing Skill

To replace your LITERAL slots with new custom types, you need to edit the intent schema and sample utterances on the Interaction Model section of the developer portal.

Note: you may want to copy your intent schema and sample utterances into text files, do the updates below, and then copy the data back to your skill in the developer portal.

  1. On the Interaction Model page for your skill, click Add Slot Type to add a new custom slot type. Specify a name and the list of values.

    Note: If your schema has multiple LITERAL slots you are converting to custom slot types, create all of the types first, before updating the intent schema and sample utterances.

  2. In your intent schema, update the type property for the slot to the name of your custom type.

    This: {"name":"Sign","type":"LITERAL"}

    Becomes this: {"name":"Sign","type":"LIST_OF_SIGNS"}

  3. In your sample utterances, remove all of the sample slot values. The slot should appear in the utterance as just the slot name within curly brackets. For example:

    This: GetHoroscope give me the horoscope for {sagittarius|Sign}

    Becomes: GetHoroscope give me the horoscope for {Sign}

  4. At this point, you may have numerous duplicate utterances. All of the duplicates can be deleted.

Enter the revised intent schema and sample utterances in the Interaction Model for your skill and save the changes, then re-test the skill.

Common Errors when Editing the Intent Schema and Sample Utterances

Note that you cannot save an invalid interaction model for your skill. This means that you cannot do a “partial” migration from the previous version. For example, if you update your intent schema to use AMAZON.DATE for a slot type, but you leave the old slot values in your sample utterances ({today|MyDate}), an error occurs.

Because of this, you may want to do your editing in an external text editor, and then paste the finished schema, custom values, and sample utterances into the Interaction Model page when finished.

When migrating LITERAL slots to custom slot types, create all of the new custom slot types first, before updating the intent schema and sample utterances. This ensures that the interaction model can be properly built once you complete the updates.