Tutorial: Test Voice-Forward Consent in an Alexa Skill

This tutorial walks you through how to test voice-forward consent in an Alexa skill based on the Survey template.

For details about testing personalization in the developer console, see Use Voice-Forward Consent in Your Alexa Skill.

Steps to test voice-forward consent in a skill

To test voice-forward consent in a skill based on the Survey template, take the following steps:

  1. Create a voice ID.
  2. Create a skill based on the Survey template.
  3. Update the skill code.
  4. Enable testing.
  5. Test the scenario where Alexa doesn't recognize your voice.
  6. Test the scenario where Alexa recognizes your voice but you haven't given Alexa permission to your name and email address yet.
  7. Test the scenario where Alexa recognizes your voice and you've already given Alexa permission to your name and email address.

Step 1: Create a voice ID

To test voice-forward consent, you must set up a voice ID in the Alexa app. If you already have a voice ID, you can skip this step.

To create a voice ID

  1. Open the Alexa app.
  2. At the bottom, select More.
  3. Select Settings, and then select Your Profile & Family.
  4. Follow the instructions on the screen to add your profile, including a mobile phone number.
    The mobile phone number is where you receive one-time passwords, as you do in step 6 of this tutorial.
  5. Follow the instructions on the screen to add your voice ID.

Step 2: Create a skill based on the Survey template

Next, create a skill based on the Survey template, which supports voice-forward consent.

To create a skill from the Survey template

  1. Log in to the Alexa Skills Kit developer console.
  2. Click Create Skill.
  3. Enter a name for your skill.
  4. Scroll down, and, for Choose a model to add to your skill, click Custom.
  5. For Choose a method to host your skill's backend resources, click Alexa-Hosted (Node.js).
  6. At the top, click Create skill.
  7. From the list of templates, select Survey Skill.
  8. Click Continue with template.
    Skill creation takes a few minutes.
  9. On the Build tab, on the left, expand Invocations, and then click Skill Invocation Name.
  10. For Skill Invocation Name, change the name to stand up skill.
  11. At the top, click Save Model.
  12. At the top, click Build Model.

Step 3: Update the skill code

Now, you update a file name and team information in the skill code. For this tutorial, the team information includes names, email addresses, and passcodes for fictional team members.

To update the skill code

  1. Continuing from the previous step, at the top, click the Code tab.
  2. On the left, under Skill Code, right click lambda/.env.sample, and then rename it to lambda/.env.
  3. Double click team.json, and then update the names, email addresses, and passcodes for your fictional team members.
  4. At the top, click Save.
  5. At the top, click Deploy.
  6. Wait for the Deployment Successful message to appear at the bottom of the developer console.

Step 4: Enable testing

Before you can test your skill, you must enable testing for the skill.

To enable testing for a skill

  1. Continuing from the previous step, at the top, click the Test tab.
  2. On the left, under the header bar, for Test is disabled for this skill, click Off, and then select Development.
  3. If the Alexa Simulator asks for permission to access your microphone, grant the permission.

Step 5: Test the scenario where Alexa doesn't recognize your voice

For your first test, try the scenario where Alexa doesn't recognize your voice.

To test this scenario

  1. In the Test tab, on the left, in the box that says, Type and click or hold the mic, type open stand up skill, and then press enter.
    Alexa doesn't recognize your voice because you typed in the request, so Alexa should ask for your passcode.
  2. Enter one of the passcodes you put in team.json in the previous step.
    Alexa should say that your passcode is valid, and then ask you what you worked on today.
  3. Type exit, and then press enter.
    Stand up skill when your voice isn't recognized.

Step 6: Test the scenario where Alexa recognizes your voice but you haven't given Alexa permission to your name and email address yet

In this step, you continue to use the Alexa Simulator, but you open the skill by using your voice instead of by typing. You previously set up a voice id, so Alexa should recognize your voice. However, because you haven't given Alexa permission to access your name and email address yet, Alexa takes you through the voice-consent flow.

To test this scenario

  1. Ensure that you created a voice ID in step 1.
  2. In the developer console, go to the Test tab.
  3. On the left, in the box that says, Type and click or hold the mic, click and hold the mic, and then say open stand up skill.
    Alexa should go through the voice-consent flow, which includes the following steps:
    1. Alexa asks if you give the skill permission to access your first name and email address.
    2. Alexa sends a one-time password (OTP) to your phone. After you say the OTP, Alexa starts the stand-up skill functionality.
  4. Type exit, and then press enter.
    Stand up skill when your voice is recognized but Alexa needs permission to access your first name and email address.

Step 7: Test the scenario where Alexa recognizes your voice and you've already given Alexa permission to your name and email address

In the previous step, you gave Alexa permission to access your first name and email address. You can now test the final scenario, in which Alexa recognizes your voice and already has the appropriate permissions.

To test this scenario

  1. On the left, in the box that says, Type and click or hold the mic, type open stand up skill, and then press enter.
    Alexa should enter the skill functionality without requiring further permissions from you.
  2. Type exit, and then press enter.
    Stand up skill when your voice is recognized and you already gave Alexa permission to access your first name and email address.