SMS chat bots and AWS Lambda go well together if you want to build a bot that can reach people all over the world without worrying about your underlying infrastructure. In just a few steps we’re going to see how easy it is to deploy a Node.js chat bot on Lambda using Claudia.js.

What is Claudia.js?

I’ve always liked the idea of Amazon’s Lambda service, but the first time I tried to use it I found the deployment process troubling. As I uploaded the zip file of my project to the AWS dashboard, yes that is how you deploy to Lambda, to test my work I thought to myself, “There must be a better way.”

Thankfully I wasn’t the only one, so tools like Claudia.js, Serverless and Seneca were born. Each of them offer various features and different methods of deploying apps to Lambda. I was recently drawn to Claudia.js not only because it makes deploying applications to Lambda easier, but because it comes with Claudia Bot Builder, a framework that abstracts away the differences between a host of bot platforms. Together they make it really easy to write and deploy bots to Lambda, so let’s build an SMS bot to see how it all works.

Before we start

There are a few things we’re going to need to get this project off the ground

A Twilio account and a Twilio phone number that can receive SMS messages

An AWS account

Node.js v4.3.2, the version that runs on Lambda (you can install multiple versions of Node.js using nvm)

Don’t worry if you’re just trying this out, both Twilio and AWS have free tiers that you can use to build this bot.

Now we need to prepare AWS for use with Claudia.js.

Setting up AWS

Claudia.js will need access to your AWS account, so it’s best to create a profile that only contains the permissions that Claudia.js needs to deploy our bot. To do so, go to the Users section of the Identity & Access Management service. Create a new user and give it a recognisable name.

Make sure “Programmatic Access” is checked. Click “Next: Permissions”. On the next screen you will be able to select the permissions the user has. We need three permissions for this user: AWSLambdaFullAccess, IAMFullAccess and AmazonAPIGatewayAdministrator.

Click “Next: Review” to review your user and ensure they have the correct permissions, click “Create User”. You should see the success screen and your new user’s Access Key ID and Secret Access Key. Don’t move on from this screen yet, these credentials will only be shown to you once!