Creating An Alexa Skill (Synonyms Finder) - Part One - Introduction And Interaction Model

Introduction

All Alexa Skill mainly contains two parts, Interaction Model - Front End, and the Hosted Service - Backend.

  • Interaction Model (Front End)
    It is similar to the GUI of a mobile app, Alexa skills need a Voice User Interface (VUI), which is called the interaction model. Interaction Model defines what functionalities or behaviors the skill is able to handle.

  • Hosted Service (Backend)
    The Hosted service, as usual, includes the programming logic to respond to user requests and is hosted on the internet. 

    Alexa Skill

This is part 1 of the article and we shall completely learn all the things about Interaction Model, and in part 2 of this article we shall learn the AWS Lambda method creation and integrating it with the Alexa skill. 

Interacting with an Alexa Skill

To begin a conversation with Alexa-Enabled devices, you say a word, "Alexa", followed by the request line. 

Let us say:

Alexa, ask Synonyms Finder, what are synonyms for Passion?

Wake word: "Alexa"

" Alexa " is the default wake word. It wakes up the device and tells it that the user wants to talk to Alexa.

Starting Phrase: "Ask"

Following the "Alexa" wake word, users must use a starting phrase. In our case "ask" is used to specify the type of request they are using. 

Invocation Name

In the above example "Synonyms Finder" is the invocation name. The user says "Synonyms Finder" to instruct Alexa, to invoke the Synonyms Finder skill. Every skill needs to have a unique invocation name.

Now let's create an Alexa Skill. Log in to https://developer.amazon.com/ and navigate to Alexa Console and click create a new skill, give a skill name, select custom skill, and click create skill. 

Alexa Skill

Now, we are on your created skill dashboard. Now select Invocation on your left menu and give an invocation name for your skill. Invocation name has to be unique and is used to invoke your skill.

Alexa Skill

Let's talk about Intents and Utterances.

Intent

Each intent defines a specific behavior, like buttons on a web page. An intent takes user input and executes some code based on it. 

Utterances

These help Alexa connect the intent to phrases spoken by the user. In this case, these sample utterances will help Alexa map the spoken user input to the intent which we create.

Let us create a custom Intent and add some sample utterances:

Alexa Skill

Before we add sample utterances let us learn what a slot is. 

Slot

A slot is a variable that relates to an intent allowing Alexa to understand information about the request. A slot is basically added to the sample utterances which we create.

For example: what are synonyms for the {word}.

Here, whatever is defined in {} is nothing but a variable, so we create a slot and use it in our utterances. Slots are variable and can be used in the backend service to process the request. Let us create a slot with the  name word of type AMAZON.Literal.

Alexa Skill

We do have predefined slot types basically based on the type of variable. We can also create a custom slot type which can take only some set of values.

In our case the slot type is AMAZON.Literal, so the sample utterances also need to contain a sample word along with the slot name. For example, the sample utterance will be like. 

What are synonyms for the {passion | word}? 

Here, passion is a sample word which stands for the word slot.

Now, let us create as many sample utterances we can as shown below. Try adding as many sample utterances as we can so that the skill will be responding for the most utterances.

Alexa Skill

Now, let us check the JSON Editor for the settings we made. We will be able to see all the things like invocationName, and intents in our interaction model. We have created Synonyms intent for our skill. Apart from this, we can have some other predefined intents like AMAZON.CancelIntent which is used for canceling the user response or exiting the skill. These intents can be used in the backend to define some logic to process the request based on the intent received.

  1. {  
  2.     "interactionModel": {  
  3.         "languageModel": {  
  4.             "invocationName""synonyms finder",  
  5.             "intents": [{  
  6.                 "name""AMAZON.FallbackIntent",  
  7.                 "samples": []  
  8.             }, {  
  9.                 "name""AMAZON.CancelIntent",  
  10.                 "samples": []  
  11.             }, {  
  12.                 "name""AMAZON.HelpIntent",  
  13.                 "samples": []  
  14.             }, {  
  15.                 "name""AMAZON.StopIntent",  
  16.                 "samples": []  
  17.             }, {  
  18.                 "name""Synonyms",  
  19.                 "slots": [{  
  20.                     "name""word",  
  21.                     "type""AMAZON.LITERAL"  
  22.                 }],  
  23.                 "samples": ["{impeccable| word} ""{impeccable| word} synonyms""synonyms {impeccable| word}""what are synonyms of {impeccable| word}""what are synonyms for the {impeccable| word} ""What are synonyms for {impeccable| word}"]  
  24.             }],  
  25.             "types": []  
  26.         }  
  27.     }  
  28. }  

In the next part of the article, we will focus on backend services, where we can call an externalAPI to process our request, accessing slots in the AWS Lambda, integrating the Alexa skill with the AWS Lambda function, and even learn how we can test our skill using an Alexa simulator.

If you have any questions please add them as comments.


Similar Articles