Introduction: A Guide to Learning and Understanding the Alexa Skills Kit

Picture of A Guide to Learning and Understanding the Alexa Skills Kit

Most of you have probably heard of Amazon Alexa, and for many, it is extremely useful. On the other hand, there are very few "Apps" or as Amazon calls them, "Skills" that are available to the consumer that actually serve a useful purpose. Of course there are some, like the Phillips Hue Skill and the Nest Thermostat Skill, which can connect to various smart devices in your home, but for the most part, the Skills that are available showcase the potential of Alexa, and not much more. To the average person, the prospect of writing a skill from scratch is daunting, but in this Instructable, I hope to accomplish two things:

The first of these is obviously to guide you through the process of writing and using a custom Alexa Skill, and the second is to ensure that you have a resource to help you later on in your development journey. We will do this by creating a Skill that serves as a reference guide for knowledge of all things Alexa, so that whenever you feel like you need to understand a topic better, all you have to do is ask. If you don't have an Alexa device, you can still do this! If you go to echosim.io you can find an Echo simulator to use. In the off chance that you just want the resource but can't put in the time to make the skill yourself, I'll be putting a link here once I get my version of the Skill published so that you can enable my Skill in your Alexa App. (It will receive updates and things like that, so you may want to do that anyway!)

That's all I have to say, so get ready to jump in headfirst and move on to the next step!

A couple notes: All of these pictures are either screenshots from my computer, or photos that I have taken, while I did not develop any of this software, every piece of media in this Instructable is my own.

EDIT: For whatever reason, some of the code I uploaded did not work. I have updated it completely so that it should function as intended, and be certified with no problems. I have submitted my Skill to be certified, and I highly suggest that you do too because the giveaway this month is an Echo Dot!

Step 1: Create Your Accounts

Picture of Create Your Accounts

To begin, we need to create a few accounts. These will give you access to the powerful resources of Amazon Web Services (AWS) and those of an Amazon Developer. The accounts are free, and if you have an Amazon account already most of the setup is already done, but the AWS setup does require that you enter a credit card for billing purposes. For our purposes, you will never be charged, because the usage should fall into the free tier. (We are using a service that runs code in the cloud, and under the free tier, you get 1 million requests per month, so better start rationing!)

To create your account, go to https://aws.amazon.com/ and click "Create a Free Account"

You will now be asked to fill in some details and enter a PIN through a phone call to sign up.

Next, we need to create an Amazon Developer Account. This is also free, but does not require a credit card.

To create this account, go to https://developer.amazon.com and click "Sign In"

Now enter the Email and Password you entered in the last step (This may be your Amazon Account details, if you already had one), and enter the rest of the information it requests.

Now that we have our accounts in order, we can begin the actual setup.

Step 2: Initial Skill Setup

Picture of Initial Skill Setup

Now that you have an Amazon Developer account, go ahead and log in. You will be brought to a dashboard, which displays information and statistics related to your account. In the menu bar, there is a button that reads "Alexa". Click on it. Now, you are at the Alexa dashboard, and have two options. These are the Alexa Skills Kit and Alexa Voice Services. Alexa Voice Services are useful if you are trying to build a device with Alexa integration, or even just for a personal project like AlexaPi, on the other hand, the Alexa Skills Kit contains the resources necessary to write and deploy a Skill. Obviously, we are trying to write a skill, so click on the "Get Started" button below the Alexa Skills Kit. At this point, you will see a dashboard that is pretty much empty, but will hopefully fill up as you learn and publish more Skills. Click "Add a New Skill" to move forward.

Now we begin to set up our Skill. In the example that I have written, we can see that I have titled the Skill "Alexa Development Tips", with an invocation name of "development tips". Essentially what this means is that the Skill will be listed a "Alexa Development Tips" in the Skills Store, and can be called upon by saying something like "Alexa, ask development tips..." As you set up this information for the demo Skill, keep in mind that I will be publishing the final Skill under the name I mentioned previously, so that others can enable it without the pressure of building the skill from scratch. If you are planning on publishing your Skill, which you should because you get a free T-Shirt (more on that near the end), it would be great if you could choose a different name for your Skill, something like "Unofficial Alexa Development Tips" because my Skill will always be the most up-to-date and I would hate to have people receiving outdated information because there were too many Skills with the same name.

Step 3: Set Up the Interaction Model

Picture of Set Up the Interaction Model

Now click on the "Interaction Model" tab. The first area that we will need to edit is the Intent Schema. This section essentially determines how your request is fulfilled by defining what the Skill is to do if it determines the intent to cancel the request, stop the request, repeat something, fulfill the request, or ask for help. To set this up, simply download the attached files, and copy the contents of "intentschema.txt" into this section.

Next, open "slot_types.txt" and copy the contents into the "Enter Values" area of the "Custom Slot Types" section. For the title of the type, enter "LIST_OF_ITEMS" without the quotation marks. This section essentially determines the options for the code, if that makes any sense. For instance, you might ask the Skill a question, and it uses the slot to determine what you are asking about. Let's say you asked "Alexa, what is an Amazon Echo?" the slot on that situation is Amazon Echo, and thee code will use that to determine how to answer. (This will make a lot more sense after you complete the final section)

Lastly, open "utterances.txt" and copy the contents into the "Sample Utterances" section. This is pretty much a list of ALL the possible ways you could ask the skill a question, so if you look through the list and feel like you might ask differently, add it, because the Skill will not respond otherwise. If you follow the pattern this will make sense (Starts with RequestIntent, {item} is the specific example...). To better explain the other section, the utterances tell the Skill how it will be asked a question. For example, you can ask the question "Alexa, what is an Amazon Echo?" a couple of different ways, so you must account for that in the code. Looking at these utterances, you can see that the specific part of the question is {item}, this makes sense, when you realize that the code will interpret the question and use the word in the SLOT {item} to answer. If that didn't make sense, leave a comment and I'll reword that last section.

