How to Create your first Alexa Skill & get Free Swags!! [TUTORIAL]

Apoorv Lathey
6 min readSep 7, 2019

--

Past Alexa Swags offered by Amazon

After I got my Alexa Swags (T-Shirts and Sipper), I was asked countless times by my fellow developers and friends how I got those, so here is a simple to follow step by step tutorial.

Amazon provides incentives to Alexa Skill Developers in the form of Developer Perks which vary each month from T-Shirts, Sippers, Amazon Gift Cards to a Play Station 4! You may read about their current promotion Here.

Most of you would be knowing about Amazon’s voice-assistant Alexa, but what are Alexa Skills? Well, they are the custom apps built for Alexa by developers to provide additional features to your Alexa device. They vary in a wide variety from Games to Music to even Fitness.

In this guide, I will be teaching you how to create your very own Quiz Skill from scratch. Follow along!

STEP 1:
First of all, create/log in to your Amazon Developer Account HERE.

STEP 2:
Click on “CREATE SKILL” on the right side.

STEP 3:

  • Fill out the Skill name. For this tutorial, I would be using “Windows Facts”.
  • To be eligible for Developer Perks, choose the language as English(IN).
  • Scroll down and make sure “Custom” is selected under “Choose a model to add to your skill”.
  • Scroll further down and select “Alexa-Hosted (Node.js)” as a method to host your skill.

STEP 4:

In the left column if English(IN) is not selected, click on the dropdown, click Language settings, and Add a new Language then English(IN). Now choose it from the left dropdown.

STEP 5:
Go back to the custom tab.
Now, we would be setting the Invocation Name for our Alexa Skill.
The Invocation Name is like an app name, which would be used to call our skill by Alexa.

  • Go to the Invocation tab from left sidebar and input your invocation name, then press Save Model at the top.

STEP 6:
The intents are actions that fulfill the spoken requests from the user. Every intent has at least one utterance, a predefined word, phrase, or sentence which the user might say to invoke the intent.

  • Go to the Intents tab. You can see that there a lot of built-in intents.
    We would be creating “FactsIntent” to respond to the user with a random Fact when invoked.
  • Click on:

and type “FactsIntent”.

Sample Utterances are the statements that the user might use to invoke our particular intent.
We don’t need to provide each and every statement, just a few would do the work as Alexa’s A.I. would train on this data and respond to similar queries.

Sample Utterances List
  • Save then Build the Model.

It’s Time To Write Some Code!

  • Scroll down to “LaunchRequestHandler”

What this code does is that when your skill is called, LaunchRequest intent gets invoked. It is one of the intents generated by default.

The canHandle function checks for whether this intent is invoked or not.
The handle function is executed to respond back to the user.

Change the value of speakOutput so that your skill greets the user in a personal way.
This is the string that would be converted to speech by Alexa.

Here’s how my code looks:

Create a new file and name it “factsList.json”. This would be the file from where we would be randomly selecting the facts.

Paste the following code into the file. Replace Fact1, Fact2, … with the actual facts!

Now head back to index.js. On the top add the following:
const factsList = require('./factsList.json');

We would be writing code for the FactsIntentHandler :

This is similar to the LaunchRequestHandler that we saw earlier, here just the speakOutput is being dynamically generated by randomly selecting a string (Fact) from factsList.json.

One last step is to add our newly created FactsIntentHandler to the exports.handler.
For that, scroll down to the last line in index.js and add FactsIntentHandler to the list.

Your code must now look like this :

Editing HelpIntentHandler so your Skills doesn’t get rejected:
After editing its speakOutput, the code should look like this:

Save and Deploy both the files to proceed further

The Difficult part is Over!

Test & Interact with your Alexa Skill

Head over to the Test section and enable Development for your skill.

Testing our Skill

Chat with your newly creates Alexa Skill!

Speak/Type: “Alexa, open <your skill’s invocation name>”

If everything works fine, you are (almost) ready to publish your Skill.

  • Go to the Distribution section and fill out all the mandatory fields. You would also be required to upload an icon for your skill.
  • Make sure to correctly specify the Example phrase!
  • Similarly, fill out Privacy & Compliance.

In the Availability tab, Select INDIA under:

(Refer to this link, to learn more about Swags in various countries and the Terms and Conditions that apply.)

We do this in order to be eligible for the Promotional Perks.

Under the Certification section, Run Validation and Functional Test. If there is an error with your skill or any field left empty, you would be notified.

Finally, Submit your Skill for Review.

Hurray !! You just finished creating your very own custom Alexa skill!

Note: It takes around 2 days to get your skill published. If there are some problems with your skill, you would be notified via email. Correct them and submit again. The mails usually have a detailed description of what you missed out and how to reproduce the same error.

Apply for Developer Perks

After successfully launching your skill on the Amazon Store, you need to fill out the form present on the website: https://developer.amazon.com/alexa-skills-kit/alexa-developer-skill-promotion-india (scroll down).

You can get the skill id from here: https://developer.amazon.com/alexa/console/ask

View Skill ID

That’s it for the beginner tutorial to get you started! There’s a lot more to explore like APL to display on Echo Show devices, playing custom sound recordings, using Alexa Skills Kit (ASK), etc.

For any queries, reach out to me in the comments below and share this post with your fellow developers 😉

Update: As for the month of October, Amazon is even offering a brand new PS4 for creating the most used Alexa Skill!

Originally published at https://apoorvlathey.com on September 7, 2019.

--

--