So you want to build an Alexa skill...
In order to get started there are a couple of things you will need to sign up for in order to get going!
- Amazon Developer Account: This is where the front-end of your skill will be.
- Amazon Web Services (AWS) Account: This is where the backend is hosted for your skill.
Other helpful links:
- 17 Frequently Asked Questions About Building Your First Alexa Skill
- 10 Things Every Alexa Skill Should Do
- Build an Engaging Skill with In-Skill Purchasing and Earn Developer Perks
- Amazon Blueprints - Little to no code required
- Fact Skill Tutorials
What type of skills can Alexa learn? She can do a number of different things, but the basic set-up is defined by these categories:
- Game Skills
- Content Skills
- Kid Skills
- Music Skills
What can Alexa do? You can actually do a lot with Alexa, with Amazon adding new features practically everyday. We know Alexa for her ability build engaging voice experiences, but now you can use Alexa for adding visual and touch elements to the conversation or for in-skill purchasing.
We're going to be building a glorified Hello World program. In this tutorial, we are going to be working out a call and response for Alexa to interact with the users. There are certain words / utterances that Alexa is looking for a user to say that allows her to know the way to interact back with you.
- Launch (LaunchRequest):
Open [Skill Name]
,Start [Skill Name]
,Play [Skill Name]
- Utterances: These are what we will define later to show how the conversation should go within your skill
- Help (HelpIntent):
Help
- Stop (StopIntent):
Stop
- Cancel (CancelIntent):
Goodbye
Add Intent
You will need to define utterances that you want to have alexa identify. You will not need to say "Alexa"
a fact
for a fact
inspire me
tell me a fact
Then build the model.
Navigate over to AWS to work on the backend of your skill. Go to the Services
tab and search for Lambda
- which is a powerful yet simple compute capability with AWS.
You'll want to make sure you are in one of these four regions (preferably the one closest to you of the four). The only regions you'll be able to connect the Alexa skill to are the following:
- US East (Virginia)
- US West (Oregon)
- EU (Ireland)
- Asai Pacific (Tokyo)
You'll then click the Create Function
button to start your Lambda function. You're then given a couple of options of how to create the function. We're going to select AWS Serverless Application Repository
to use a template for
alexa skill kit nodejs fact skill
How to link the front end and the back end, your Alexa skill to AWS: Amazon Resource Name (ARN). You'll need to copy the ARN at the top of your Lambda function (within the AWS console) and navigate over to Amazon Developer account to fix your endpoint.
Service Endpoint Type --> ARN Default Region --> paste the ARN from AWS Save Endpoints
Now we've connected the front end and back end to have the JSON responses communicate. The other entries are for creating different endpoints for offloading to decrease the latency for other regions of the world.
At this point you should have all 4 checkpoints on the "Skill Builder Checklist"
In order to test your Alexa skill, you can do a number of things. You can configure your physical Alexa with the same email account as your developer account, or use the online tester.
Click the Test
tab in the developer console, and since this is our first time in the test environment, we'll have to enable the testing.
(We don't need to say Alexa) "Open [Skill Invocation Name]"
Look at the simulator you can see what was sent to the backend, and what was sent back. This will be very important when you're debugging.
We'll need to change how to handles the launch request in our backend code. We'll get to that later.
Now we're going to use the different utterances we've described earlier.
"Ask Preemptive Love for a fact"
and you'll see that the utterance is relating to the "GetNewFactIntent"
.
Let's go back to the AWS console to configure what is being given back as a response to the user interaction.
**index.js**
Within the index.js
file, you'll see the GetNewFactHandler
and you'll see 2 different functions: canHandle()
and the handle()
.
canHandle()
: determines if Alexa skill can handle the functionhandle()
: is the action that takes place when handling it
If it determines that it can handle the request, it will pick a random number of the amount of facts in the data
array.
Facts Array
Change the contents of the data array to have your own facts.
const data = [
'A year on Mercury is just 88 days long.',
'Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.',
'Venus rotates counter-clockwise, possibly because of a collision in the past with an asteroid.',
'On Mars, the Sun appears about half the size as it does on Earth.',
'Earth is the only planet not named after a god.',
'Jupiter has the shortest day of all the planets.',
'The Milky Way galaxy will collide with the Andromeda Galaxy in about 5 billion years.',
'The Sun contains 99.86% of the mass in the Solar System.',
'The Sun is an almost perfect sphere.',
'A total solar eclipse can happen once every 1 to 2 years. This makes them a rare event.',
'Saturn radiates two and a half times more energy into space than it receives from the sun.',
'The temperature inside the Sun can reach 15 million degrees Celsius.',
'The Moon is moving approximately 3.8 cm away from our planet every year.',
];
const SKILL_NAME = 'Space Facts';
const HELP_MESSAGE = 'You can say tell me a space fact, or, you can say exit... What can I help you with?';
FallBackIntent
: way to service unwanted requests where it doesn't know how to handle it. (You can delete it, until you create a handler).
Click on "Distribution" and fill out the form. Pay close attention to the example phrases and make sure your sample utterances appear in your model, otherwise it won't pass certification.
- Have to have alexa in one of your example phrases
Alexa open Preemptive Love facts
Alexa ask Preemptive Love for a fact
Alexa tell Preemptive Love to inspire me
You can create an Icon for your Alexa skill. Enter a category that your skill applies with, as well as keywords.
Testing Instructions: be as descriptive as possible. "Say alexa open Preemptive Love
to test the skill. You can also say Alexa ask Preemptive Love to tell me a fact
The skill will return a random fact about the organization."
Once finishing the distribution form, it will run a validation test and a functional test before submitting the skill for certification.
Review Amazon Alexa Incentives for additional prizes. You can build your skill in javascript or python and you can look at their github for other supported languages.