Step 4: Set Up the Lambda Function

Picture of Set Up the Lambda Function

At this point, we have to edit and add the code for the Lambda Function. The best way to do this is to log in to your Amazon Web Services account and begin to setup the function. Now, navigate to this link. You should see the "Configure Triggers" page. Select the Alexa Skills Kit by clicking on the empty box. Do not change the region at any time, as the location contained in the link (N. Virginia) is one of the only regions that is able to serve requests from the ASK.

Click "Next". Now download the file that I have uploaded to this step, if you haven't already. This contains the code necessary to run our Skill, but we need to make one quick change after you upload it to AWS. Once you download the file, all you have to do is get it uploaded to AWS. Look at the Lambda page. In the first section, you can give the function a name and description. Do not change the runtime. I called mine "DevelopmentTips", and put "Code for ASK Tips" in the description. In the section directly below, click on the dropdown titled "Code entry type", and click "Upload a .ZIP file". Now click the "Upload" button and find the .ZIP archive you just downloaded.

If you're curious, I would highly reccomend unzipping the archive and looking at the code, just to get an understanding of how it all works, and what you can do with it later.

Once the upload is complete, we have to set the function handler and role. The default handler, "index.handler" is fine, but we need to set the role. Open the "Role" dropdown and click "Create a Custom Role". A new tab will open, there is nothing to configure, and you can click "Allow"

Finally, click "Next" at the bottom of the page. At the review screen that pops up, check to make sure that everything is correct, and click "Create Function" .

Now look at the dashboard that you have been brought to. If you click on the tab titled "Code" and look at the code, you will see this at line 16:

  • var APP_ID = undefined; // TODO replace with your app ID

Replace "undefined" with your App ID enclosed with apostrophes ('like this'), which can be found in the header of your Skill Setup page, or in the Skill Information tab of the same page. (This is back in the Alexa Developer tab)

The last thing to do is to copy the ARN that appears in the top right of the Lambda dashboard to link this function to the Alexa Sills Kit.

Step 5: Link the Function to the Skill

Picture of Link the Function to the Skill

To link the function, open the "Configuration" tab for your skill. In the "Service Endpoint Type" area select the option titled "AWS Lambda ARN (Amazon Resource Name)", now check the box titled "North America", and paste the ARN from the previous step into the box that appears below. At this point, all the heavy lifting is over, and your Skill is just about complete. All that is left to do at this point is to test and publish it.

Step 6: Wrap Up

Picture of Wrap Up

At this point you are just about done. Click on the "Test" tab, and you should be able to scroll down and test your Skill by typing in inputs. If you can do this, then you will also be able to test your skill through an Alexa enabled device by enabling the Skill in the Alexa App. This can be done by going to the menu, clicking "Skills", and the "My Skills" at the top. Find the name of your skill and click enable. It is now usable through Alexa devices on your account. If you don't have an Alexa "device" don't worry (I don't), go to this website to find a free Echo simulator that you can use in your browser. Once you've had your fun, and are satisfied that everything works, click on the "Publishing Information" tab. Fill in all the required information as you wish, I categorized mine as "Reference and Education", and just filled everything else in as accurately as I could. Once complete, click "Save" and move on to the "Privacy and Compliance" tab. Click "No" to all, and then check the box under "Export Compliance", you don't need any of the URL's. Now click "Save" and you should see all green check marks along the side. If you do, go ahead and click "Submit for Certification". This will tell the Amazon team to go ahead and review your Skill, so that it can be published in the Skill store for anyone to see and use. Pretty cool, right! I should also mention that Amazon gives away T-Shirts to anybody who publishes Skills in the US, UK, and Germany, so fill out the form at this link and get developing! They change the shirt every month, and sometimes give away hoodies!

Step 7: Final Thoughts

Picture of Final Thoughts

Congratulations! You have now created your first Skill, complete with a custom interaction model, as well as integration into a Lambda function! In doing so you created an impressive resource for your later developing endeavors, and you will be able to call upon it at any time using Alexa! I am going to publish the "finished" Skill so that those who want the resource but do not have the time can still use it, and I have included a link to a Google Forms survey so that if you feel like I missed ANY terms and definitions, as well as other general comments, I can get that feedback and apply it to the Skill.

In addition, I would highly recommend taking a good look at the code contained in the ZIP file, it is relatively straightforward, and you can even use it as a base for future projects. I use a text editor called Atom, and it's pretty cool because it will identify that you are writing in JavaScript and highlight the code accordingly (most other text editors do this too, but Atom has some great features on top of that).

Lastly, don't be afraid to try things, check out the documentation for Alexa, and try out some of Amazon's tutorials. They are a great jumping-off point and I think you will find that they are a great way to advance your knowledge.

Important:

As always, if you experience any issues with the code, let me know. Also, I created this Instructable to enter into the IOT contest, as a submission for the Judge's Prize. I think that this project does a pretty good job of explaining the Alexa Skills Kit and the process of creating a Skill, and by guiding the viewer through the creation of a Skill that they can use as a reference guide at any time during their developing journey, I feel like it really accomplished two pretty big goals in a very unique way. If you liked it, maybe consider dropping a vote in the hat for me, I'd really appreciate it!

Comments

FlyingHazard (author)2017-06-02

If you make a skill in the month of June you qualify for an Echo Dot! Get developing!

About This Instructable

596views

26favorites

License:

Bio: FPV Pilot, RC Fanatic, broken NextCloud Server too many times to count. Latest projects include whole home audio system based on Forked-DAAPD and Shairport-Sync as ... More »
Add instructable to: