Test Skills in Visual Studio Code

You can use the Alexa Skills Toolkit (ASK Toolkit) for Visual Studio Code (VS Code) to test your skill while you are building it locally. You can test your local skill without leaving VS Code by using the VS Code Alexa simulator page. You can also test your local skill by using other methods such as the Alexa simulator in the Alexa developer console and the ASK CLI.

For prerequisites and installation instructions, see Get Started with the ASK Toolkit for VS Code.

Prerequisites

Before you can invoke your local skill, add ask-sdk-local-debug to your skill project. Follow the instructions for your SDK language to add ask-sdk-local-debug to your skill:

Test your local Alexa skill

To test your local skill in VS Code

  1. Create a launch.json file for your skill, if you don't already have one, by doing the following:

    1. Open the Run menu and then choose Add Configuration…. The Select Environment dialog appears.
    2. Choose your programming language, Node.js or Python. The launch.json file is added to your project and opens in the editor.
  2. Edit the launch.json file to add the Alexa debugger, if you haven't already, by doing the following:

    1. Open the Run menu and then choose Add Configuration… A list of options appears.
    2. Choose ASK: Alexa Skills Debugger (Node.js) or ASK: Alexa Skills Debugger (Python). The configuration code is added to the launch.json file.
    3. Save the changes to the launch.json file.
  3. Open the Run menu and then choose Start Debugging. Your skill code starts and a websocket connects from your local machine to the Alexa proxy service. Requests to your skill are now routed directly to your local skill code as long as the connection with the Alexa proxy service is open. The connection remains open for one hour. You can't create more than one connection to a skill.

  4. Test your skill by using one of the following methods:

To stop testing locally, open the Run menu and then choose Stop Debugging. This closes the connection to the Alexa proxy service and Alexa reverts to invoking the endpoint that's configured for your skill instead of your local skill.

Test your skill in the VS Code Alexa simulator

You can test your skill by using the Skill Simulation page in the VS Code IDE. By using the skill simulator, you can send utterances to Alexa and receive responses without leaving the VS Code IDE.

The following screenshot shows the Skill Simulation page in the Visual Studio Code IDE:

The skill simulation page in the VS Code IDE

Use the VS Code Alexa simulator

To test your local skill in the VS Code Alexa simulator

  1. In the activity bar, click the Alexa icon. The Alexa Skills Toolkit side bar appears.
  2. Expand Skills, expand your skill, expand Test skill, and then choose Open simulator. The Skill Simulation page appears.
  3. In the Talk to Alexa section, for Skill stage, choose Development. This step enables your skill for testing, and activates the utterance text box at the bottom of the page.
  4. For Locale, choose the language and locale that you want to test. Your skill must contain an interaction model for the language and locale that you select. For details, see Interaction Model.
  5. In the text box at the bottom of the page enter an utterance and then click Send. Your request is sent to Alexa, and the response appears. After you receive the response, you can do the following:

    • Select the Skill I/O tab to view the JSON for the most recent request and response.
    • Select the Execution Info tab to view information such as considered intents.
    • Select the Device Preview tab to see how the response from your skill appears on a device screen. Use Change viewport to choose from round, small, medium, large, or full-screen TV views.
  6. Repeat the previous step as needed. You can enter new utterances, or use the up and down arrows on your keyboard to enter previous utterances quickly. You can't enter a new utterance until Alexa has responded to the previous request.
  7. At any time, click the Reset button to clear the utterances and responses in the Talk to Alexa section.
  8. Enter exit in the text box and click Send to disable your skill for testing and end your testing session.

Save and replay sessions in the VS Code Alexa simulator

While you test your skill, you might want to send the same utterances to Alexa repeatedly. You can save the utterances that you enter during a test session and replay them later.

To save and replay a test session in the VS Code Alexa simulator

  1. To save a session, click the Export button. Your utterances are saved as json and you are prompted for a location to save the file.
  2. To replay a session, in the Alexa Skills Toolkit side bar, expand Skills, expand your skill, expand Test skill, and then choose Replay session. You are prompted for the location of a file that you saved previously. After you specify the file, the utterances replay in the simulator.
  3. Enter exit in the text box and click Send to disable your skill for testing and end your testing session.