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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file ask-sdk-local-debug-1.1.0.tar.gz.

File metadata

  • Download URL: ask-sdk-local-debug-1.1.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.6

File hashes

Hashes for ask-sdk-local-debug-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6180a0d48ed2a9330e4506076a9cf4afc46310208b5e7d52e8cc11781e7c9156
MD5 7aeba049d07760d901c6fbe391b2bf6f
BLAKE2b-256 96b7814f0da8c7a55304ba7708dd8b9fb9eb4939b216ab30ace6313db4bc615c

See more details on using hashes here.

File details

Details for the file ask_sdk_local_debug-1.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: ask_sdk_local_debug-1.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.6

File hashes

Hashes for ask_sdk_local_debug-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 373c1ba75d4a1c5e76d8c90319171352fbbf83b151000bfc55da37efe331bc50
MD5 0ffca31c86cb6ef3a4746f2fe7c16718
BLAKE2b-256 829fa5af68dcfd4bc0a0e5511c87f4ae84a27a463fdde7981d4004287f64c522

See more details on using hashes here.

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