July 16, 2021
Deloris Thompson
Tags:
‍
This is an updated version of a previous Echobind blog post. This new version still contains valid parts from the original found here.
The first step in creating an Alexa Skill is signing up for a developer account. Once you are signed up/logged in select Alexa. This will bring you to the Alexa homepage, click on the “Create Alexa Skills” button.
‍
‍
If you are not logged in you will notice the button is “Console” instead of “Register Now”. You can still click “Console” and this will bring you to the sign-in page (it will also allow you to sign up if you have not done that yet).
Creating a new skill requires clicking the “Create Skill” button on the right-hand side.
A lot is going on here so let’s break it down.
A. This is where we set our skill name.
B. Default Language — This is our skills default language(English). We can add more later.
C. Model — There are a lot of really great pre-built skills. We are going with the Custom model; it allows us to create a custom model with the required skills and a Hello World skill.
Click “Create Skill”
The developer console is where the magic happens. It allows us to set everything we need for the skill.
A. Invocation — This is where we set the Skill Invocation Name. The Skill Invocation Name is what the user says to begin interacting with our skill.
B. Interaction Model — This is a combination of utterances, intents, and slot values.
C. Intents — Represents an action that fulfills a user’s spoken request.
D. HelloWorldIntent — This is a really great freebie that we can ignore or even delete.
E. Built-In Intents — These are the minimum requirements for all Alexa Skills. They are not to be removed at all.
‍
‍
There are a few requirements for an invocation name:
Now that we have the name click “Save Model” and wait for the confirmation alert on the bottom right-hand side of the site. Once the save is finished click “Build Model”. This is required for all new changes to take effect. The bottom right-hand side will display a small alert letting us know if the build was successful or not.
Intents are nested under the Interaction Model dropdown. Click "+ Add Intent" to do just that.
We are going to keep this part simple with only a couple of intents. For more information on intents, see this section of the Alexa documentation. Intents are always PascalCased. Once you add the name click “Create custom intent” to begin adding utterances.
An utterance is a user’s spoken request. When adding an utterance think of all the possible questions a user will ask for the intent. One user might say what is the hottest pokemon? while another would ask what’s the hottest pokemon? or even who is the hottest pokemon?. Taking the time to map out these questions will greatly improve your skill and user experience. At this point, our skill doesn’t have an utterance so let’s add some. Hitting “Enter” will automatically add the utterance.
List of Utterances
Let’s pause the skill configuration for a second. Breaks are important so let’s take a small one and pat ourselves on the back.
Let’s set up our application to handle Alexa’s requests. For this section, we’re going to assume you have a Rails API available.
‍
Create a new controller for requests from Alexa.
‍
‍
In this controller, you’ll note that I return an odd piece of JSON. A lot of this is the boilerplate you need for Amazon. The most important part is the “outputSpeech” section. Here is the documentation to learn more about responses and requests from Amazon. For now, we’ll stub out a simple response “Hello from Pokemon Hot!”
and update your routes file
‍
Once you’re finished make sure to restart your Rails server.
ngrok will host a local version of our app, and allow Amazon servers to speak to it. Amazon requires our server to have SSL. We don’t want to host a Heroku SSL instance simply for testing, so ngrok will work perfectly.
‍
After installing ngrok, set it to run on whatever port you’re running your Rails server on. In our case, it’s good ol’ port 3000.
‍
Do you see that HTTPS link above? That is what we’ll tell Alexa to communicate with.
Now that we have:
‍
Let’s point Alexa at our application. Go to the Alexa skill you created earlier, click on “Endpoint” in the left sidebar. The default setting is AWS Lambda ARN, let’s change it to HTTPS and paste in the HTTPS link from ngrok, including the route we created Ex:
‍
It’s testing time!!!
‍
Go to the “Test” tab in your Alexa skill. Testing is automatically turned off.
Now we can test our skill!!
Type in your invocation name. You should see output similar to below:
Great Job! You see we got a response back from our API. This post just skims Alexa skills. There are other features like slot values and more.
Create Alexa Skills Kit | Amazon Alexa Voice Development
‍
Deloris is a software engineer at Echobind by day and student, mom, and wife by night. She is obtaining a Bachelor's in Computer Science at the University of Advancing Technology.