Skip to Content
Learn
Control Dialog in Lambda
Overriding Intent Confirmation

“Personalize the intent confirmation message using the :confirmIntent directive”

Just like slot confirmation, we can make our intent confirmations custom as well. Custom intent confirmations can be used to personalize a prompt, present the availability or cost of an intent, or initiate another intent.

To show the syntax for intent confirmations, imagine that we want to tailor our confirmation to comedy movie requests:

ALEXA: Aha. I love comedy movies. I’ve got a really good recommendation for you. Do you want me to tell you the comedy movie I found for you? USER: Yes.

Remember that intent confirmations can be tedious for users, so, when building your own skills, only use them for actions of high consequence — actions that are publicly visible (like social media), affect another person (like sending a message), or involve money.

To confirm an intent, use the :confirmIntent directive in your Lambda function:

this.emit(':confirmIntent', speechOutput, repromptSpeech, updatedIntent);
  • The :confirmIntent directive is used to confirm the intent the user has provided
  • speechOutput is the string that will be used as the prompt, like “So {user}, you’re looking for a {genre} {video} from the {decade}, right?”
  • repromptSpeech is the prompt used if the user takes longer than 8 seconds to reply or if the response was incomprehensible for Alexa. It is optional, but it’s good practice to use this parameter to provide context and guidance towards a valid response.
  • updatedIntent is used to update the state of the conversation. This will be explained later in the lesson. Optional.

Instructions

1.

Let’s implement the custom intent confirmation mentioned above. In index.js in the FindVideoByGenreIntent handler, the genre and videoType slot values are stored in genreRequestedByUser and videoTypeRequestedByUser, the if-else statements are already set up, the main functionality (recommending a video) is included in the last else block. There are two scenarios to consider:

  • First, if dialog is not completed, genre has been collected and confirmed and the intent has not been confirmed, check if the user is looking for a comedy movie. If so, use the custom intent confirmation.

Your code will look similar to this (You’ll need to add three arguments to this.emit()):

if ((genreRequestedByUser == 'comedy') && (videoTypeRequestedByUser == 'movie')) { const speechOutput = "Aha. I love comedy movies. I’ve got a really good recommendation for you. Do you want me to tell you the comedy movie I found for you?"; const repromptSpeech = "So you're looking for a " + genreRequestedByUser + " " + videoTypeRequestedByUser + ", right?"; this.emit( , , ); }

Scroll down on index.js to find where this code belongs.

2.

If the user is not looking for a comedy movie, use the standard slot confirmation.

Your code will look similar to this (You’ll need to add three arguments to this.emit()):

else { const speechOutput = "Just to confirm, you're looking for a " + genreRequestedByUser + " " + videoTypeRequestedByUser + ", right?"; const repromptSpeech = "So you're looking for a " + genreRequestedByUser + " " + videoTypeRequestedByUser + ", right?"; this.emit( , , ); }
Folder Icon

Take this course for free

Already have an account?