August 2017

Professional Deployment of Alexa Skills based on NodeJS

Writing Alexa Skills for the Amazon Echo Dot is pretty easy. You can start with the templates at Amazon Developer Blog. When you finished, you simply upload your code to AWS lambda as a Zip file. For a one-time deployment this is straightforward, but if you want to develop a professional application and have multiple deployments it is not a good way. Also if you use a build system like Jenkins, an automatic deployment would be mandatory.

To face this issue, at least if you develop with NodeJS, you can use a tool called “ClaudiaJS” (https://claudiajs.com/claudia.html).
With a simple command (claudia update) your NodeJS based skill gets zipped and uploaded. So this tutorial is about the configuration and usage of that tool.

First of all to configure ClaudiaJS for Lambda deployment, you need to have an AWS account with IAM and Lambda.

  1. Login to your AWS account and choose IAM
  2. Create a new group with the privileges IAM full access, Lambda full access and API Gateway Administrator
  3. Create a user and attach it to the group you created before
    1. Tick “Programmatic access”
  4. In the review tab, you can see the Access key ID and the Secret access key – we will need them later

The next step is to configure your AWS credentials on your local machine

  1. Create a new folder under /Users/your-user/.aws
  2. Create a file named credentials
  3. The content of the file looks like (fill in the previously generated keys):
    [default]
    aws_access_key_id = your-access-key-id
    aws_secret_access_key = your-secret-access-key

If you finished that step, you can install ClaudiaJS

  1. Choose a folder where you want to create your new NodeJS application
  2. Open up a command prompt in that folder
  3. Type npm init
  4. Type npm install claudia -g
  5. Create a new file like server.js
    exports.handler = function (event, context)
    {
         context.succeed(‘hello world’);
    };
  6. Type claudia create –region us-east-1 –handler server.handler
    1. The handler, is the name of your file where is the entrypoint of your application. Like server.js or app.js.
    2. This will create a new lambda function and upload your content
  7. You can test if the creation succeeded by typing: claudia test-lambda
  8. For updates, you can simply use: claudia update

To use the new handler with Alexa Skills, you must select Alexa Skills Kit as trigger in the AWS lambda web console.
ClaudiaJS supports more tasks like defining tests or checking the logs. You can find the full documentation at https://claudiajs.com/documentation.html