Build a Custom Amazon Alexa Skill
Introduction to Alexa
Amazon’s Alexa is the voice activated, interactive AI Bot, or intelligent personal assistant in the cloud that lets people speak with their Amazon Echo, Echo dot and other Amazon smart home devices. Alexa is designed to respond to number of commands and converse with people.
Alexa Skills are apps that give Alexa even more abilities. These skills can let her speak to more devices or websites.When the Alexa device is connected through wi-fi or Bluetooth to the internet, it wakes up by merely saying “ALEXA”. Alexa Skills radically expands the bots repertoire, allowing users to perform more actions with voice-activated control through Alexa.
Overview of Alexa Skill
The most important part of ALEXA skill is its interaction design. Alexa skills don’t have visual feedback like web or desk top applications and will guide the user through the skill using voice. All Alexa skill replies needs to tell the user clearly what the next options are.
An Alexa skill is a small application that interacts with Alexa via an AWS Lambda function
Designing the Alexa Skill
The most important aspect of the skill is its Vocal interface. The skill should be interacting naturally with the user. The components of Alexa Skill are :
- Alexa requires a word, often called as Wake phrase which would alert the device that they can expect a command immediately after.The Default wake phrase is ALEXA. It can also be Amazon, Echo,Computer.
- Launch Phrase is the word that tells Alexa to trigger a skill. Examples of Launch phrase are “ OPEN”, “ASK” , “START”, “LAUNCH”.
- Invocation name is the name of the skill.
- Intents are the goals that the user is trying to achieve by invoking the skill.
- Utterance tells alexa what the skill should do. Apart from Static utterances such as Start and Launch, dynamic commands can be added. These Dynamic commands are called slots.
- Each intent can contain one or more slots. A Slot is the variable that is parsed and exposed to the application code.
Alexa has a built in natural language processing engine. To Map the verbal phrase to an intent, Alexa handles the complexity of natural language processing through the help of a manually curated file Sampleutterances.txt.
The first word in each line of SampleUtteranaces.txt is the intent name. The application code reads the value of the intent name and responds appropriately. Following the intent name, is the phrase that the user says to achieve that intent. The User might tell a phrase apart from those defined as Slots in the intent. The application is free to react differently based on the presence or value of the slot. To give Alexa the best chance of understanding users, it is recommended to include as many sample utterances as possible. Depending on the skill there could be n number of ever changing sample utterances.
The below example sums up the entire vocal interface
Build and Publish a new skill
Building and publishing a new skill in Alexa comprises of the below steps:
1. Create and Configure Skill :
Create an Alexa skill using https://developer.amazon.com/alexa-skills-kit. This will open the skill information where we can specify the name of the skill and the invocation name.
2. Create Interaction Model:
Interaction model is a set of rules that defines the way the user interacts with your skill. As a part of an interaction model, Intents, Utterances are defined. The intent schema should be in JSON format and it should define an array of intents, each with a name, and an optional list of dynamic parts — slots. Alexa will automatically train itself with the provided interaction model.
3. Coding the Backend system:
Once the interaction model has been designed Code and deployment of the Lambda function has to be done.
For each intent, an input/output contract has to be implemented. The input is an IntentRequest which is a representation of the user’s request and includes all the slot values.
The response from alexa can be of multiple ways.
- Ask the user a question and wait for response.
- Give the details to the user and shut down.
- Say nothing and shut down.
Alexa can either respond verbally or the response could be displayed on the phone.
4. Deploying the Backend system:
The skills can be deployed as an AWS Lambda function with code written in Java or Node.Js, Python or C#. The simplest approach would be the code in Node.Js.
5. Testing the Skill:
Testing of the Skill can either be done through the test simulator available in the Developer console account or through the device connected to the development account.
6. Publishing the Skill:
To Publish the skill, The skill has to be submitted by filling out the “Publishing Information” and the “Privacy & Compliance” sections