Your Alexa Consoles
?
Support

LITERAL Slot Type Reference

AMAZON.LITERAL passes the recognized words for the slot value with no conversion. You must define a set of representative slot values as part of your sample utterances. This is primarily provided for compatibility with earlier versions of the Alexa Skills Kit.

Sample Utterance Syntax for AMAZON.LITERAL

When using AMAZON.LITERAL, you must include sample slot values within the curly brackets defining the slot in the utterance:

{
  "interactionModel": {
    "languageModel": {
      "intents": [
        {
          "name": "GetHoroscope",
          "slots": [
            {
              "name": "Sign",
              "type": "AMAZON.LITERAL"
            }
          ],
          "samples": [
            "give me the horoscope for {capricorn|Sign}",
            "give me the horoscope for {aquarius|Sign}",
            "give me the horoscope for {pisces|Sign}",
            "give me the horoscope for {aries|Sign}",
            "give me the horoscope for {taurus|Sign}",
            "give me the horoscope for {gemini|Sign}",
            "give me the horoscope for {cancer|Sign}",
            "give me the horoscope for {leo|Sign}",
            "give me the horoscope for {virgo|Sign}",
            "give me the horoscope for {libra|Sign}",
            "give me the horoscope for {scorpio|Sign}",
            "give me the horoscope for {sagittarius|Sign}",

            "what is the horoscope for {capricorn|Sign}",
            "what is the horoscope for {aquarius|Sign}",

            "...ten more instances of this phrase, one for each sample value",

            "...more phrasing varieties, each repeated 12 times to include each value"
          ]
        }
      ]
    }
  }
}

Note that the Sign slot shown in the above example is for example purposes only. This slot type would work much better as a custom slot type rather than AMAZON.LITERAL.

If you create and edit your interaction model in the developer console, add the slot to your intent, assign it the type AMAZON.LITERAL, then use the above syntax when you enter your sample utterances.

Note the following rules and recommendations.

Include samples with different numbers of words for the slot value:

  • Samples with the minimum number of words you expect for the slot value.
  • Samples with the maximum number of words for the slot value.
  • Samples with all varying numbers of words between the minimum and the maximum expected.

These samples should always include only slot values that represent actual phrases the user might say. Do not use meaningless placeholder words in the sample phrase just to fill the slot with the right number of words. Instead, fill the sample slot value with real-world examples of the data you want to collect in the slot.

If you are using the AMAZON.LITERAL type to collect free-form text with wide variations in the number of words that might be in the slot, note the following:

  • Covering this full range (minimum, maximum, and all in between) will require a very large set of samples. Try to provide several hundred samples or more to address all the variations in slot value words as noted above.
  • Keep the phrases within slots short enough that users can say the entire phrase without needing to pause.

Lengthy spoken input can lead to lower accuracy experiences, so avoid designing a spoken language interface that requires more than a few words for a slot value. A phrase that a user cannot speak without pausing is too long for a slot value.

For example, the intent for an ability that posts the user's spoken words to a social media site might have an UpdateText slot that collects the text to post. Values for this slot range from just one word to about nine or ten words. The sample utterances to support this intent should cover a range of words such as the following:

{
  "interactionModel": {
    "languageModel": {
      "intents": [
        {
          "name": "StatusUpdate",
          "slots": [
            {
              "name": "UpdateText",
              "type": "AMAZON.LITERAL"
            }
          ],
          "samples": [
            "post the update {arrived|UpdateText}",
            "post the update {dinner time|UpdateText}",
            "post the update {out at lunch|UpdateText}",

            "...(more samples showing phrases with  4-10 words)",

            "post the update {going to stop by the grocery store this evening|UpdateText}"
          ]
        }
      ]
    }
  }
}

This set includes sample slot values ranging from one word ("arrived") to about ten words. This type of sample coverage should provide better recognition.

Migrate AMAZON.LITERAL to a Custom Slot Type

Custom slot types provide an easier way to define possible values and use them within utterances. They also reduce the number of sample utterances you need, since the values are not defined within the utterances. Migrating AMAZON.LITERAL slots to custom slot types is highly recommended.

  1. Go to developer.amazon.com/alexa.
  2. Click Your Alexa Consoles and then click Skills. This opens the developer console and displays any skills you have already created.
  3. Edit the skill to update.
  4. Create a new custom slot type for the slot that currently uses AMAZON.LITERAL.
  5. Add all your sample values from your LITERAL slot to the new custom slot type.

    The sample slot values are in your utterances, to the left of the | character.

  6. Edit the intent that uses the slot with LITERAL and change the slot type to the new custom slot type.
  7. Remove the sample values within the utterances.
  8. Remove any duplicate sample utterances.
  9. Save and build your model.

You can also use the JSON Editor to make the changes directly to the interaction model JSON.

The JSON for the earlier horoscope example would like this after migrating the AMAZON.LITERAL slot to a new LIST_OF_TYPES custom slot type:

{
  "interactionModel": {
    "languageModel": {
      "intents": [
        {
          "name": "GetHoroscope",
          "slots": [
            {
              "name": "Sign",
              "type": "LIST_OF_SIGNS"
            }
          ],
          "samples": [
            "give me the horoscope for {Sign}",
            "what is the horoscope for {Sign}",            

            "...additional unique utterances showing different phrasing"
          ]
        }
      ],
      "types": [
        {
          "name": "LIST_OF_SIGNS",
          "values": [
            {
              "name": {
                "value": "sagittarius"
              }
            },
            {
              "name": {
                "value": "scorpio"
              }
            },
            {
              "name": {
                "value": "libra"
              }
            },
            {
              "name": {
                "value": "virgo"
              }
            },
            {
              "name": {
                "value": "leo"
              }
            },
            {
              "name": {
                "value": "cancer"
              }
            },
            {
              "name": {
                "value": "gemini"
              }
            },
            {
              "name": {
                "value": "taurus"
              }
            },
            {
              "name": {
                "value": "aries"
              }
            },
            {
              "name": {
                "value": "pisces"
              }
            },
            {
              "name": {
                "value": "aquarius"
              }
            },
            {
              "name": {
                "value": "capricorn"
              }
            }
          ]
        }
      ]
    }
  }
}

Note that the twelve sample utterances are condensed to a single utterance.

For more about custom slot types, see Create and Edit Custom Slot Types.