Building your own Amazon Alexa Skill !!

                              Amazon_Alexa_Logo

It will be really great if you could control all your apps like your news feeds, score updates, etc with your voice. Amazon Alexa can help you achieve that.
Alexa is an intelligent personal assistant developed by Amazon, first used in the Amazon Echo and the Amazon Echo Dot devices developed by Amazon Lab126.

So just like any open source project, alexa also wanted developer’s around the world to help them innovate & develop awesome alexa skills. So, they have launched various program (which are rewarding :P) , so that developers around the world can showcase their creativity & tech skills to develop awesome alexa skills.
Link to program.

Recently, I also developed a skill. The skill is named as “Crypto Updater” (link).The skill basically tells user about latest price of crpto coins like bitcoin, ripple, litecoin, etc prices in US dollars.

The blog is basically about how to create your own custom alexa skill. So, let’s get started.

Steps :-
1.) make an amazon developer account (link).
2.) go to developer’s console and select Alexa.
3.) a list of your alexa skills will be shown here. Select “Add new skill”.
4.) here, there will be 5 different sections.
–> Skill Information
–> Interaction Model
–> Test
–> Publishing Information
–> Privacy & Compliance

Skill Information : here, you have to fill basic information like name of skill, Invocation Name, language, etc.

Interaction Model
: It is the place where all the magic happens :
a.) Intents : they are like name of the functions which will be called when you speak some particular sentences to Alexa.
b.) Utterances : now for each Intent name you have to define sample sentences or phrases which will help Alexa to understand which Intent to call.
c.) Slots : they are like variables which will get assigned to values specified by user who is using the skill.

So, for my skill I created two intents :-
–> intro : it will handle introduction of my skill like what it does , how to start, etc.
–> price_coin : this intent will handle all the logic when user asks about a coin price.

Now, after this I defined sample_utterances for each intent. For example, utterances for “intro” intent are like :
–> open {invocation_name},
–> launch {invocation_name}.
Similarly, utterances for “price_coin” intent are like:
–> “tell me latest price of {coin}”
–> “{coin} price”
here, {coin} can vary according to different coin name. So, here we will use slots which are like pre-defined values which that variable (coin in this case) can have. I have defined values of {coin} slot as name of 20 different crypto coins.

Finally, after defining these 3 properties, we have to write logic of each Intent. The logic will be written in AWS lambda function, i.e the code which will be executed when a particular intent is called. First, you have to make account on Amazon AWS portal, there in lambda section create your own lambda function using pre-defined Alexa template, which will write most of the boiler-plate code. You have to just focus on main logic of Intent. Sample of my lambda function.

Your lambda function will have an ARN number, in order to link your Alexa skill with your Lambda function, you have to insert this ARN id in “Configuration” section.
Note :- make sure you are in US East (N. Virginia) or EU (Ireland) region while creating your lambda function.

Test : You are almost done. Go to “test” section & test your skill response by typing different sample utterances for your Intent and check the response.

Publishing Information : Finally, go to “Publishing Information” section & fill out some description about skill.

At the end, apply for certification. Now, Alexa people will test & verify your skill on their standards , if your skill is lacking somewhere they will mail you the details within 1 or 2 days. Finally, if skill your is passed, it will be available in Amazon Alexa Skill Store and to alexa users.

Hope you will also come up with a great Skill.
Happy Hacking 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.