Skip to content
Phillip Markert edited this page Oct 20, 2015 · 1 revision

Here are the steps that I like to do to setup a new Alexa skill using Wavelength.

Create a new empty lambda function in AWS using node as the engine. Name your function whatever your project name is going to be.

Make sure that you have AWS credentials setup in your ~/.aws/credentials file (see AWS documentation). If you can run the AWS command-line client, then you are in good shape.

Create a new project folder for your project, name it the same thing as your Lambda function.

Inside of that folder, initialize a new npm module with ```npm init``. Answer the questions and you will get a package.json file.

Install the grunt and grunt-aws-lambda modules (saving them as development dependencies in your package.json)

npm install --save-dev grunt
npm install --save-dev grunt-aws-lambda

Now setup a Gruntfile.js to customize your lambda configuration. I like to use the following:

var grunt = require('grunt');
grunt.loadNpmTasks('grunt-aws-lambda');

grunt.initConfig({
    lambda_invoke: {
        default: {
	    file_name: process.env.EVENT_FILE || "event.json",
        }
    },
    lambda_deploy: {
        default: {
            arn: process.env.LAMBDA_ARN,
            timeout: process.env.LAMBDA_TIMEOUT || 60 // Set to the number of seconds for timeout
        }
    },
    lambda_package: {
        default: {
        }
    }
});

grunt.registerTask('deploy', ['lambda_package', 'lambda_deploy']);

Then I setup a .gitignore file at the root of my project with the following files. (NOTE: this is very important even if you aren't using git to manage the source, otherwise, the dist folder will get packaged with your deployment and each time you package, your archive will get exponentially larger.)

dist
node_modules

Then you need to add wavelength as a dependency

npm install --save wavelength

Now you are ready to code. Edit the index.js and add your code. When you are ready to deploy, you will need to get the ARN (identifier) of the empty Lambda function you created in the AWS console. When you find that ARN, you will pass it into the grunt task to tell it where/how to deploy your code.

LAMBDA_ARN=arn:aws:lambda:us-east-1:XXXXXXXXXX:function:[YOUR_LAMBDA_FUNCTION_NAME] grunt deploy

Then you can go into the Alexa developer portal and give it the ARN of your function to invoke.

Clone this wiki locally