< Home

My Alexa Skill workflow (Part 2/2)

Hello, and thank you for coming back for part two. If you haven’t read part one of this guide, you can find it here. Alternatively, if you just want to skip part one, go ahead and clone the repository.

In part one we created the codebase for our skill, but testing the skill needs to be done locally. Wouldn’t it be cool, if we could get it running on an alexa device and show all our friends what we have done? That is what we are going to do in this article.

The first thing we need to do is create a zip of our skill to upload to AWS. Go to the skill directory on your machine and zip up the contents. Make sure you only zip up the contents and not the directory itself. I tend to do the following from inside the skill’s directory:

zip -r spacefact.zip .

Next, as we are going to be using AWS Lambda to “host” our skill, the first thing we need to do is log into our AWS account. If you haven’t got an AWS account, you can quickly set one up here. At the moment ASK only supports two regions US East (N. Virginia) or EU (Ireland). Make sure that you choose one of these regions from the region dropdown in the top right of the console. Once you have decided, make a mental note of which one you chose as this will come to be important when we hook up the lambda to skill - sounds confusing I know, but it will become apparent soon.

With your region selected, click services on the top right and choose Lambda from under the “Compute” heading.

AWS Services Screenshot

Click Get started or Create a Lambda function depending on whether you have used Lambda before. Then, select Blank Function from the blueprint options.

AWS Select blueprint screenshot

You will then be asked to add a trigger for your Lambda. You can choose to set this up at a later date, but as we know what we want, we are going to go ahead and choose Alexa Skill Kit from the integrations drop down.

AWS Configure triggers screenshot

Finally, you will be asked to configure the function itself. Add the following for the options:

  • Name: mySpaceFact
  • Description: Tells you a fact about one of three planets - Mercury, Venus, and Earth.
  • Runtime: Node.js 4.3

Under the “Lambda function code” heading, choose to Upload a .ZIP file from the “Code entry type” title. Proceed to click the Upload button, find and select the zip file we created.

Next, under the “Lambda function handler and role” heading, choose Choose an existing role from the “Role” option, from there you can choose lambdabasicexecution from the “Existing role” heading. You may need to create this role if you have a brand new AWS account. In which case I would choose Create a custom role.

You should end up with something similar to this:

AWS Configure Function screenshot

Click Next, then click Create function on the review page. You should land on a page which looks the same as this:

AWS Lambda Overview

Before we go on to associate the Lambda function with the skill, let’s add a test case for our lambda. Click the Actions button and select Configure test event. A modal will be displayed which looks similar to this:

AWS Lambda testing modal screenshot

Paste the contents below into the editor and click Save and test.

  "version": "1.0",
  "session": {
    "new": true,
    "sessionId": "amzn1.echo-api.session.abeee1a7-aee0-41e6-8192-e6faaed9f5ef",
    "application": {
      "applicationId": "amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe"
    "attributes": {},
    "user": {
      "userId": "amzn1.account.AM3B227HF3FAM1B261HK7FFM3A2"
  "request": {
    "type": "LaunchRequest",
    "requestId": "amzn1.echo-api.request.9cdaa4db-f20e-4c58-8d01-c75322d6c423",
    "timestamp": "2015-05-13T12:34:56Z"

(This is copied from http://localhost:8080/alexa/spacefact)

You should then see “Execution result: succeeded” at the bottom of your screen. The response to this LaunchRequest should look something similar to the below:

AWS Lambda testing response screenshot

If the execution result failed, make sure your tests are passing, and your local testing is producing the expected result.

OK, so we now have our working Lambda function with a test configured. Before we go any further, copy the ARN from the top right of the screen, we will need this to associate the skill with the Lambda function.

AWS Lambda ARN Screenshot

Next, we need to head over to https://developer.amazon.com/, click Sign In from the top right. Now, this step is critical, if you want to get the skill working on your Alexa (which is, after all, what we are looking to do in this article). You need to make sure that you create a developer account with the Amazon account that is associated with your Alexa. Obviously, this is not true if we were going to publish the skill, but that is outside the scope of this article, so we have to associate the skill with the Alexa we want to use for testing.

Click Alexa from the navigation:

Amazon Developer Console screenshot

Click Get Started under the “Alexa Skills Kit” option.

Amazon Developer Console Alexa Skills Kit Screenshot

Next, click Add a New Skill located at the top right of the screen. You will then presented with a form which allows you to start creating your new Alexa skill.

Fill out the form with the following information:

  • Skill Type: Custom Interaction Model
  • Language: This depends on the region you selected when you set up your Lambda. As I picked EU (Ireland) I am choosing English (U.K.), if you opted for US East (N. Virginia) make sure you choose English (U.S.).
  • Name: SpaceFact
  • Invocation Name: space fact

Your page should look like the below:

Amazon Developer Create new Alexa Skill screenshot

Click Next. We are then presented with a page for the “Interaction Model” information. Copy the following for the Intent Schema input.

  "intents": [
      "intent": "planetFact",
      "slots": [
          "name": "WORD",
          "type": "POSSIBLEWORDS"
      "intent": "AMAZON.StopIntent",
      "slots": []

(This is copied from http://localhost:8080/alexa/spacefact)

Then, click Add Slot Type. Add the following for the inputs.

  • Enter Values: Mercury | Venus | Earth

Finally, add the following for the Sample Utterances input. You may have more depending on whether you added more utterances in part one.

planetFact    tell me about {WORD}
planetFact    tell us about {WORD}
planetFact    {WORD}

(This is copied from http://localhost:8080/alexa/spacefact)

Your page should look like the below:

Amazon Developer Skill Interaction Model Screenshot

Click Next. We will then see a page for the “Configuration” information. This part is easy, select AWS Lambda ARN (Amazon Resource Name) for the “Service Endpoint Type” option, chose the region you are working in and then paste the ARN we copied from our Lambda earlier.

Your page should look similar to the below:

Amazon Developer Skill Configuration screenshot

Click Next. You can then use this page to test your skill OR you can use Alexa itself. If you go the Alexa app on your phone and visit “Your Skills” you should see your SpaceFact skill in the list. If you are seeing this, it confirms that your skill has been set up successfully. It should look something similar to this:

Alexa App SpaceFact screenshot

There you have it, you have now added your skill to Alexa (albeit in a development environment.) Now, go and have fun with your skill, here are some sample expressions you could say to Alexa:

“Alexa run space fact”

“Alexa start space fact”

“Alexa ask space fact”

Want to do more?

Try adding more built-in Intents. At the moment, if you asked our skill for help it would return the IntentRequest response. Returning this response is not very useful when you are asking for help. ASK defines built-in intents for handling standard intents like “help” and “stop”. Visit this for a push in the right direction. To publish your skill, you are required to handle these built-in intents, so it is worth investing your time in looking into these properly if you are planning to publish a skill shortly.

Initially, I was going to write a third and final article around automatic the deployment of your Lambda. I have since found this article published by AWS about how to do it. I would highly recommend running through the article and substituting where necessary, things like bucket-name and project-name for space-fact. One thing to be aware of, this will create a whole new Lambda which will not be hooked up to your skill. Once you have run through the article and the Lambda is set up don’t forget to update the ARN on your skill config in development.amazon.co.uk.

There you have it, go and improve the world by making something truly amazing and innovative with Voice UI.