#003 — Smart Home Skills: Linking Lambda functions

Anuj Deshpande
IoT Tidbits
Published in
3 min readMar 17, 2017

In this follow up post to #002, we will see how to associate an AWS Lambda function with a Smart Home Skill and test it using the mobile app and a simulator.

When we create a new Smart Home Skill, there is space for us to add mandatory information about an endpoint. As of March ’17, only one type of endpoint is supported, and that is an AWS Lambda function.

Configuration tab inside a Smart Home Skill

What is AWS Lambda?

A lambda function is a service for running managed functions. It means that I can write a simple function in one of the supported programming languages, and not worry about provisioning space for it on a virtual/physical machine. This function will have accept a JSON payload as input, where we can pass some variables. Of course, this being a regular function, we can write subroutines to fetch additional data, along with the provided input.

Simply put, it is a place where we write some code and never worry about the infrastructure it runs on. More about it here.

Why do we need an endpoint?

A Smart Home Skill is like an app that one would install on their phone, except that it resides *completely* on the cloud end, unlike smartphones. That means that when we invoke a command like —

  • turn on the kitchen light
  • set temperature to 25 degree Celsius

— there needs to be a 3rd party web service which will be responsible for taking the required action. In this case it will be sending a message to the connected bulb/thermostat to change it’s state.

Amazon Alexa/Smart Home Skills API doesn’t care which cloud service you use for your connected appliances. It could be on Azure, IBM Watson IoT or any other cloud provider.

Linking the Lambda function

When creating a Smart Home Skill, we will have to provide the ARN of the Lambda function that will be the end point for the skill in question. ARN is for a Lambda function can be found in the top right corner of the webpage.

Top right part is where the ARN of the Lambda will be mentioned

Make sure that you have created a function in the same region as your skill

  • N. Virginia aka us-east-1 for North American skills
  • EU Ireland aka eu-west-1 for UK/German skills

Once you have created a Lambda function, copy the ARN and paste it in the Endpoint section of the Smart Home Skill configuration page.

We also need to configure the possible triggers for the Lambda function. Just like each Lambda function has a unique ARN, each Alexa Skill has a unique Application ID that can be found on it’s Skill Information tab —

Application ID circled in green

Copy the ID from your Smart Home Skill and head to the Triggers tab in your Lambda function console —

Click Add trigger and you should be able to see possible triggers. Select Alexa Smart Home from that list and then paste the Application ID for your skill. Make sure that Enable trigger checkbox is ticked.

A configured trigger should look like this

Once you do that, we are done linking the end point to the voice app i.e. we have linked AWS Lambda to Alexa Smart Home Skill.

To receive updates, signup to our mailing list here !

--

--