Alexa and all her skills
A few days ago I had the privilege of attending a workshop on building skills for Alexa by an Alexa Voice Service Evangelist (yes that is his title). During the workshop there was a lot of lingo used and I will try my best to point them out. One of them is skills, I think of Alexa skills as the equivalent to apps that we have on our typical touch devices. We do not make apps for Alexa but instead create skills for Alexa.
For those who have not had experience with Alexa, it is on a few of Amazon’s products and is voice activated. Below is Alexa in action with the Echo Dot.
To “turn on” Alexa so it is listening to your commands users have to use the wake word which is simply “Alexa”. Once it hears the wake word the device will be listening for 7 seconds for a command/prompt/question/etc. If within that time it hears nothing it will shut off and users will have to use the wake word again. Users can know if it is listening by the light located on the top of the device, if it is lit Alexa is listening and if not the device is not listening for anything.
Before developing it is important to keep this in mind. Commands to Alexa have a few parts, let us use the below two commands as examples:
“Alexa, tell me a space fact.”
“Alexa, ask space fact for trivia.”
- As mentioned above “Alexa” is the wake word so the device wakes up and knows to listen
- “Tell” and “ask” are just a few of the launch words that tell Alexa what to do to the skill. Other launch words include “open”, “login”, “start”, “launch”, etc.
- “Space fact” is the skill invocation name that you will set up for your custom skill. Since Alexa has many skills it will need to know which skill it is accessing. There can be many skills from different users with the same invocation name (i.e cat facts) but the Alexa app only allows users to have one skill with that invocation name at a time. More information can be found here.
- The second example “for trivia” is an example of an utterance which are additional ways of how users can interact with your skill. Other utterances may include “tell me something”, “give me something”, etc.
It turned out to be not so difficult or intimidating to build a skill for Alexa. The rest of this article will walk you through. The first steps are to sign up for Amazon Developer tools and Amazon Web Services. Check out the links below.
The Amazon Developer Services portal allows developers to distribute and sell Android and HTML5 web apps to millions of…developer.amazon.com
In Amazon Developer Services go click on the tab that says “Alexa” to get started. Once you are on the page select “Alexa Skills Kit”
This will take you to a dashboard where you can view all the skills that you currently have. There is also a button which brings you to a wizard that so that you can create new skills.
- The Skill Type to select is “Custom Interaction Model”.
- Language currently only supports English (U.S), English (U.K) and German but they will be coming out with new languages periodically.
- The Name field is how users can search for your skill in the Alexa app.
- Invocation Name is the key word or words that users will say for Alexa to access the skill. As the above example, the skill will be called “space facts” so once Alexa hears “space facts” it will be able to know which skill to access.
- At this point the Audio Player can be left at the default “No”
At the next screen empty spaces for the Intent Schema and the Sample utterances. Instead of writing your code here you should go to the GitHub for Alexa. Here you can find templates for creating skills but for this tutorial we will just search fact and go into the repository for skill-sample-nodejs-fact.
Once in the repo go to the speechAssets folder -> IntentSchema.json and copy and paste the contents into Intent Schema section of the setup wizard. Go back to the speechAssets folder -> SampleUtterances_en_US.txt and copy and paste the contents into the Sample Utterances section of the wizard. It should look like below once completed.
- The Intent Schema is the intents. Essentially each intent is a behavior of skills. The first intent is the one for your skill while the other 3 are defaulted ones that Amazon provides for us (in order to have your skill published your skill needs the 3 intents that are provided: Help, Stop and Cancel). More information can be found here.
- Sample Utterances are just ways of asking for the same thing. These utterances do not need to match exactly as Alexa is learning and can figure it out by the pattern.
Now we need to go to the AWS site. Once logged in make sure that you are in the US East (N.Viriginia) region as this is the server that holds Alexa (see screenshot).
We can now search for lambda in the search bar. On the next screen you will want to click the “Create a Lambda function” button.
You will need to search for a blueprint so type in “fact” and click on “alexa-skill-kit-sdk-factskill”.
The next step is to configure the triggers. Click on the empty box and select “Alexa Skills Kit” from the dropdown.
For the configuration only these fields need to be filled in:
— Name* which can be anything you like.
— Role* which you select “Create a custom role” (see screenshot).
Selecting “Create a custom role” will open a new tab. There should be nothing to do on this page except to just confirm by clicking “Allow”. The default values should be as below.
The tab will close and you should be back to where you left off in AWS. At this point you can continue to the next screen and “Create function”. Once the function is created you will be given an ARN which is to be used back in the developer site. Copy the code as highlighted below.
Once copied, go back to the Developer wizard and select AWS Lambda ARN, North America and then paste in the code and click “Next”.
At this point you have already created a skill for Alexa! The next page is just a testing screen where you can test out your skill. You can test this out on the screen here or you can go to https://echosim.io to test it out using your voice.