Early bird prices are coming to an end soon... ⏰ Grab your tickets before January 17

This article was published on October 5, 2020

Alexa, teach me how to teach you


Alexa, teach me how to teach you Image by: Unsplash: Andres Urena

Alexa, amazon’s voice-based virtual assistance like Siri for the iPhone, and Cortana for Microsoft Windows, is a cloud-based service. When first introduced, it was in the form of ‘Amazon Echo.’ Fast forward and this voice assistant is now part of multiple devices including: music devices, robots, mobile phones, vacuum cleaners, among other things. Its skills are voice-driven and the interface between users and Alexa is called ‘Skills.’

Creating Alexa skills

Alexa skills are built by two different components:

  • The voice controls or actions
  • The functionality

In this article we’ll evaluate how to set up both, starting with the functionality.

The functionality is simply some code that will be executed when Alexa is tasked with our custom actions (or skill). This code for our purposes will run on AWS Lambda, a service matching perfectly with Alexa, it’s cost-efficient and super easy to set up.

Here are all the steps we need to take into account when building an Alexa skill:

  1. Set Up AWS (Amazon Web Services) Lambda
  2. Create a free Alexa Developer Account
  3. Create a sample of Alexa Skill
  4. Test the newly created Alexa skill

So let’s start with the first step:

Setting up an AWS (Amazon Web Services) Lambda

  1. Go to the Amazon Web Services management console and create a new account if you don’t have one already. Click on the “Complete Sign Up” button.

  1. After adding the appropriate data in all the required fields, login to the AWS management console. Keep in mind that AWS is a paid service, though they offer a trial period of 1 year with certain limitations, but it’s more than enough for what we want to do.
  2. After the successful login, the AWS management console dashboard will be displayed to you.
  3. Different web based services are available of AWS portal. From the find services list, search for the “Lambda” service. Select the “Lambda” service.

  1. Lambda service only works in the US East (N. Virginia), EU (Ireland), US West (Oregon), and Asia Pacific (Tokyo). Make sure to choose one of the given regions before creating the Lambda service.
  2. After choosing the “Lambda” service you will be redirected to the Functions screen. Choose the “Create function” option.

  1. Click on the “Use a blueprint” option and search for the “Alexa-skills-kit-color-expert-python”.

It’s worth noting we’ll use a blueprint for sample, a blueprint is an already developed sample which can be easily added to your AWS lambda account. If you want to build your own skills, you can either program the lambda yourself, or use the blueprint and update it to your needs.

There are blueprints for Python, NodeJS and other programming languages, in our case we will use one based off Python, though we will ignore the code for this tutorial and focus more on the Alexa side of things.

  1. If the results are not displayed under the “Use a blueprint” section, then select the third option “Browse serverless app repository” and search for the “Alexa-skills-kit-color-expert-python.”

  1. Now enter the “TopicNameParameter” and click on the “Deploy” button.

  1. Now click on the “Logical ID” text.

  1. The function code will be displayed to you. Copy the “ARN” code displayed to you on the “top right corner”.

Creating your free Alexa Developer Account

Now we have to create an Alexa Developer Account. Go to the Amazon developer portal and create an account if you don’t have an account already. While creating the new account, add the appropriate data in all required fields.

Just sign in to the Amazon developer portal if you have signed up already.

Create a sample of Alexa Skill

Here is where we build the actual Alexa interface, that is how we’re going to talk to Alexa to solve our problems and communicate with our Lambda function.

Follow all these steps carefully:

  1. Now choose the “Alexa” option from the dashboard and select “Alexa Skills Kit.” You will be redirected to the “Alexa developer console.”

  1. Click on the “Create Skill” button.

  1. Enter the skill name, choose the language, and click on the “Create Skill” option.

The skill name can be anything you want, keep it meaningful to what you are trying to achieve. But don’t confuse the name with the phrase you will use to invoke Alexa to perform the task. The name is only for your reference.

  1. Enter the skill invocation name. This is what you will have to say to Alexa when communicating with your skill.

  1. On the Alexa skill dashboard, you will the list of your created skills. Click on “MyBookSkill.”

  1. Take a look at the sample intents to understand how you can create your own intents.

With the invocation name you told Alexa to “talk” to your program, now intents, will tell your program exactly what procedure to execute. They can be anything your program can perform, like “find a book”, or “read Live Code Stream.”

  1. For creating your own intent, click on the “Add Intent ” button.

  1. Enter the name of intent and then enter the utterances.

  1. Now choose the slots type from the left menu and click on “Add slot type.”

Slots allow you to create lists of possible values, IDs and synonyms. Often times they’re generated by code, but for now we’ll set them up manually.

  1. Enter the name of the slot type. I have entered here “BOOK_TYPE”, and after that enter the values.

  1. Enter all the values and then click on the “Build model.”

  1. Now click on the endpoint section from the left menu and enter the Lamba ARN value.

  1. After entering the ARN value, click on the “Save endpoints” option.

Alexa skill is now successfully created.

Test the newly created Alexa skill

After the implementation of the Alexa skill, we have to test it. The testing verifies the either we’re achieving our desired results or not?

We can test the Alexa skill in many ways:

  • We can deploy the Alexa skill on Amazon devices i.e. Amazon Echo Dot, Amazon Echo, or on any other device which supports the deployment of Alexa.
  • We can test the Alexa skill by using the simulator. Just say the skill invocation name that you have written while creating the Alexa skill.

This is the fun part, so enjoy it.

Alexa, and voice assistants in general are here to stay, and the success of your product or services may be limited by the integration that these systems will present in the future.

So grab yourself some time and take a look into the endless possibilities these assistants give to users and developers alike.


This article was originally published on Live Code Stream by Juan Cruz Martinez (twitter: @bajcmartinez), founder and publisher of Live Code Stream, entrepreneur, developer, author, speaker, and doer of things.

Live Code Stream is also available as a free weekly newsletter. Sign up for updates on everything related to programming, AI, and computer science in general.

Get the TNW newsletter

Get the most important tech news in your inbox each week.

Also tagged with