Skip to content

Latest commit

 

History

History

tools

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Tools

Make me productive!

The following tools will enhance your developer experience.

  • Have Node.JS on your laptop command-line, and become familiar with NPM, the Node Package Manager.
  • Have GIT on your laptop.
  • Have the AWS Command Line Interface (AWS CLI) installed and configured.
  • Review the alexa-sdk documentation.

Developing Online

When creating a new AWS Lambda function, you can choose the alexa-skill-kit-sdk-factskill blueprint which automatically bundles in the alexa-sdk. You can delete this code, and paste in sample code from this cookbook. The online editor will work best if your skill code fits within a single file.

Working from your Laptop

You may want to develop from a project folder on your local laptop for a number of reasons:

  • You can create a project with more than one source file
  • You can bundle in external Node.JS modules via NPM
  • You can use your favorite text editor or IDE
  • You can run unit tests locally
  • You can upload your project to your personal GitHub repositoriy easily

Download from GitHub

You can download the entire Cookbook to your local hard drive in one of two ways:

  • Click the green Clone or download button from the home page, and download the zip file. Be sure to extract everything to a new folder.
  • If you have GIT installed, open a command prompt and run : git clone https://github.com/alexa/Cookbook

You can also create a new skill function from scratch. Create an empty folder, and add a file called index.js

Install required modules with NPM

The examples each contain a /src folder which contains the index.js source file. When the code runs within AWS Lambda, it relies on the alexa-sdk module, which is installed by default with the Fact skill blueprint. In order to test and deploy projects from your local laptop, you will need to bundle in required modules such as the alexa-sdk within your /src folder.

Follow these steps to install the alexa-sdk:

  1. Open a command prompt and navigate into the /src folder where your index.js lives.
  2. Verify you have Node.JS installed by typing npm --version
  3. Type npm install --save alexa-sdk
  4. You will notice a new folder called node_modules which contains an alexa-sdk folder.
  5. You can repeat and use any other Node modules to your project with the npm command.

Note: You can install the aws-sdk locally, however it is already available within Lambda and does not need to be bundled into your deployment.

You can now test your project from the command line, or package and deploy it to the AWS Lambda service.

Publishing to Lambda

Once you are ready to deploy your local code back into AWS Lambda, you can zip the contents of your /src folder (just the contents, not the /src parent folder) and publish the Zip archive to your Lambda function.

Manual steps:

  1. Within your file explorer tool, double-click into the /src folder
  2. Multi-select the index.js file, any other source files, the node_modules folder.
  3. Right-click and create a new zip file (zip, or send-to: compressed folder).
  4. Within the AWS Lambda console, create or locate the Lambda function.
  5. Within the Code section, locate the Code entry type dropdown.
  6. Click and select Upload a .ZIP file
  7. Locate and double click on the new zip file you made previously.
  8. You will need to click the blue "Save" button, or continue creating your new skill, for the upload to complete.

Automated steps:

  • You can choose to automate the packaging and publishing of your AWS Lambda project via a command line script. Read and follow the guide to Publishing Your Skill Code to Lambda via the Command Line Interface

  • Once the AWS CLI is setup, you can choose to use Node commands to deploy your function.

    • Navigate to the src/ folder and type npm deploy. This runs the commands defined in the scripts.deploy section of the src/package.json file. You will need to customize the function-name in a few places from the default of HelloWorld.

See also How To Test

Back to the Home Page