Skip to content

Latest commit

 

History

History
90 lines (52 loc) · 7.88 KB

4-testing.md

File metadata and controls

90 lines (52 loc) · 7.88 KB

Build An Alexa Fact Skill

Voice User InterfaceLambda FunctionConnect VUI to CodeTestingCustomizationPublication

Testing Your Alexa Skill

So far, we have created a Voice User Interface and a Lambda function, and connected the two together. Your skill is now ready to test.

  1. Go back to the Amazon Developer Portal and select your skill from the list. You may still have a browser tab open if you started at the beginning of this tutorial.

  2. Open the "Test" tab on the left side.

  3. Understand the voice simulator. While it's not specific to your skill, the Voice Simulator is a valuable testing tool for every skill. Type a word into the box, and click the "Listen" button to hear how Alexa will pronounce it. To make changes to her pronunciation, use Speech Synthesis Markup Language (SSML) to modify how Alexa will interpret text to speech. Try these examples:

    <say-as interpret-as="number">12345</say-as>
    <say-as interpret-as="ordinal">12345</say-as>
    <say-as interpret-as="digits">12345</say-as>

    Return to the Voice Simulator as needed to ensure that Alexa says words and phrases as you would expect.

  4. Test your skill with the Service Simulator. To validate that your skill is working as expected, use the Service Simulator. In the Enter Utterance text box, type "open reindeer trivia"

    Service Simulator Tips

    • After you click the "Ask [Your Skill Name]" button, you should see the Lambda Request and Lambda Response boxes get populated with JSON data like in the screenshot above.

    • Click the Listen button in the bottom right corner to hear Alexa read the response.

    • If you receive a response that reads: "The remote endpoint could not be called, or the response it returned was invalid," this is an indication that something is broken. AWS Lambda offers an additional testing tool to help you troubleshoot your skill.

  5. Configure a test event in AWS Lambda. Now that you are familiar with the request and response boxes in the Service Simulator, it's important for you to know that you can use your requests to directly test your Lambda function every time you update it. To do this:

    1. Enter an utterance in the service simulator, and copy the generated Lambda Request for the next step.

    2. Open your Lambda function in AWS, open the Actions menu, and select "Configure test events."

    3. Select "Create New Test Event". Choose "Alexa Start Session" as the Event Template from the dropdown list. You can choose any test event in the list, as they are just templated event requests, but using "Alexa Start Session" is an easy one to remember.

    4. Type in an Event Name into the Event Name Dialog box. Delete the contents of the code editor, and paste the Lambda request you copied above into the code editor. The Event Name is only visible to you. Name your test event something descriptive and memorable. For our example, we entered an event name as "startSession". Additionally, by copying and pasting your Lambda Request from the service simulator, you can test different utterances and skill events beyond the pre-populated templates in Lambda.

    5. Click the "Create" button. This will save your test event and bring you back to the main configuration for your lambda function.

    6. Click the "Test" button to execute the "startSession" test event.

      This gives you visibility into four things:

      • Your response, listed in the "Execution Result."

      • A Summary of the statistics for your request. This includes things like duration, resources, and memory used.

      • Log output. By effectively using console.log() statements in your Lambda code, you can track what is happening inside your function, and help to figure out what is happening when something goes wrong. You will find the log to be incredibly valuable as you move into more advanced skills.

      • A link to your CloudWatch logs for this function. This will show you all of the responses and log statements from every user interaction. This is very useful, especially when you are testing your skill from a device with your voice. (It is the "Click here" link in the Log Output description.)

  6. Other testing methods to consider:

  7. If your sample skill is working properly, you can now customize your skill.