The Anatomy of an Alexa Skill
For today’s post I thought I’d take a bit of a step back. I’d realised I haven’t actually covered the anatomy of an Alexa Skill, which is probably a good step to take!
You can obviously go through the official docs at https://developer.amazon.com/docs/ask-overviews/build-skills-with-the-alexa-skills-kit.html but I wanted to break it down into understandable, laymen's terms. Or at least how I understand it!
Request
When you say something along the lines of “Alexa, open the weather” a number of things happen.
First your request is sent to the Alexa Voice Service to handle automatic speech recognition and natural language understanding. But in basic terms you can think of it as turning the words into text.
At this point Alexa “understands” your request and looks for a suitable “skill” to handle it. If it finds a suitable skill (your skill I hope) then it sends you the request in the form of “intents” and “slots”.
Intents
An “intent” is what a user might say for a particular use case. In the example above the “intent” is “what’s the weather?”. You would then have an appropriately name handler (some function code) to process this and return “It’s raining” or “It’s sunny” depending on where you live. You can create custom intents to handle what you think your users are going to say (and you need to be thorough here in trying to list all variations you can think of), but there are also some default ones that Amazon have pre-trained. Phrases like “Yes”, “No” and “help”.
Slots
Slots form part of intents. They are specific phrases or words that you want to pull out because they mean something to you. You define slots as part of your Alexa skill. There are numerous pre-built slots (similar to intents above) but you can define your own. You can even extend the existing ones if need be. Some example of pre-built slots are cities, first_names etc.
For our weather example above, we might actually expect the user to say “What’s the weather like in London”. In this case “London” would be the slot value you want to pull out as part of the intent, so you can look up the weather at the appropriate location and tell that to the user.
Responding
Once you have all the information you need, you return a response to Alexa, which in turn reads it out to your user (or displays it on a screen etc.).
The easiest way to get started here is to use one of the available Alexa SDKs such as the ASK-SDK for node. But we will cover some of these in more detail in later posts.
This was just a brief beginners guide to the Alexa lifecycle, but I hope it has helped clear up some ambiguity around what “intents” and “slots” actually are.
Please feel free to sign up to my new Alexa Devs facebook group here if you wish to continue this discussion.