Creating Your First Skill for Alexa: Part 1

Alexa, if you didn't know, it's the high-tech toy in fashion. It is the conversational assistant with which you interact by voice. You can ask him a whole bunch of questions, plug in “skills” and even control your home automation installations by voice. The "skills" are the applications that are called and controlled by voice.

Alexa is also the interface through which brands will interact with their customers tomorrow. And if we know the same enthusiasm as for the mobile applications market, it is better to be ready to get your share of the cake.

With a scandal over espionage techniques having just broken and a video questioning the links between Amazon and the CIA having gone viral, there was no better time to write this article.

If that didn't alert your inner Snowden, then you can keep reading this article and find out how to build your first skill for Alexa.

How Alexa works

It all starts the moment you say “Alexa”. This very charming little name is the hotword, the trigger word in French, which triggers the recording of your request.

The audio recording is then sent to Amazon's servers. Amazon uses Machine Learning to help it recognize spoken words (don't worry, you can pull out your best English accent) and understand the question, it's called "Natural Language Processing". Once understood, Amazon queries the corresponding system to return the requested information to you.

How does a “skill” work?

alexa diagram
Scheme of how Alexa works

Unlike smartphones, here no application is installed locally. All "skills" are stored at Amazon and the user chooses through his dashboard (or the official Alexa application) which "skills" he wishes to activate.

Skills are invoked by their name (“Alexa open My Awesome Skill”)

And just like for an API, we can also add parameters to your request (“Alexa ask My Awesome Skill for the weather in London”). Here, you guessed it, the parameter is “London”.

But how does it know, Alexa, what request to make and what to do with my parameter?

A “skill” is made up of three parts:

  • your program,
  • An “Intent Schema”,
  • A file of “Sample Uterrances”

"Sample Uterrances" is a really complicated term for a file containing several ways to invoke your "skill" and what queries to execute in these cases.

GetWeather what is the weather in {Location}
GetWeather weather in {Location}
GetWeather will it rain in {Location}
GetSingles single ladies between {Age1} and {Age2} in {Location}

And on the other side we have the declarative schema of variable types expected by the GetWeather function

{
 "intents": [
  {
   "intent": "GetWeather",
   "slots": [
   {
    "name": "Location",
    "type": "AMAZON.EUROPE_CITY"
   }
   ]
  },
  {
  "intent": "GetSingles",
  "slots": [
    {
     "name": "Location",
     "type": "AMAZON.EUROPE_CITY"
    },
    {
     "name": "Age1",
     "type": "AMAZON.NUMBER"
    },
    {
     "name": "Age2",
     "type": "AMAZON.NUMBER"
    }
   ]
  }
 ]
}

There are as many “slots” (types of variables) declared as variables required for your function.

In this way, after the Speech-to-Text, the Natural Language Processing algorithm makes the connection between the words and the types of "slots" announced.

And "Alexa ask My Awesome Skill for singles ladies between forty and seventy in Paris" will be translated into GetSingles('paris',40,70)

The full list of "slots" is available here: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#list-types and if the "slot" you need does not exist, you can always create it.

Create your development environment

There are several ways to test your code. A single prerequisite, having an Amazon account.

echosim.ioThis website offers you to test your orders directly in the browser

Reverb.aiReverb also lets you experiment with your controls in the browser. Its added value is that it is also possible to download the application directly to your Mac, your iPhone (iOS 10 minimum) or your Android (Android 5.0 minimum)

Alexa AVSDo you like to tinker and are looking for your next ideal project for a rainy Sunday? So head to the Official Alexa GitHub, regularly updated by Amazon developers.

All the instructions are detailed there to create your Alexa on Raspberry Pi, Linux, Mac and Windows.

  • Get an Amazon Echo or Echo Dot: not yet available in France but can be easily found on eBay

And now how do I code my “skill”?

We will see that in the second part of this article 😉

Thank you for reading me, and if you liked the article, do not hesitate to share it on social networks.

[actionbox color=”default” title=”” description=”JS-REPUBLIC is a service company specializing in JavaScript development. We are an approved training center. Find all our technical training on our partner site dedicated to Training” btn_label=”Our training” btn_link=”http://training.ux-republic.com” btn_color=”primary” btn_size=”big” btn_icon=”star” btn_external =”1″]