Step 4: Built-in Intents and IntentMap

by Jan König on Nov 24, 2018

In Step 1: Adventure Game Interaction Design, we already created two intents for the second interaction of the adventure game: a "Yes" and a "No" answer. In this step, we're going to build out the app logic for this.

Second Step Interaction Design

First, let's take a look at the interaction to see what we could ask the user. For this course, we won't go too deep into scripting games (there are whole books written about this topic), but let's think about some different scenarios for both doors:

Blue Door: You're going through the blue door. There is a dark, long floor. Suddenly, you hear a sound from a room at the end of it. Do you want to follow the sound?

Red Door: You're going through the red door. You find yourself in a small room with only one door, and a dog sleeping in front of it. To go through it, you would have to wake up the dog. Do you want to do it?

This leaves two options for each door: Yes or No.

Fortunately, we already created the necessary intents in the previous steps.

Let's build this into our code.

Coding the Second Interaction

This is what our EnterDoorIntent currently looks like:

As we want to ask another question and not stop the session, we need to switch from _tell _to ask for the blue and red door.

Let's restructure the code a little bit and add the script from above.

Notice how we changed the methods from tell to ask to keep the session open and wait for user input.

Next, we need to add the intents for Yes and No.

Alexa Built-in Intents and Jovo intentMap

What we have created in Step 1: Adventure Game Interaction Design for Yes and No are Alexa built-in intents called AMAZON.YesIntent and AMAZON.NoIntent.

If you click into them on the Skill Builder, they are explained like this:

This means we don't need to create any phrases for these intents. Great, right? However, those built-in intents do come with one problem: If we're developing for cross-platform, we probably don't want to call our intents on Dialogflow (for Google Assistant) AMAZON.x.

For this, Jovo offers the ability to match different names to one with an intentMap. In it, you can define new names for certain intents, so that they have the same key across platforms.

In this example, we want to map incoming AMAZON.YesIntent requests from Alexa and YesIntent requests from Google Assistant to one intent called YesIntent:

Let's do this for both YesIntent and NoIntent.

In the configuration part of your voice app, config.js, add the following:

This is all you need to do to map different intent names. We're going add the intents for yes and no to our logic next.

Adding YesIntent and NoIntent to the Logic

First we're going to add this to the handlers variable for testing:

So, how do we know if the person is in the room with the blue door, or in the one with the red door?

Let's talk about this next.

Next Steps

Step 5: Introduction to States

Jan König

Co-founder at Jovo

Comments and Questions

Any specific questions? Just drop them below or join the Jovo Community Forum.

Join Our Newsletter

Be the first to get our free tutorials, courses, and other resources for voice app developers.