Create your first Alexa Smart Home Skill – Part 1/3

In this tutorial, we will learn how to create your first Alexa Smart Home skill. Before we get into the details, here are a few pre-requisites:

  1. You should have an AWS Account with access to lambda functions
  2. You should have an OAuth2.0 service for authenticating the users of your smart platform. You can use Amazon Cognito, if you don’t already have one.
  3. You should have a way of fetching the devices linked to a user from the Access token provided by the Alexa skill to your lambda function. You can fetch the user_id from the access token and then perhaps fetch the devices linked to that user_id from a database.

Scope of this tutorial

Since the purpose of this article is to focus more on the method of creating the skill, rather than focusing on the capabilities of the skill (which can be different for each application), we will be adding only the Power capability (i.e., the ability to switch your devices ON or OFF) to our skill. You can think of this skill as one created for controlling a smart switch. Of course, using the method and references from this series of articles, you can very well go ahead and create your own complex skills with multiple capabilities.

This tutorial is divided into 3 articles. Here’s what each article will cover:

Part 1: Understanding Alexa Smart Home Skills, creating a new skill on the Alexa console, and setting up Account Linking

Part 2: Creating the lambda function and linking it to your skill

Part 3: Testing the skill, beta testing, and adding other developers

Without further ado, let’s get started.

Alexa Smart Home Skills Overview

Smart Home Skills are a specific subset of Alexa skills, wherein you need not develop the voice model. In a Custom Alexa skill, you have to define all the utterances that a user would typically use to invoke and interact with your skill. In Smart Home skills, you offload that burden to Alexa. All you need to do is define that capabilities that your device has, and the allowed friendly names for those capabilities, and you are done. Alexa then does the interpretation of the command by itself.

For instance, if you had a smart light with the ability to turn ON/OFF, and change brightness, then you’d only have to specify that the light supports these capabilities. The interpretation of the voice command will then be handled by Alexa. Thus, the user can say, “Increase brightness” or “Set brightness to 50%” or “Dim the light” or “Lower the brightness” or “Make the light brighter” or any other brightness related command, and Alexa will interpret and send the appropriate directive to your endpoint. All this just because you told Alexa that the light supports brightness control. Imagine the hassle you’d have to go through if you had to define the utterances for each of these variations.

Creating a new skill

Now that we understand what Alexa Smart Home skills are, let’s head on to the Alexa developer console.

  • Click on the ‘Create Skill’ button.
  • In the next screen, provide a name to your skill, and also the primary locale. I’ll name it ‘My Smart Home Skill’ and provide the locale as ‘English (IN)’. Then click on ‘Next’
  • For the type of experience, select ‘Smart home’, and for model, select ‘Smart Home’. We are essentially telling Alexa that we will use its Smart Home model, and not develop a custom voice model ourselves.
  • Leave the Hosting service option to the default (Provision your own).
  • Review the model, and then click on ‘Create Skill’.

Congratulations, your skill is created. Now, we need to set it up.

Setting up Account Linking

For setting up Account Linking, you need an OAuth2.0 based authentication service. We will consider Amazon Cognito for this example, but you can use any other service as well. You will require a user pool in Cognito, along with an app client created for Alexa. For creating a user pool, you can follow the tutorial here.

The steps for creating an app client can be found here. Make sure to create a client secret for this app client. For Authentication Flows, select ALLOW_REFRESH_TOKEN_AUTH. For the allowed callback URLs, mention the following three (you can find the vendor ID here):<your_alexa_vendor_id><your_alexa_vendor_id><your_alexa_vendor_id>

For OAuth Grant Types, select Authorization code grant. For OpenID Connect Scopes, select aws.cognito.signin.user.admin, openid, profile.

Once your app client is created, note down the client id and client secret. Also, note down the domain of your Cognito hosted UI. If you do not have a custom domain configured, it will typically be <custom_prefix>.auth.<region>

Next, head on to the account linking section of your skill on Alexa Developer Console. Fill in the details as follows:

  1. For Web Authorization URI, enter https://<your_cognito_hosted_ui_domain>/oauth2/authorize?redirect_url=<your_alexa_vendor_id>
  2. For Access Token URI, enter https://<your_cognito_hosted_ui_domain>/oauth2/token
  3. For Client ID, enter the ID noted after creating the app client for Alexa above
  4. For Client Secret again, enter the secret noted after creating the app client for Alexa above
  5. For Authentication Scheme, select the HTTP Basic scheme.
  6. For domain list, enter <your_cognito_hosted_ui_domain>
  7. For scope, enter openid, profile, aws.cognito.signin.user.admin
  8. You can leave the Default Access Token Expiration Time blank

Save the changes. Congratulations, you’ve configured Account Linking for your Alexa Skill. Stay tuned for the next part for the lambda function creation for linking to your skill.

I hope you liked this article. For more tutorials on AWS, check out

Leave a comment

Your email address will not be published. Required fields are marked *