Create an Alexa Skill Part 2: Setting up a Lambda Function

Published Jan 24, 2017Last updated Feb 01, 2017
Create an Alexa Skill Part 2: Setting up a Lambda Function

What is an Alexa Skill?

Created in 2014, the Amazon Echo is a hands-free speaker you control with your voice. Alexa is the voice service that powers the Echo and allows customers to interact with the device. As third-party developers, we can create apps or in this case, "skills" that users can download and interact with. One Alexa skill might help you find a good book—another might give you information about your favorite TV Show. The possibilities are endless!

Last time...

In the last tutorial, we started making a skill that tells you facts about a given Zodiac sign. With this skill, you would be able to say, "Tell me about Leos," and the echo would respond with "Leos are known to be proud, loyal, charismatic, and stylish" or something like that. You could also say, "Tell me about Virgos," and the echo would respond with a fact about people with the Virgo sign. Before jumping into the functionality of the application, we had to create the voice interface and interaction model for the skill. If you haven't done this yet, check out this tutorial, it goes into all the details of how to create it.

What is a Lambda Function?

The code that runs on AWS Lambda is called a “Lambda function.”
A Lambda function is triggered by events and in this case, the event is when the user talks to Alexa. The reason we choose to use AWS Lambda is because we do not have to maintain a server for our code - which is really awesome!

Creating the Lambda Function

To create our Lambda function, we'll start off by going to the AWS (Amazon Web Services) website. Once there, you should see a page like this.


Click Sign In to the Console and sign into your Amazon account. If this is your first time using Amazon services, there might be a few extra things to fill out, but once you are done, you'll be at your AWS dashboard.


From here, click Services in the left-hand corner and then select Lambda on the left.


Now, you'll be at your Lambda dashboard and you can click Create a Lambda function to start creating your function.

enter image description here

When creating your function, the first thing you will see are a bunch of blueprints. We'll select Blank Blueprint for now.

enter image description here

Next, you'll need to configure the event that triggers the Lambda function. In this case, it will be our Alexa Skill.

enter image description here

Once selected, your page should look like this:

enter image description here

Select Next and to configure our function. We'll call our function zodiacFunction and select Node.js 4.3 as our Runtime.

enter image description here

We'll ignore the Lambda function code for now and scroll down to the Lambda function handler and role. Our handler will stay the same at index.handler, but we will create a custom role for our role. From the drop down menu for Role, select Create a Custom Role.

enter image description here

After selecting Create a Custom Role, you should see this.

enter image description here

Go ahead and click Allow in the right hand corner and your updated Lambda function handler and role section should look like this:

enter image description here

When you're finished with all these, scroll down and click Next.

enter image description here

Review that all the values are correct, scroll down, and click Create Function.

enter image description here

Your function is now created and all set up! However, we are not done yet - we still need to write the code for this function. Right now, you should see something like this:

enter image description here

To get our code onto the Cloud, we'll write it locally using sublime, zip it up, and then upload it using the Upload a .Zip File code entry type.

enter image description here

Now we are ready to write the code for our Lambda function! In the next tutorial, we'll write the functionality for our skill in the Lambda function, upload it to the cloud, and test it with our interaction model. Check it out here.

Discover and read more posts from Kathryn Hodge
get started
Enjoy this post?

Leave a like and comment for Kathryn