Tutorial: Confirm API Arguments for Alexa Conversations


In your Alexa Conversations skill, you can use the Confirm API response 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 for Alexa Conversations. 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

Complete the following steps to add argument confirmation to a skill:

  1. Add the dialog turns for argument confirmation.
  2. Configure the Alexa turn that asks for confirmation.
  3. Configure the user turn that provides confirmation.
  4. Build the skill model.

Prerequisites

Before you do this tutorial, you must complete Tutorial: Annotate a Dialog for Alexa Conversations.

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

  1. In the developer console, navigate to the dialog you created in Tutorial: Annotate a Dialog for Alexa Conversations.
  2. Under the dialog, click Alexa says, and then enter You want the weather for {city}, right?
  3. Click and drag the left side of the Alexa turn to reposition it under the {city} user turn.
  4. Click User says, and then enter Right.
  5. Click and drag the left side of the user turn to reposition it under the You want the weather for {city}, right? Alexa turn.
  6. In the header bar, click Save.
    Dialog that includes confirmation
    Dialog that includes confirmation

Step 2: Configure the Alexa turn that asks for confirmation

To confirm the argument, you configure the Alexa turn You want the weather for {city}, right? with the Confirm API response act.

You use this response 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 configure the Alexa turn that asks for information

  1. In the dialog, click anywhere within the Alexa turn You want the weather for {city}, right?.
    An Alexa Response panel appears on the right.
  2. For the response act, select Confirm API.
  3. For API to Confirm, select GetWeather.
  4. In the header bar, click Save.
    Alexa Conversations automatically creates a response called audioResponse0, which you edit next.
    Configuring the Alexa turn that asks for information
    Configuring the Alexa turn that asks for information
  5. In the left pane, under Audio Responses, click audioResponse0.
  6. In the main window, rename the audio response to ConfirmCity.
  7. Under Type Configuration, select the CityType slot type that you created.
  8. Scroll back up to the Alexa Prompts section, and double-click {city}.
  9. Verify that you see city in the Select an Existing Property section.
    (You don't need to click it.)
  10. In the header bar, click Save.
Configuring the audio response that asks for information
Configuring the audio response that asks for information
  1. Go back to your dialog, and click anywhere within the Alexa turn You want the weather for {city}, right?.
  2. In the Alexa Response panel, at the bottom of the Response section, expand Properties of CityType.
  3. Configure the variable mapping to the following:
    city0.citycity
  4. In the header bar, click Save.
Finishing the configuration of the Alexa turn that asks for information
Finishing the configuration of the Alexa turn that asks for information

Step 3: Configure the user turn that provides confirmation

For the user turn, you then define an utterance set of request act Affirm that groups together the variety of ways that the user might affirm the argument.

To configure the user turn that provides confirmation

  1. Click anywhere within the user turn Right.
    A User Input panel appears on the right.
  2. In the User Input panel, under Request Act, select Affirm.
  3. Under Utterance Set, click the box and then select Create New Utterance Set.
    The utterance set configuration box appears.
  4. Name the utterance set ConfirmCity.
    Because you already selected a request act, the request act box automatically populates with Affirm.
  5. Under Sample Utterances, click Add Utterance, enter Yes, and then press enter.
  6. Repeat the previous step and add sample utterance Yup, but don't press enter this time.
    Ignore the Type Configuration section. There are no variables in these utterances.
  7. Click Save.
  8. In the header bar, click Save.
    Utterance set for the user turn that provides confirmation
    Utterance set for the user turn that provides confirmation

Step 4: Build the skill model

Your next step is to build the skill model.

To build the skill model

  • In the header bar, click Build Model.
    The light Alexa Conversations build begins. If the build fails, click back through all of the lines of your dialog, and ensure that you don't see any red errors. Also, see Issue: I get errors when I build the model.

If the light build succeeds, the full build begins.


Was this page helpful?

Last updated: Nov 27, 2023