AWS: How to create your first Alexa skill

Published

Step 1 - Register with Amazon Developer + AWS

You will need to register with both of these services:

  • Amazon Developer - Amazon Developer will guide you towards making an Alexa Skill.
  • Amazon Web Services - AWS will help you create a Lambda function to handle the skill requests.

Step 2 - Create a New Skill + Invocation

Skills are built-in capabilities for Alexa to give users new experiences and we first create our skill using Amazon Alexa Developer Console.

How do I get started?

Once you log into the Amazon Alexa Developer Console, select Alexa > Alexa Skills Kit to get started.

alexa-services-1

alexa-create-a-skill

What do I name my Skill?

Skills require two things to successfully work: an invocation name and an utterance. When you enter a "Skill Name", you are actually naming its invocation. Invocations are phrases that link the interaction with a custom skill.

Since I work for Classical KUSC, my invocation will be titled ninety one point five which means that users will have to say,

"Alexa, ask ninety one point five."

alexa-name-skill-ninety-one-point-five


Let's start an Alexa skill from scratch.
choose-a-template


You have completed the first step in our checklist. Now let's move on the step #2.

alexa-add-intent


Step 3 - Create an Intent + Utterances

Intents

Intents are what a user specifically wants to do. Using the previous invocation, we're going to help users ask, "Alexa, ask ninety one point five what's playing?"

Utterances

Not everyone is going to ask a radio station "what's playing" in the exact same way so we use utterances to consider other ways to ask for the same data. Utterances are derivatives of your original request but said differently. For example, here are two similar requests for information and what's implied by the user that is they want to know what's playing right now.

  • "Alexa, ask ninety-one point five composers ".
  • "Alexa, ask ninety-one point five the composer's name".

Utterances are useful because they will help you improve the accuracy of Alexa and they can also help you reach new audiences from different age ranges. For example, maybe you want to reach a younger audience and they may be more inclined to ask,

  • "Alexa, ask ninety one point five names ".
  • "Alexa, ask ninety-one point five titles ".
  • "Alexa, ask ninety-one point five 'da name".

Below is a list of my utterances.

alexa-intents


Step 8 - Get Your Alexa Skill ID

You will need your Skill ID for the next steps. You can find it by first selecting on the menu.

alexa-return-to-skills

Select "View Skill ID" to access your Skill ID string.
alexa-get-skill-id


Step 9 - Create your skill response

Once you've configured Alexa to consider your solution to solve a user's request, you'll need to create the actual solution. We are going to use Node on AWS Lambda so that we do not have to meddle with any servers.

Visit AWS Lambda

alexa-aws-lambda

Create a new function.

alexa-aws-create-function

Author a function from scratch.

alexa-aws-author-from-scratch

If you notice, I have a role called role-lambda-basic-execution. This role was created within AWS IAM and looks like this.

alexa-iam-basic-lambda

Connect Alexa to Lambda

After you've completed the initial lambda from, you'll get the chance to connect the Alexa skill to your lambda function.

alexa-lambda-hooks-1

Take note that you will need to paste the skill id that you received from step 6.

alexa-lambda-configure-portal


Step 10 - Build your skill

Here is the Javascript code we'll use to respond to our user's request.

const Alexa = require('alexa-sdk');

// Register the handlers
const handlers = {
    // A. This is the first thing that happens when the Alexa is invoked. 
    //    Think of it as a constructor function.
    'LaunchRequest': function() { 
        this.emit('LaunchIntent');
    },
    // B. This will be Alexa's first response.
    'LaunchIntent': function() {
        this.emit(':ask', "How are you today?");
    },
    // C. This will be called throught the intent schema and utterances.
    'HelloIntent': function() {
        this.emit(':tell', "I'm great. You have successfully created your first skill with Amazon Alexa.");
    }
};

exports.handler = (event, context, callback) => {
    var alexa = Alexa.handler(event, context);
        alexa.registerHandlers(handlers);
        alexa.execute();
};

Step 11 - Simulator testing

Now that we've created a skill, created an invocation with utterances and a Javascript solution, it's time to test our app.


Step 12 - Hardware testing

Your hardware device must match your

Visit alexa.amazon.com to pair your hardware device with your skill.

Comments