Skip to main content

The ASK SDK Local Debug package provides Alexa Skills Kit debugger functionality

Project description

ASK SDK Local debug - Debugger for Python ASK SDK

ASK SDK Local Debug (ask-sdk-local-debug) is a package which enables you to test your skill code locally against your skill invocations by routing requests to your developer machine. This enables you to verify changes quickly to skill code as you can test without needing to deploy skill code to Lambda.

Quick Start

Installation

Assuming that you have Python and virtualenv installed, you can install the package from PyPi as follows:

$ virtualenv venv
$ . venv/bin/activate
$ pip install ask-sdk-local-debug

You can also install the package locally by following these steps:

$ git clone https://github.com/alexa/alexa-skills-kit-sdk-for-python.git
$ cd alexa-skills-kit-sdk-for-python/ask-sdk-local-debug
$ virtualenv venv
...
$ . venv/bin/activate
$ python setup.py install

Usage and Getting Started

Using Alexa SKills toolkit for VSCode

The Alexa Skills Toolkit for Visual Studio offer integrated support for local debugging. To get started, please review our technical documentation on how to Test your local Alexa skill using VSCode.

Using with other IDEs and Debuggers

  • To instantiate a connection to the local debugging service, retrieve the following details for your skill :
    • ACCESS_TOKEN :
      1. Install ASK CLI v2.

      npm install ask-cli@2 -g
      1. Generate the accessToken using ASK CLI

      ask util generate-lwa-tokens --scopes alexa::ask:skills:debug
      1. You will be directed to a Login with Amazon page. Sign in and retrieve your ACCESS_TOKEN from the terminal.

    • SKILL_ID : The ID of the skill you are trying to debug. Ensure that the developer account you used to login to obtain the access token has access to this skill.

    • HANDLER_NAME : The exported handler method (typically lambda_handler or handler). For example, please see the Hello world example.

    • FILE_NAME : The path to your skill code’s main file (typically lambda_function.py). This file or module contains the skill’s handler function.

    • REGION : The region of the developer account. The accepted values are NA(North America), FE(Far East), EU(Europe). Defaults to NA. Instructions on finding out your region can be found here.

  • Create a local_debug.py file in your skill’s lambda directory and add the following code :

    from ask_sdk_local_debug.local_debugger_invoker import LocalDebuggerInvoker
    
    if __name__ == "__main__":
        LocalDebuggerInvoker([
            '--accessToken', '<ACCESS_TOKEN>',
            '--skillId', '<SKILL_ID>',
            '--skillHandler', '<HANDLER_NAME>',
            '--skillFilePath', '<FILE_NAME>'
            "--region", "<REGION>" # Optional argument. Region defaults to NA.]
        ).invoke()
  • Configure your preferred IDE or other debugging tool to attach to the above process or execute directly from your preferred IDE. For example, in VS Code, this would be included in the launch.json:

    {
       "type": "python",
       "request": "launch",
       "name": "Skill Debug",
       "program": "<Absolute file path to local_debug.py>",
       "args": [
            "--accessToken", "<ACCESS_TOKEN>",
            "--skillId", "<SKILL_ID>",
            "--skillHandler", "<HANDLER_NAME>",
            "--skillFilePath", "<FILE_NAME>",
            "--region", "<REGION>" # Optional argument. Region defaults to NA.
        ]
    }

Things to note

  1. Local debugging is only available for a skill’s development stage.

  2. A connection remains active for 1 hour. You will need to reinstantiate the connection after 1 hour.

  3. All Alexa requests for the skill will be routed to your development machine while the connection is active.

  4. Only one connection session may be active for a given Skill ID and developer account.

Got Feedback?

  • We would like to hear about your bugs, feature requests, questions or quick feedback. Please search for the existing issues before opening a new one. It would also be helpful if you follow the templates for issue and pull request creation. Please follow the contributing guidelines!

  • Request and vote for Alexa features!

CHANGELOG

1.0.0

  • Initial release of ask sdk local debugger package.

1.1.0

This release contains the following changes :

  • region support in local debug invoker.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ask-sdk-local-debug-1.1.0.tar.gz (12.0 kB view hashes)

Uploaded Source

Built Distribution

ask_sdk_local_debug-1.1.0-py2.py3-none-any.whl (23.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page