Hello World with Alexa and AWS Lambda

Lambda

Creating an Alexa Skill with AWS Lambda is easy. I used the Hello World sample skill and this tutorial to deploy my first Alexa skill using AWS Lambda: Deploy a Sample Custom Skill to AWS Lambda. I had to jump between many pages to complete the tutorial so I summarize the steps with the corresponding links in this post.

Pre-requisites:

  • Register for Amazon Web Services
  • Register for Alexa Developer Portal

Prepare a Node.js Sample to Deploy in Lambda

  • Install Node.js and Visual Studio Code locally on your machine
  • Download the sample code for Hello World from GitHub
  • Open the folder in VS Code and review the files
    • The folder speechAssets is for the Alexa Developer Portal
    • The folder src is for the AWS Lambda function
  • Navigate to View > Integrated Terminal, navigate to the folder src and run “npm install alexa-sdk”
  • Select all the contents of the src folder, including the node_modules folder, and create a zip file

Set Up a New Skill in the Developer Portal and Get the Skill ID

  • Go to the Alexa Developer Portal
  • Follow the steps at Register a New Skill to add a new skill
    • Select language
    • Enter name and invocation name

Creating the Lambda Function for the Sample

  • Go to the AWS Management Console
  • Follow the steps at Create the Lambda Function for the Sample to add a new Lambda function and configure the Alexa Skills Kit Triggers using the Skill ID from the Alexa Developer Portal

Complete the Configuration of the Skill on the Developer Portal

  • Go to the Alexa Developer Portal and edit your skill
  • Navigate to Custom > Endpoint, select AWS Lambda ARN, then paste the ARN for your Lambda function in the Default Region box.
  • Navigate to Custom > Interaction Model > JSON Editor, paste in the interaction-model.json, then click Save Model and Build Model.

Test your Skill

  • In the Alexa Developer Portal, navigate to Test: “Test is enabled for this skill” is disabled by default so enable it
  • In the Alexa Simulator, enter “hello world”
  • Check the JSON Input request and the JSON Output response

Additional resources