A Foray into Alexa Skills: Part 2

Karen Go
4 min readJul 21, 2019

--

Back in the day of when I wrote my first post, I was in the world of Ruby on Rails at Flatiron School. I had ambitiously started Amazon’s tutorial for Cake Walk and just blindly followed what the tutorial told me to copy and paste into different sections the index.js file, not quite understanding what exactly the code was doing. After a few hours of copying and pasting, I decided to give it a rest and come back to it later…

…and, today is later. Coincidentally, it is the day before I am to make a blog presentation to my class.

I opened up my bookmark to where I left off on Cake Walk and not-so-suddenly, it started clicking together. Since my last blog post, I started learning Javascript and now the syntax and verbs and methods that the tutorial was walking me through kinda made some semblance of sense in-a-way. Even the part where it said to add “async” in front of this function and have the “await” keyword— I kinda knew what it was talking about!

Pumped about being able to decipher some parts of what the tutorial was prompting me to do, I spent the majority of my Sunday completing the tutorial and now I can tell Alexa when my birthday is, and she will be able to remember it (saved to Amazon S3) and calculate how many more days until my next birthday when I open up the skill again. ✅ Yay!

Translating this to my Feeding Zeus skill, my next step was to get Alexa to prompt me for my pet’s name remember it, then prompt me for the last time I fed Zeus and remember it. Based off of the Cake Walk tutorial, the first 50% of this was straightforward enough. But getting Alexa to save the last time I fed Zeus is a bit more complicated since I need a different Interaction Model, Intent, and Intent Handler.

Interaction Model and Intent

The Interaction Model defines the voice interface for how a user would interact with Alexa. It is the pattern for a voice command, which is then matched with a particular Intent, or function of what I want the skill to do when the user says this particular command.

Capture Pet Name Intent: This is how I expect a user to tell Alexa what the name of their pet is. A user can say a variety of phrases. Ideally, you would program all the ways that a person would tell Alexa what their pet’s name is to provide a frustration free user experience.

The {name} is a slot with a slot type of AMAZON.FirstName— this tells Alexa that whatever word is said in this spot is a key value if the value is a value found in AMAZON.FirstName, then the correct intent is found. The AMAZON.FirstName is a built in slot type that consists of 1000s of first names. I’ve also added some popular dog names (courtesy of Rover) to this slot type in my skill so that Alexa will be more likely to recognize the correct intent.

Capture Last Fed Intent: After Alexa captures my pet’s name, she prompts the user “When was Zeus last fed?” and waits for a response. I want my user to be able to answer with the day (today, yesterday, Monday, etc) and the time (7am, this morning, last night), or with how long ago (10 minutes ago, 3 hours ago, etc), so my interaction model looks like the below.

Intent Handlers

When a user says an “utterance” (aka voice command), Alexa uses speech recognition to determine what the user is saying figures out which interaction model and intent it corresponds with. Alexa then translates the command to JSON. The JSON input then goes to the skill’s Lambda Function (backend) and the corresponding Intent Handler figures out how to handle the data and how to respond. It outputs a JSON response to Alexa, which then translates it into an audio file and replies to the user.

So I have my two intents and one intent handler — still working on the handler for my CaptureLastFedIntent. Let me know if you have any tips! I still have a long way to go to make my Alexa skill a reality, but,

--

--

Karen Go

Full Stack Software Engineer in Seattle, WA (Rails + React JS)