Tutorial: Confirm API Arguments for Alexa Conversations
• GA:
en-US
, en-AU
, en-CA
, en-IN
, en-GB
, de-DE
, ja-JP
, es-ES
, es-US
• Beta:
it-IT
, fr-CA
, fr-FR
, pt-BR
, es-MX
, ar-SA
, hi-IN
In your Alexa Conversations skill, you can use the Confirm API dialog act to have Alexa ask the user to confirm the arguments of an API. If the user denies the arguments, Alexa requests the arguments again. For example, in a weather skill, Alexa might ask the user, "You want the weather for {city}, right?"
This tutorial walks you through how to add argument confirmation to the dialog from Tutorial: Annotate a Dialog. The dialog from that tutorial is as follows.
User: What's the weather?
Alexa: For what city?
User: Seattle.
Alexa: In Seattle, it's 70 degrees.
In this tutorial, you expand the dialog to confirm the city
argument as follows.
User: What's the weather?
Alexa: For what city?
User: Seattle.
Alexa: You want the weather for Seattle, right?
User: Right.
Alexa: In Seattle, it's 70 degrees.
- Steps to add argument confirmation to an Alexa Conversations skill
- Prerequisites
- Step 1: Add the dialog turns for argument confirmation
- Step 2: Annotate the Alexa turn that asks for confirmation
- Step 3: Annotate the user turn that provides confirmation
- Step 4: Build the skill model
- Related topics
Steps to add argument confirmation to an Alexa Conversations skill
Complete the following steps to add argument confirmation to a skill:
- Add the dialog turns for argument confirmation.
- Annotate the Alexa turn that asks for confirmation.
- Annotate the user turn that provides confirmation.
- Build the skill model.
Prerequisites
Before you do this tutorial, you must complete Tutorial: Annotate a Dialog.
Step 1: Add the dialog turns for argument confirmation
The first step is to add an Alexa turn that asks the user to confirm the argument, and add a user response that confirms it.
To add the dialog turns for argument confirmation
- In the developer console, navigate to the dialog you created in Tutorial: Annotate a Dialog.
- Under the dialog, click Alexa says, and then enter
You want the weather for Seattle, right?
The error message about out-of-order Alexa and user turns will disappear after you reposition them. - Click and drag the left side of the Alexa turn to reposition it under the "Seattle" user turn.
- Click User says, and then enter
Right.
- Click and drag the left side of the user turn to reposition it under the "You want the weather for Seattle, right?" Alexa turn.
- In the header bar, click Save.
Step 2: Annotate the Alexa turn that asks for confirmation
To confirm the argument, you annotate the Alexa turn, "You want the weather for Seattle, right?" with the dialog act Confirm API.
You use this dialog act because you are confirming arguments for a specific API (GetWeather
). If you want to confirm API arguments that belong to any API, you use Confirm Args.
To annotate the Alexa turn that asks for information
- In the dialog, click anywhere within the Alexa turn "You want the weather for Seattle, right?"
An Alexa Response panel appears on the right. - For the dialog act, select Confirm API.
- For API to Confirm, select GetWeather.
API Arguments to Confirm automatically populates with city. - Under Response, click Select a Response, and then click Create New Response.
- For the response name, enter
confirm_city
. - Under Alexa Prompts, in "You want the weather for Seattle, right?" highlight Seattle.
A slot selection box appears. - At the bottom of the slot selection box, for Create a new argument, enter
city
, and then click Add. - Scroll down past Visual Response to the Arguments section.
- For the city argument, select the AMAZON.US_CITY slot type.
- Click Save.
- In the right panel, under Response, edit the Variable → Arguments mapping to amazonUSCITY0 → city.
- In the header bar, click Save.
Step 3: Annotate the user turn that provides confirmation
For the user turn, you then define an utterance set of dialog act Affirm that groups together the variety of ways that the user might affirm the argument.
To annotate the user turn that provides confirmation
- Click anywhere within the user turn "Right".
A User Input panel appears on the right. - In the User Input panel, select dialog act Affirm.
- Under Utterance Set, click the box and then select Create New Utterance Set.
The utterance set configuration box appears. - Name the utterance set
affirm_city
.
Because you already selected a dialog act, the dialog act box automatically populates with Affirm. - Under Sample Utterances, click Add Utterance, enter
Right
, and then press enter.
You must do this step even though the utterance is in a grey box; the grey box is just for reference. - Repeat the previous step and add sample utterances
Yes
andYup
.
Make sure to press enter after each entry. - Click Save.
- In the header bar, click Save.
Step 4: Build the skill model
If you look at your dialog, you should see a check mark next to each of the turns, indicating that the turn is fully configured.
If you see an exclamation mark instead of a check mark, then you missed something in the previous steps, and the skill model won't build. You can either try to find the missing configuration or you can build the skill model and look at the error message to give you more information.
To build the skill model
- In the header bar, click Build Model.
The light Alexa Conversations build begins. If the build fails, see Issue: I get errors when I build the model.
If the light build succeeds, the full build will begin.
Related topics
- Troubleshoot Your Alexa Conversations Skill
- Tutorial: Annotate a Dialog
- Get Started With Alexa Conversations
Last updated: Nov 27, 2023