Build a Smart Home Skill
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.
Substeps to test the smart home skill
Complete the following substeps to test that you can control the virtual light bulb by using the smart home skill.
- Enable your skill and account linking
- View the device
- Test your skill with voice
- View the skill log entries
Substep 5.1: 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
- Sign in to the Alexa app on your mobile device with the same credentials as your Alexa developer account.
- To find your skill in the Alexa app, tap More, and then tap Skills & Games.
- In Skills & Games, tap Your Skills.
- Scroll the skill types to the right, and then tap Dev.
- Tap my-smart-home-skill, and then tap ENABLE TO USE.
- When Alexa prompts you, sign in to your Amazon developer account.
- To allow access to the skill, tap Allow, and then tap CLOSE.
On success, you see the message, "my-smart-home-skill has been successfully linked." If account linking fails, check your account linking configuration in the Alexa developer console in Step 4: Set up Account Linking. If you make changes to the account linking configuration or your discovery response, disable your skill in Your Skills, and then go back to Substep a: Enable your skill and account linking.
Substep 5.2: View the device
After the skill is enabled and linked, 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. After Alexa finds your device, the Sample light device displays on the Devices page in the Alexa app.
If discovery fails, check the logs for your Lambda function. Use the logs to troubleshoot the issue. Common issues include incorrectly formatted discovery responses. If you make changes to the discovery response, disable your skill in the Alexa app under Your Skills, and then go back to Substep a: Enable your skill and account linking.
Substep 5.3: 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
- Sign in to the Alexa developer console.
- From the skill list, locate your skill.
- Under ACTIONS, from the drop-down menu in your skill's row, select Edit.
- Open the Test page.
- To test with voice, in the Will you allow developer.amazon.com to use your microphone? pop-up, select Allow.
- 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."
Substep 5.4: 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
- Sign in to the AWS management console.
- Navigate to the CloudWatch console.
- In the CloudWatch console, from the left menu under Logs, click Log groups.
- Under Log group, to open the log stream for your skill, click /aws/lambda/my-smart-home-skill.
- Under Log stream, to view logs for each directive that Alexa sent to the skill, click the log entry that you want to view.
- 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 toUS East (N. Virginia)
. If the region isn'tUS 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
andTurnOff
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
- Navigate to the Lambda console.
- From the left menu, click Functions.
- Under Functions, find the my-smart-home-skill, and then select the check box.
- From the Actions drop-down menu, select Delete.
To delete the IAM role
- Navigate to the IAM dashboard.
- On the IAM dashboard, from the left menu under Access management, click Roles.
- On the IAM > Roles page, select lambda_smart_home_skill_role, and then click Delete.
To delete the IAM policy
- On the IAM dashboard, from the left menu under Access management, click Policies.
- On the IAM > Policies page, select smart_home_skill_policy, and then click Delete.
- From the Actions drop-down menu, select Delete.
To delete the skill
- Sign in to the Alexa developer console.
- On the Skills tab, under SKILL NAME, find my-smart-home-skill that you created in Step 1: Create a Smart Home Skill.
- From the drop-down menu under ACTIONS, select Delete.
Last updated: Feb 02, 2024