We are excited to announce two new Alexa Skills Kit features have been made available for you to use immediately within your own Alexa skills. This update gives you the ability to create custom slots and values for items that are not covered by Amazon’s built-in slot types. If you have created an Alexa skill before, you may have often relied on the LITERAL slot type for most of your intents. This resulted in a large amount of sample utterances being required for Alexa to consistently understand your requests. With custom slot types you can now define your own slot types resulting in far fewer sample utterances.
With this update we have also added support for Speech Synthesis Markup Language (SSML) allowing you to control how Alexa generates speech from your skill’s text responses. This includes Alexa’s inflection, pauses, periods, interpretation (like how to specify digits, dates or times) and pronunciation. Need her to pause after a long sentence? Now you can!
The custom slot type is used for items that are not covered by Amazon’s built-in set of types and is recommended for most use cases where a slot value is one of a set of possible values. For example, let’s say you needed to create a computer model number with the following list of values:
A500, A1000, A2000, A2000HD, A2500, A3000, A600, A1200 and A4000
You could easily create a new slot type of MODEL and then define it within the developer portal on the Interaction Model page.
Clicking on Add Slot Type will allow you to create a name for your new Slot Type and its corresponding values.
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 English dictionary may not be recognized. Click Ok, and you will see your new slot type and values displayed for easy use within your Intents and Sample Utterances.
In addition to the new custom slot type Amazon now provides built-in support for the following slot types:
If your skill uses any of these types, you don’t need to provide sample values in a separate file, you just reference your slots of this type in the Sample Utterances file as necessary. For other data types, a custom slot type is recommended. Note that all built-in types are prefixed with the AMAZON namespace.
LITERAL slot type has been renamed to AMAZON.LITERAL. The AMAZON.LITERAL type is maintained primarily for backwards compatibility with skills produced by earlier versions of the Alexa Skills Kit, and is not recommended for most use cases going forward. You should instead use a custom slot type moving rather than AMAZON.LITERAL.
Once you have defined your slot types you can immediately use them within your own Intents. For the computer model described earlier you would use them within your intents like so:
{
"intents": [
{
"intent": "GetComputer",
"slots": [
{
"name": "Model",
"type": "MODELS"
},
{
"name": "Date",
"type": "AMAZON.DATE"
}
]
}
]
}
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, which was a common practice for getting Alexa to fully understand all of the possible values a LITERAL slot could contain.
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}
That’s the power of custom slots! You can spend more time coding your skill and less time creating Sample Utterances.
To learn more about using custom slot types within your Alexa skill click here.
When the service for your skill returns a response to a user’s request, you provide text that the Alexa service converts to speech. Alexa automatically handles normal punctuation, such as pausing after a period, or speaking a sentence ending in a question mark as a question.
However, in some cases you may want additional control over how Alexa generates the speech from the text in your response. For example, you may want a longer pause within the speech, or you may want a string of digits read back as a standard telephone number. The Alexa Skills Kit now provides this type of control with Speech Synthesis Markup Language (SSML) support. SSML is a markup language that provides a standard way to mark up text for the generation of synthetic speech.
The Alexa Skills Kit supports a subset of the tags defined in the SSML specification. The specific tags supported currently for SSML are: speak, p, s, break, say-as, phoneme, and w.
To use SSML, construct your output speech using the supported SSML tags. When sending back a response from your service, you must indicate that it is using SSML rather than plain text:
"outputSpeech": {
"type": "SSML",
"ssml": "<speak>This output speech uses SSML.</speak>"
}
You can use SSML with both the normal output speech response and any re-prompt included in the response.
The SSML you provide must be wrapped within <speak> tags. For example:
<speak>
Here is a number read as a cardinal number:
<say-as interpret-as="cardinal">12345</say-as>.
Here is a word spelled out: <say-as interpret-as="spell">hello</say-as>.
</speak>
For more information on using SSML within your Alexa skill read the SSML reference here.
Check out these additional Alexa developer resources:
Migrating to the Improved Built-in and Custom Slot Types
An Introduction to the Alexa Skills Kit (ASK)
Free Video Training - An Introduction to Amazon Echo and the Alexa Skills Kit
Creating an Amazon Echo Adventure Game with the Alexa Skills Kit
New Alexa Episode on the AWS Podcast
Looking to get hands on with Alexa? Check out these upcoming Alexa events:
Sign up for Alexa sessions and Workshops at AWS re:Invent 2015
Join a Local Alexa Hackathons with the Alexa Roadshow
-Dave (@TheDaveDev)
Want Amazon Developer blogs delivered to your inbox? Stay in the loop on the latest industry best practices, Amazon promotions, and new launches by subscribing to our weekly blog summary here.