COVID-19 time and Alexa Skill, part II

Pawel Piwosz
4 min readApr 8, 2020

--

(continued)

Alexa Skill and dialogue construction

As you may know, to create an Alexa Skill you need to have a developer account here: https://developer.amazon.com/ I will not present here a walk-through how to create the skill, it is not the point of this article. I describe my scenario, so at this point I give only some of the most important information.

Create Intents

First, what is the intent. Due to the Alexa documentation

An intent represents an action that fulfills a user’s spoken request.

This means that every logical part of the dialogue should have its own intent. And here lies the challenge with more advanced and complicated dialogues.

By default we have some intents prepared by Amazon. As built-in elements we can find NavigateHome, Fallback, Stop, Help and Cancel. In my case, I didn’t use any of them; what I did was only a slight change in the returning message.

Utterances

For having any kind of “interaction” during the dialogue, it is necessary to create proper flow. So, how will Intent know it is called? By Utterance. Utterance is a kind of context which can help the Skill to recognize the pattern and execute the proper block — Intent.

And now some of you can see the complexity. For example, imagine the Intent as a question to your colleague about his pet’s name. There are many ways to do it, like for example

What is your pet’s name

What is your pet called

How did you name your pet

How do you call your pet

Now, as you can see, your Intent has already 4 Utterances. Now, change the word pet to animal, and immediately you have 8 Utterances to cover. Of course, you can put all of them into the code of the skill.

But it is an ineffective way.

Slots

Fortunately, there is a solution. Slots are the answer. Custom slots help you to “close” common sentences used for specific case and create less Utterances.

So, in case of my Skill, it looks like this

Sample Utterances for my Alexa Skill Intent

And Detail (for example) looks like this

Slot for Detail.

In the picture above you see only three elements for DetailSlot. There are 8 of them. It is simple math now, 7 Utterances multiplied by 8 positions in the DetailSlot. And as you can see, there are more Slots.

How to configure Slots? We have some options here. For example, for country selection I used a predefined one, AMAZON.Country. For the rest I used custom slots with my list of values. Also, we can use Query (let’s think about it as an “open question without proper answer” and other predefined slots.

This Skill does not need anything more sophisticated.

The last thing for the configuration is to provide an endpoint, where this Skill will be connected. In my case it is the Lambda Function.

Endpoint connection for the Skill

Testing

First, for early stage tests you can use Evaluate model functionality. This will help you to check, if your Utterances work.

Evaluate Model button to test your skill ‘offline’
Evaluate Model. See what kind of payload you can expect.

After successful deployment of Lambda function, and after all configuration necessary, it is possible to test the Skill “live”. Simply go to Test tab and start interact with your app.

Test console

Skill code

I’m sure, you already thought about of it. Is there any chance to have the skill as a code? Yes!

The skill is generated as a JSON code, and it is accessible for you all the time. You can simply copy it and put to version control of any kind.

The most common (and I think it is a best practice) is to keep the code Models in directory Models (in your project) with file name related to the language. So, i.e Models/en-us.json.

Next part is about Lambda function: COVID-19 time and Alexa Skill, part III

Previous part is about Alexa skill overview: COVID-19 time and Alexa Skill, part I

--

--