Developing Amazon Alexa Skills

The objective of this article is to explain what is Amazon Alexa, Alexa skills, how to build those skills. This article is intended for those who are interested in learning Alexa skill building and those who have some understanding of amazon lambda, NodeJs etc.

What is Amazon Alexa?
Let’s look at what Wikipedia has to say about Alexa. 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. It is capable of voice interaction, music playback, making to-do lists, setting alarms, streaming podcasts, playing audiobooks, and providing weather, traffic, and other real-time information, such as news. Alexa can also control several smart devices using itself as a home automation system. Users can extend the Alexa capabilities by installing “skills”.

Why Voice?
Voice is the most natural form of user interaction, and recent advancements in speech recognition and natural language understanding technology are now enabling us to control our connected devices with speech. We believe that voice can simplify the modern lifestyle, providing us with a unifying interface across devices so we can be entertained, stay informed, and organize our lives by just asking.

What Is a Voice User Interface (VUI)?
A voice user interface (VUI) allows people to use voice input to control computers and devices. In short, it’s what enables voice experiences like the Star Trek computer and Alexa, Amazon’s voice service and the brain behind millions of devices including the Amazon Echo. Voice experiences are great when they offer a faster, easier, or more delightful way of doing things.

How to build custom Alexa skills?
This is a two-step process. First is to write a lambda or web service which will listen to Alexa events. We are going to write amazon lambda using NodeJs. And the second step is to configure skill events using Alexa Skills Kit. So how this works is, we create a new skill and provide the invocation name to it and some sample utterances. And these utterances are tied to an Amazon event which is handled by Amazon lambda. So when we wake Alexa with invocation name and ask something, based on utterance Alexa voice engine determines which amazon event to trigger, and output is provided by Amazon lambda function which handles that particular event.

 
Let me take you through the steps now:
1] Login to Amazon console and select lambda service. You will see the list of lambdas already created by you. You can see the Create Function button.

1

It is important to note that you have to select the region US East (N. Virginia) for Lambda functions used with the Alexa Skills Kit.

15

 
2] After clicking on Create Function button, you will be redirected to this page. Amazon supports lambda creation from blueprints or templates. For our skill, we are going to create it using blueprint.

2

 
3] Click on the blueprint and you will see the list of blueprints. Search for alexa-skill-kit-sdk-factskill and one blueprint will be shown below. Click on the skill and customize button on the right bottom.

3

 
4] Provide Basic information of lambda such as name, role etc and click on Create function button.

 
5] Now function has been created and configuration page will open. Now we have to add triggers to function. You can see the trigger list from the menu on left, click on Alexa Skill Kit to add it to the function. It is recommended that you add the Alexa skill trigger once you have set up an Alexa skill in developer console because you will have to provide the app id in the lambda skill trigger.
Now open the function code which is editable online and add following code in the handlers.

'DateIntent': function () {
  this.emit(':tell', 'You are asking for todays date.');
}

5

Proceed further and save the function.

 
6] Now, login to https://developer.amazon.com/ and click on the ALEXA tab inside. You will see something like this.

6

 
7] Now click on the Get Started button on Alexa Skills Kit section. And the Add a New Skill.
First, you have to provide the Skill information. Most important thing is to name the skill and provide the invocation name. Make sure not to use big invocation name and without any special characters. These guidelines are useful at the time of certification of the skill.
For example, if you provide invocation name as “date helper”. Then to invoke the skill, you will say something like Alexa, ask date helper to give me today’s date.

7

 
8] After saving the skill information, an ID will be allocated to the skill which you can provide in the lambda Skill Kit trigger which we discussed earlier.

 
9] Click next to go to Interaction Model. This is the section where you will be creating an Intent, utterances to invoke the Intent etc. Click on the “Launch Skill Builder” button which will take you to the dashboard.

 
10] On the left menu, you can see default intents which Amazon provides. Now you have to create ADD button to create custom intent.

10

 
11] Name the intent as DateIntent and click create intent button. Now it will ask for the sample utterances. You have to provide multiple utterances which could invoke/trigger this intent. The name of the intent should match with the handler you have written in lambda.

11

 

Intents can have slots configured. A slot is a keyword whose value is going to be dynamic. We can choose existing slot types or create new ones.

 

12] Save and build the model. Once the model is built, click on the configuration link to go to the previous page.

 

13] Configuration tab asks you for the service which is going to handle the intent events. Since are going to provide the AWS lambda ARN which is going to handle the intents. Click on the AWS Lambda radio button and provide lambda ARN which we have created earlier. Save and click Next.

 

14] Now you are onto the Test section which provides the voice simulator and service simulator. Provide sample utterance and click the Ask button. You will see the service request and response. You can copy this request which can be used in the lambda section to create tests.

14
Click Next and go to the Publishing Information section.

 
15] Publishing information asks you for the basic information about the skill. You will have to provide the category, testing instructions, description of the skill, sample utterances, and icons. Make sure to provide the correct description and sample utterances because those are important in case you try to submit the skill for certification.

 
16] Provide information in the privacy and compliance section and save. If you think your skill is good enough to go live, submit it for certification.

You can have a look at my GitHub repository to understand how the lambdas are written to handle the Alexa skill intents.

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