Tutorial: Implement Voice-Forward Account Linking in Your Skill (LWA)

The following tutorial walks you through the steps to enable Alexa customers to use their voice to link their Amazon account with the account they have with your skill service.

For an overview of voice-forward account linking, see Use Voice-Forward Account Linking for Alexa Skills (LWA).

Steps to implement voice-forward account linking in your custom skill

To implement voice-forward account linking in your custom skill, take the following steps:

  1. Review the requirements.
  2. Configure your custom skill and implement account linking.
  3. Add voice-forward account linking to your custom skill code.
  4. Test your implementation.
  5. Certify your skill.

Step 1: Review the requirements

Review the skill, website, and customer requirements in Prerequisites.

Step 2: Configure your custom skill and implement account linking

Before you add code to link accounts by voice, you must configure your custom skill and implement traditional account linking.

To configure your custom skill and implement traditional account linking

  1. Sign in to the Alexa developer console and navigate to your custom skill.
  2. Select the Build tab.
  3. On the left, click TOOLS, and then click Account linking.
  4. Turn on Do you allow users to create an account or link to an existing account with you?.
  5. If you want to keep account linking as optional, turn on Allow users to enable skill without account linking.
  6. Turn on Allow users to link their account to your skill using voice.
  7. Fill in the rest of the account linking settings based on the information in Configure an Authorization Code Grant and save the skill.
  8. Implement traditional account linking. For implementation details, see Steps to Implement Account Linking in Your Skill.

Step 3: Add voice-forward account linking to your skill code

The following procedure outlines the steps to add voice-forward account linking to your custom skill code.

To add voice-forward account linking

  1. Implement a handler to initiate the voice-forward account linking flow by transferring control to the Amazon-owned voice-forward account linking skill.
    For details, see Implement a handler to request the task to initiate voice-forward account linking.
  2. Implement a handler to receive a response from the Amazon-owned voice-forward account linking skill after the account linking task is complete.
    For details, see Implement a handler to get the response on the task to initiate voice-forward account linking.
  3. As with other methods of account linking, you must include skill code to get the user's access token from Alexa's requests, validate the access token, and use it to retrieve the necessary user information from your resource server.
    If your skill doesn't maintain a resource server, you can retrieve LWA user_id by making a call to LWA.
  4. (Optional) If you need the customer's profile information, you must add fallback logic that calls the Customer Profile API when the voice-forward account linking flow is complete. This is because the account linking token that you obtain during the voice-forward account linking flow only has the profile:user_id scope. To get the customer profile information, you must do the following steps:
    1. Get the customer's user_id by using the access token you received from the voice-forward account linking response to call LWA.
    2. Use the returned apiAccessToken to call the Customer Profile API to get the customer's information.

Step 4: Test your implementation

Use the developer console to test your implementation in the following way.

To test your implementation

  1. Sign in to the Alexa developer console.
  2. From the skill list, select your skill.
  3. At the top, click the Test tab.
  4. On the left, under the header bar, for Skill testing is enabled in, select Development.
    For details, see Test your skill in the developer console. Alternatively, you can test your skill by using the Alexa app installed on your iOS or Android mobile device. For details, see Test with the Alexa app.
  5. On an Echo device, launch your skill and then test it with different scenarios, such as the examples provided in User experience for voice-forward account linking.
  6. Test different customer account configurations, such as a test account with no voice profile, a voice profile without Personalize skills enabled, and so on.

Step 5: Certify your skill

After you build your skill and test it with your account, you can submit your skill for certification. For details about certifying a custom skill, see Certification Requirements.