Running Skill Code Locally

Next, you’ll need to install the ask-sdk-local-debug library. The following npm install command, executed at the root of the skill project will install the local debugging library as a dependency in your skill project.

 $ ​​npm​​ ​​install​​ ​​--prefix​​ ​​lambda​​ ​​--save-dev​​ ​​ask-sdk-local-debug

Notice the use of the --lambda and --save-dev parameters. The --lambda parameter specifies the location of the fulfillment code as being in the lambda directory. (This assumes that you run npm install from the project’s root directory.) And because the local debugging library is a development-time dependency and is not needed by the skill itself, the --save-dev parameter ensures that the dependency will not be included when the skill’s fulfillment code is deployed.

Finally, it’s time to run the skill’s fulfillment code. This is made easy with the ASK CLI’s run command. From the skill’s root directory, run it like this:

 $ ​​ask​​ ​​run

After a few seconds, you should be able to test your skill using the Alexa Developer Console or an actual device connected to your developer account. You’ll know it’s hitting your local code because the request and response will be logged in the same console where run started the local run.

Although ask run is about as easy as it can get to kick off a local run of your skill’s fulfillment code, you’ll more likely want to specify the --watch option:

 $ ​​ask​​ ​​run​​ ​​--watch

With the --watch option, the local runner will restart if it detects a change to the fulfillment code. This enables an efficient development process in which you can test and make changes in rapid succession, without having to stop to redeploy.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset