The Amazon Echo is an amazing tool that utilizes AWS. These little speakers can play music, set alarms, search the internet, and much more. To extend the functionality of Echo’s and the Alexa platform, Amazon introduced Alexa skills.

What are Skills?

Skills are like apps on your phone or programs on your computer. They are designed to perform one or two basic functions very well. Some popular types of skills include trivia skills, podcast skills, and music skills.

Learning to Build a Skill

I wanted to learn how to build an Alexa Skill, so I decided to check out the A Cloud Guru Alexa skills course, Introduction to Alexa. This short course walks students through building three basic Alexa skills. I built the three skills featured in the course. Upon finishing this introductory course, I wanted to experiment with building my own custom skills.

Building the Intents

I decided to start by building a random facts skill focused on my hometown, Gaffney, SC. Amazon provides a Fact skill template to help developers. To start building my skill I visited the Alexa Developer console. I clicked “Create skill” and named the skill “Gaffney facts”. On the next page I chose the Fact skill template.

The Fact Skill template comes with several built-in intents, which makes it easier to build a skill. I mostly worked with the GetNewFactIntent when building this skill. This intent prompts the Lambda function to deliver a fact to the user. For the intent to work it needs several sample utterances. Utterances are examples of phrases the end user might say. I submitted five utterances that people might use to get a Gaffney fact, like “tell me a Gaffney fact”. After completing this step, I was reasonably confident that my intent would work.

Building the Lambda Function

After completing the intent building stage, I switched over to the Lambda section of the AWS console. I clicked create a function and then clicked on Browse serverless app repository. The first function available in the serverless app repository is the alexa-skills-kit-nodejs-factskill. I clicked on it and clicked deploy. The deploying took about a minute. Once the Lambda function was deployed, I copied the ARN from the top of the page. The ARN is necessary to connect the Lambda function to the Alexa skill. I opened the Alexa developer console and clicked “build” on my Gaffney Facts skill. I then clicked “Endpoint” on the left side of the console. I chose AWS Lambda ARN, and in my default region I pasted the ARN. Above the box there was a Skill ID, which I copied to my clipboard. Next, I jumped back to the Lambda function. On the left side of the Lambda function there is a menu that allows you to add triggers. I clicked on Alexa Skills Kit, and scrolled down to the Configure Triggers menu. When prompted to Enable Skill ID verification, I pasted my Skill ID into the Skill ID blank and clicked Add. With that step completed my Alexa Skill and my Lambda function were connected. It was time to edit the Lambda function and customize my skill.

This Lambda function is written in node.js, which I had limited experience working with, but the code is easy to read. I scrolled until I saw a line of code called const data. This line is followed by brackets and 10 different space facts within single quotes. When Lambda delivers a fact to your Alexa skill, it randomly chooses a fact from this group and delivers it to Alexa. This part of the code can be edited without breaking the function. I found 30 facts about my hometown and inserted them into the brackets, making sure to put each new fact into quotation marks and put a comma after each fact.

Putting everything together

After putting the facts into my skill, I published the new version of the Lambda function and jumped over to the Alexa Developer Console. I saved the model and clicked “Build Model”. After a few minutes the skill was built and ready to be tested. The test section takes you to an Alexa simulator. I invoked the skill and waited for a response. The test was successful, so I moved on to the publication stage.

Publishing the Skill

Publishing skills is a relatively easy process. First, I clicked “Distribution” at the top of the console, which took me to the Skill Preview. I gave my skill a name, “Gaffney Facts”. Next, I entered a One Sentence Description and a Detailed Description. I provided several Example phrases, such as “Alexa, give me a Gaffney Fact”. Then, I added a Small skill Icon and a Large skill icon using pictures from my hometown. Finally, Alexa requires you to pick a category for your skill. I choose Education & Reference because the skill helps teach people about my small town.

Now that the distribution was complete it was time to get my skill certified. The Certification step is a three-step process. I first ran a Validation test, which confirmed that my Interaction Model was built properly. Then, I ran a functional test on the skill. This test checks for common errors in the code. My code passed the functional test, so I then moved on to the final step, “Submission”. I quickly described the skill and what it can do, then sent it to Amazon for approval.

The “Submission” step can be tricky. Amazon carefully checks each Alexa skill to make sure it works perfectly. When I first submitted my skill for review, I received a response in about 12 hours. My skill failed the first review because my example phrase didn’t contain my exact skill name. I typed “Alexa, give me a Gaffney fact”, when Alexa expected “Alexa, give me Gaffney facts”. This is an easy error to fix, so I quickly went back and rectified the situation. I resubmitted the skill and it was published the next day.

Creating an Alexa skill is a surprisingly simple process. Amazon makes it easy to get started, and the fact skills template includes easy to read and alter code. I enjoyed this process, and I quickly jumped into creating my next skill. I highly recommend using Amazon’s initial templates and taking an Intro to Alexa class, so that you can follow along while you build the skill. A Cloud Guru offers a great class, but there are others on Youtube. If you’d like to talk to me about building a skill or any obstacles I might have faced feel free to message me. I’m always happy to talk.