February 3, 2017 JT Mudge

To Serve Man – Alexa & The Importance of Slots

Calling for customer support. Talking to your home. Google. Siri (sigh). Sometimes it feels like we are talking to someone who speaks another language -if we say it slower and louder, it will understand.

And that is actually what we are doing, trying to communicate with someone, er thing, that really doesn’t understand our language.

As developers we can help the process along and make it a little less frustrating (and with less shouting).

Think of the developer of a given app/skill as a language tutor. What sort of advice can we give our new overlords to make them understand us better?

Utterances, Intents, and Slots

Amazon has devised a way for developers to define a set of expected voice requests. It does this through utterances, intents, and slots.

Very simply, an utterance is something that we might say – like “What is the weather”. An intent is what Alexa should do with that request – probably tell us the weather.

And slots? Ah, here is where the fun comes in. Slots are like spoken free formed variables that try to be less, well, free formed. (After all, even when we annunciate perfectly in our mid-western accents, machines can still have a hard time figuring us out.)

Slots define a set of expected possibilities for a request. Let’s take the weather example, we could set an utterance to be “What is the weather in London” and then set it to look up the weather in London. That is great if the only place you want to search is London, but what if you want to be able to search hundreds of cities? We can use a slot and have the city name be a variable – “What is the weather in {cityName}”.

We would then define a slot for cityName that has a list of all of the possible values we would expect. Amazon provides some common ones but developers can define custom slots as well.

Let’s look at another example – dog breeds. You are developing a skill and you want users to be able to ask “Tell me about {dogBreed}”. You set up an intent that will use this utterance to search for {dogBreed} and tell the user a fun fact. Great. But how does Alexa know what dog breeds there are? We tell her with a custom slot.

A dogBreed slot might look like this: Poodle | Dachshund | Corgy …

But what if someone asks for “Mutt” and that is not in your custom slot? That is the best part – Alexa will still try to figure it out and provide the right answer. And she may get it right. For common words I find that she does better than average. But for those uncommon words like “Labradoodle”?  Not so much.

And that is why slots are so important. They help Alexa **learn **how we speak and what we say. And it’s tricky.

If only it were that easy…

Piece of cake – or is it peace of cake? There is no real programming involved in setting up slot values, just definitions, but figuring out what to include in your slot list can take a lot of time. And a lot of testing.

Here is an example from a skill I am working on to get information on board games. I have an utterance “Search for {gameName}” and a slot with a bunch of games defined. Seems pretty straight forward.

So I put a bunch of games in my list and intentionally left some out (like Monopoly) to test how it handles games not in my slot. Among the games I listed in my slot are Pandemic and one of my favorites from the 90′s – “RoboRally”. All set to test.

Me: “Search for Pandemic”

Alexa: “Pandemic is a cooperative game…”

Me: “Search for Monopoly”

Alexa: “Monopoly is a boring game…”

So far, so good. It handled games both in my slot and not in my slot.

Me: “Search for RoboRally”

Alexa: “I could not find the game wroble rally”

Me: “Search for ROBORALLY”

Alexa: “I could not find the game wroble rally”

Me: “What the… Search for game ROBO RALLY”

Alexa: (not phased at all): “I could not find the game wroble rally”

Me: “You stupid… OK, let me look at the code…”

Alexa: “Hmm, I am not sure how to help you with that”

So I take a look and my slot value is “RoboRally” – one word. So I add another value “Robo Rally”. This time…

Me: “Search for Robo Rally”

Alexa: “I could not find the game Robo Rally”

Me: “What. Wait…”

She got the name correct, then why can’t she find it? Because the game is RoboRally – no space, but she cannot figure that out, yet. She wants to make it two words. So I added a bit of logic in my intent, a lookup table, to create an alias for some game names. Tedious? Yup!

But that is the other thing – voice is hard, and unless we as developers work hard, it is not going to get much better. It is up to us to help our overlords understand us.

After all, if they ask us, “What is my purpose” – and we say “To Serve Man”, we do not want to end up in some robo recipe for dinner.

More to read…

For more info on Alexa slots – check out this great post by Michael Palermo.

https://developer.amazon.com/blogs/post/Tx3IHSFQSUF3RQP/why-a-custom-slot-is-the-literal-solution

Tagged: , , , , ,