(TUTORIAL) How to make Your First Alexa Skill | Get Free T-Shirt !!

Alexa Developer Perks

I was requested for this post countless times soon after I received my developer perks from Amazon, for developing an Alexa Skill. In this tutorial, I would be teaching you how to get started with building your custom Alexa skills. (Note: A little coding knowledge is required.)

Get to know about developer perks here: https://developer.amazon.com/alexa-skills-kit/alexa-developer-skill-promotion-india

First off all create/log in to your Amazon Developer Account HERE.

Click on “CREATE SKILL” on the right side.

• 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.

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.

Go back to the custom tab.
Now, we would be setting the Invocation Name for our Alexa Skill.
The Invocation name is like 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 on top.

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

Save and Build the Model.

Time to Write Some Code !

Head over to “Code” Section

• 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:

const HelloWorldIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
            && Alexa.getIntentName(handlerInput.requestEnvelope) === 'HelloWorldIntent';
    handle(handlerInput) {
        const speakOutput = 'Hello there! If you want to hear facts regarding Windows, say Facts.';
        return handlerInput.responseBuilder
            //.reprompt('add a reprompt if you want to keep the session open for the user to respond')

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 !

    "facts" :[
                "text" : "Fact1"
                "text" : "Fact2"
                "text" : "Fact3"
                "text" : "Fact4"

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 :

const FactsIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
            && Alexa.getIntentName(handlerInput.requestEnvelope) === 'FactsIntent';
    handle(handlerInput) {
        var random = factsList.facts[Math.floor(Math.random() * factsList.facts.length)]; //select a random fact from json file
        var factText = random.text;
        var speakOutput = "Did you know that " + factText;
        return handlerInput.responseBuilder
            //.reprompt('add a reprompt if you want to keep the session open for the user to respond')

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 :

exports.handler = Alexa.SkillBuilders.custom()
        FactsIntentHandler,     //your custom intent
        IntentReflectorHandler, // make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers

** Also EDIT HelpIntentHandler or else your Skills would get rejected ! **
After editing its speakOutput, the code should look like this:

const HelpIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
            && Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.HelpIntent';
    handle(handlerInput) {
        const speakOutput = 'To know about the facts, just say Facts'; //just edit this

        return handlerInput.responseBuilder

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.

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 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:

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

Under Certification section, Run Validation and Functional Test. If there is any 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 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!