Developing with Amazon Echo and Alexa

Aaron Baker


What is an Alexa Skill?

With the recent buzz around Amazon Echo and its’ voice-enabled virtual assistant Alexa, many developers are trying to harness the power of developing for Echo using Alexa Skills Kit (ASK). But what exactly is an Alexa skill? An Alexa Skill is essentially Echo’s version of an application. Using voice commands, users can call to various skills by asking Alexa to perform different tasks. As Amazon explains, their Alexa Skills Kit is “a collection of self-service APIs and tools that make it fast and easy for you to create new voice-driven capabilities for Alexa.”

In this piece, I will walk through how to achieve the Alexa app architecture (see our chart below) and dig into how to use AWS to set up your user registration.  


Necessary pieces for developing a basic Alexa Skill

Skill Creation in the Developer Console

If you haven’t already, you’ll want to familiarize yourself a little with the Amazon Developer Console - Amazon’s portal for creating and distributing apps for web and mobile, and in this case skills for Alexa. You can login through the consolse using an existing account if you choose, or create a new account to use for development. After entering the Alexa Skill dashboard, choose Apps & Services, and then in the sub-nav select Alexa to add the skill you’re working on. Throughout this process you will be returning a lot to create and iterate on your Intent Schema and Sample Utterances found in the Interaction Model tab and to use the Service Simulator in the Test section. However for now, let’s focus on the Intent Schema and Sample Utterances.

Tip: Keep in mind that once you’ve created your skill, you can move back and forth through each of the tabs along the left, you don’t necessarily have to complete one entirely to move onto the next.  

To describe the Intent Schema in terms of a Web API, you can essentially define the “model” that will be sent to each “endpoint”.  In this case, the “model” is a set of Slots, and the “endpoint” is an intent.  Here is an example schema:


This defines an intent called GetTemperature, which like a RESTful GET call, will simply return data - in this case the current temperature according to, say, a thermostat. The SetTemperature intent also includes a Slot (or a list of Slots with a single entry). We can see the Slot will be named “Temperature”, and it will be a number. This will be important for both creating utterances, and for handling this intent on the backend.

You will find Sample Utterances below the Intent Schema. These Utterances literally define the words that your user will speak to access different functionality within your app. Here are some sample Utterances for a thermostat app:


Tip: Keep in mind that the Utterance begins after one of several phrases the user could say to activate your skill.  For example if you skill is called “Thermostat”, the user could say: “Alexa, ask Thermostat to get the temperature”, or they could say, “Alexa, ask Thermostat get the temperature”.  The second example doesn’t sound as good, so we may also want to add “the temperature” as an utterance so the user can simply say: “Alexa, ask Thermostat the temperature” or “Alexa, ask Thermostat for the temperature”.

For more in-depth information on the Intent Schema and Utterances, check out Amazon’s own document on Defining the Voice Interface.

Alexa Skills Kit Service

There are two options for setting up your Alexa Skills Kit service: HTTPS or Lambda ARN (Amazon Resource Name). The quickest and easiest way is setting up an AWS Lambda function and providing it’s ARN to connect it to your Alexa Skill. I recommend using the “alexa-skills-kit-color-expert” blueprint when creating your Lambda function, as it gives you stubs for most or all of the events that your service can handle. As soon as this is created, you can plug it’s ARN into the Developer Console (under Skill Information there is an “Endpoint” field that accepts a Lambda ARN).

These are all the pieces that are required to get your Skill up and running. If you use the blueprint mentioned above, all you need to do is find the function “onIntent”, and replace it’s contents with a conditional statement to handle the intents that you have defined in the Developer Console.

Tip: Regardless of your approach, I recommend creating a Lambda function using that blueprint as a way to familiarize yourself with how to set up a service to handle a request from Alexa.

Adding user registration


The architecture that I will be describing to handle user registration relies on a few basic components. You would need at least: a login page, a privacy consent, a wb API, and a database. This can easily be achieved using a basic setup of a few Amazon AWS services.

Amazon S3

Amazon S3 is a very simple and quick solution for deploying a static website or single web page. You can use this to create a basic login page with the ability to submit data to an API (using angular, jQuery, or the native XMLHTTPRequest object in javascript), and you can also set up a simple page or upload a .pdf to link to for privacy consent.

Once you have a login page and privacy consent up, you will want to return to your skill in the Amazon Developer Console. On the Configuration tab, you will want to answer “Yes” to the first field, which asks if you want to allow users to create an account linking to an existing account.  This will allow you to specify an Authorization URL, which is the URL to your login page. You will also need to specify a Client ID, which can be used when you’re creating the authorization service to verify where the request is coming from.

Note: As soon as you choose “Yes”, the page will also update to indicate that a Privacy Policy URL is now required in the Usage & Privacy section of the page.

Elastic Beanstalk

The Elastic Beanstalk service can be used out-of-the-box to create an environment where you can deploy your web API. In the background, it handles management of EC2 instances, EBS drives (basically virtual disk space), and Elastic Load Balancing. All that you have to do once you’ve created this environment, is upload a .zip file with a basic Node or Java application to act as a web service. Depending on the complexity of your services, you may also consider a Lambda function here.

For the purposes of registration, all you would need is an endpoint for your login form to submit to. This endpoint would be responsible for saving whatever information you want about the user upon registration (e.g. email and password), and also for creating and storing the user’s Access Token in association with the rest of their data. The Access Token is created by the Authorization server (i.e. the endpoint), and returned to Amazon. This is essentially saying, “Amazon, when this user makes a request from their Alexa device, send me back this Access Token so I can look up their information”.

To return the Access Token back to Amazon, you will need to redirect the user back to a URL that Amazon has provided. This URL lives in the Amazon Developer Console. In your skill, under Configuration, there is a Redirect URL field. By redirecting the user back to this URL upon successful registration, and by including the access token in the redirect URL, you are completing the Account Linking process.

Tip: If you still have questions about Account Linking check out this document from Amazon, which dives into significantly more detail.

Where do you go from here?

So let’s say you have created your skill in the Amazon Developer Console and you’ve set up a Lambda function to handle requests from the skill. With just these two pieces, you are able to take in a command from the user, and from your Lambda function you can connect directly to an existing or brand new database of information to provide to the user, or you could call out to separate API’s (such as location or search engines, or an API that you develop yourself).

Furthermore with user registration enabled, you can store information about the user, or persist information if they ask you to. For example you could create an intent that will email a reminder to the user after a specified amount of time (by associating that reminder with the user’s email address and/or access token in the database).  

There’s a lot of flexibility and options when creating an Alexa Skill, but there’s also a lot of value and efficiency to this particular approach. I’ve used it successfully in production, as well as for several proof of concepts and demo skills to show our clients the value that Alexa could bring to them.

Are you ready to dig into the power of Alexa for your business? Download our guide on “The Power of Amazon’s Echo.”