Step 5: Test the Skill

In the previous step, you completed account linking between Alexa and your skill. Now, in this final step of the tutorial, you can test the smart home skill in the Alexa app and with voice on an Alexa-enabled device and the Alexa simulator.

Steps to test the smart home skill

To test that you can control the virtual light bulb by using the smart home skill, complete the following steps.

Step a: Enable your skill and account linking

In this substep you enable your skill and perform account linking in the Alexa app.

To enable your skill and account linking in the Alexa app

  1. Sign in to the Alexa app on your mobile device with the same credentials as your Alexa developer account.
  2. To find your skill in the Alexa app, tap More, and then tap Skills & Games.
  3. In Skills & Games, tap Your Skills.
  4. Scroll the skill types to the right, and then tap Dev.
  5. Tap my-smart-home-skill, and then tap ENABLE TO USE.
  6. When Alexa prompts you, sign in to your Amazon developer account.
  7. To allow access to the skill, tap Allow, and then tap CLOSE.
  1. Sign in to the Alexa app in your browser with your Alexa developer account credentials.
  2. To find your skill, on the left, select Skills.
  3. On the All Skills page, click Your Skills.
  4. On the Your Skills page, click Dev Skills.
  5. Scroll to find the skill you just created, and then select my-smart-home-skill.
  6. On the my-smart-home-skill page, to link your account with the skill, click ENABLE.
  7. When Alexa prompts you in another browser tab or window, sign in to your Amazon developer account.
  8. If account linking is successful, Alexa displays my-smart-home-skill has been successfully linked.
  9. Close the browser tab.

On success, you see the message, "my-smart-home-skill has been successfully linked." If account linking failed, check your account linking configuration in the Alexa developer console in Step 4: Set up Account Linking.

Step b: Discover the device

After the skill is enabled and linked, you can discover the virtual light bulb in the Alexa app on your mobile device or in your browser.

To discover the virtual light bulb in the Alexa app

  1. On Discover Devices in the Alexa app, tap DISCOVER DEVICES.
    Alexa sends a Discover request to your skill to learn about the connected devices. Your skill returns the discovery response with the details about the virtual light bulb device.
  2. After Alexa finds your device, tap SET UP DEVICE, and then tap DONE.
    The Sample light device displays in the app.
  1. On the my-smart-home-skill page, tap DISCOVER DEVICES.
    Alexa sends a Discover request to your skill to learn about the connected devices. Your skill returns the discovery response with the details about the virtual light bulb device.
  2. After Alexa finds your device, on the Devices page, you see Sample light.

Step c: Test your skill with voice

If you have an Amazon Echo or another Alexa-enabled device associated with your Amazon developer account, you can ask Alexa to turn the light on and off with one of the following utterances.

User: Alexa, turn on the sample light.
User: Alexa, turn off the sample light.

You can also test your skill with voice or text in the Alexa simulator.

To test your skill in the Alexa simulator

  1. Sign in to the Alexa developer console.
  2. From the skill list, locate your skill.
  3. Under ACTIONS, from the drop-down menu in your skill's row, select Edit.
  4. Open the Test page.
  5. To test with voice, in the Will you allow developer.amazon.com to use your microphone? pop-up, select Allow.
  6. In the simulator pane, enter an utterance.
    Or, to use voice, click and hold the microphone, and then speak an utterance.

If the test is successful, Alexa says, "OK."

Step d: View the skill log entries

AWS Lambda logs events, errors, and debugging information in AWS CloudWatch.

To view the skill log entries on the CloudWatch console

  1. Sign in to the AWS management console.
  2. Navigate to the CloudWatch console.
  3. In the CloudWatch console, from the left menu under Logs, click Log groups.
  4. Under Log group, to open the log stream for your skill, click /aws/lambda/my-smart-home-skill.
  5. Under Log stream, to view logs for each directive that Alexa sent to the skill, click the log entry that you want to view.
  6. Review the requests and values from Alexa and the responses from the Lambda function.

Congratulations!

After you review the requests from Alexa and the responses from the Lambda function, and your logs in AWS CloudWatch are clean, you finished Step 5 and completed the Build a Smart Home Skill tutorial successfully.

Troubleshooting guide

You can use the Smart Home Devices page of the Alexa developer console to view device state to test and debug your Smart Home skill.

Review the following items to find possible resolutions for common issues.

Q: Why can't I see the my-smart-home-skill in the Alexa app?

Make sure that you log into the Alexa app with the same Amazon developer account that you used to create the skill.

Q: Why can't doesn't account linking from the Alexa app work?

Make sure that you log into the Alexa app with the same Amazon developer account that you used to create the skill. Also, verify the account linking configuration for your skill in the developer console. Check that you copied the client ID and client secret correctly from LWA to the developer console. Be sure that there are no any trailing spaces in these values. For details, see Step 4: Set up Account Linking.

Q: Why can't Alexa discover the sample light?

Check the logs for your Lambda function to see if your skill received a Discover directive. If it didn't receive the directive, check that you have the correct ARN configured for your skill. If you have the right ARN and are still not receiving a directive, on your Lambda function page, make sure that the AWS Lambda region is set to US East (N. Virginia). If the region is not US East, go back to Step c: Create a Lambda function.

Q: Why does Alexa say, "Sample light is not responding"?

Check the responses to the TurnOn and TurnOff directives in the logs. Verify that the response is formatted correctly and contains all the required properties. Compare your responses to the example responses in the Alexa.PowerController interface.

Clean up resources

After you complete the tutorial and start building your own skills, delete the resources that you no longer need.

To delete the Lambda function

  1. Navigate to the Lambda console.
  2. From the left menu, click Functions.
  3. Under Functions, find the my-smart-home-skill, and then select the check box.
  4. From the Actions drop-down menu, select Delete.

To delete the IAM role

  1. Navigate to the IAM dashboard.
  2. On the IAM dashboard, from the left menu under Access management, click Roles.
  3. On the IAM > Roles page, select lambda_smart_home_skill_role, and then click Delete.

To delete the IAM policy

  1. On the IAM dashboard, from the left menu under Access management, click Policies.
  2. On the IAM > Policies page, select smart_home_skill_policy, and then click Delete.
  3. From the Actions drop-down menu, select Delete.

To delete the skill

  1. Sign in to the Alexa developer console.
  2. On the Skills tab, under SKILL NAME, find my-smart-home-skill that you created in Step 1: Create a Smart Home Skill.
  3. From the drop-down menu under ACTIONS, select Delete.