Summer in the Health Cloud: AWS Lambda Slack Bot

Summer is famous for its flings, and our R&D department (basically our devs having fun with new tech) chose their first week of summer crush – AWS Lambda (before another one catches their eye next week – IBM Bluemix OpenWhisk).  

In just a couple of hours in a relaxed summer atmosphere (courtesy of our HR department for providing these amazing lounge chairs) our devs were able to test AWS Lambda by making a Slack Bot. The idea was to check how we could automize and build a development environment for a healthcare client – meaning it needed to be HIPAA compliant (whence AWS Lambda and Slack).

AWS Lambda Slack Bot


To create AWS Lambda Slack bot we first needed to configure the following resources:

Resource name Resource description
AWS API Gateway AWS Service that enables users to create API endpoints.

AWS Lambda Function Implementation of bot logic.
Slack Integration Slack can be integrated with AWS Lambda using: Slack Slash Commands, Slack WebHooks or with Slack Application. In this presentation we are covering the Slack Slash Command.

For those who have no prior knowledge of Lambda, we scraped up some information from several online resources.

What is AWS Lambda?

AWS Lambda is a compute service that lets you run code without provisioning or managing servers. The code runs on Amazon Elastic Compute Cloud (Amazon EC2) instances across multiple Availability Zones. AWS Lambda supports (Node.js, Java, C# and Python).

Details can be found in the following location:

One key to Lambda is that customers only pay for the service when functions are executed (so, this may or may not suit you, but is an interesting setup).

How it works?

Possible use cases for AWS Lambda are given in the AWS documentation:

The use case covered in this presentation is: “On-demand Lambda function invocation over HTTPS (Amazon API Gateway)”.

In this use case, the AWS Lambda function is invoked over HTTPS. To accomplish this we need to create the API endpoint and then configure it so that it invokes our Lambda on request. For this we use the AWS API Gateway service:

Programming model

You can find a description of the Lambda function programming model at this link:

The simple function can be programmed directly in the AWS console online interface. In cases when the Lambda function logic is more complex it can be coded locally and uploaded as a ZIP file.


The following are some node libraries that can be used to automatize Node AWS Lambda development:

Building the bot

In this example we will use the Claudia Bot Builder to create and publish our bot code on AWS.

We need to install and configure the AWS CLI, because the Claudia Bot Builder uses it.

Setup AWS CLI (Command Line Interface)

The AWS CLI is a command line utility that provides a consistent interface for interacting with all parts of AWS. The documentation can be found here:

The best way to install it on windows is to use the MSI Installer:

Once the client is installed we need to setup a profile:

The profile consists of:

  •      aws_access_key_id
  •      aws_secret_access_key

You can generate the id and key in the AWS online web console, by going to:

Services > IAM > Users > (Select user) > Security credentials > Create access key.

It is recommended to create a developer user and use it for id and key generation and not to use your master AWS user for this.

Implement the function

Before we start the implementation, we need to install the Claudia node package globally:

Run the following command:

npm install claudia –g

Create new node project by running the command:

npm init


Install the Claudia Bot Builder package:

npm install claudia-bot-builder –S

Create a file named bot.js in the project root folder and insert the following code in it:

var botBuilder = require('claudia-bot-builder');

module.exports = botBuilder(function(message) {

    console.log('got text', message.text);

    console.log('full response', JSON.stringify(message.originalRequest));

return 'Thanks for sending ' + message.text + '! Your message is very important to us!';


Deploy and connect with Slack


Setup Slack Slash Command

To create Slash Commands, go to the custom integrations page on slack, select “Slash Commands,” and select Add Configuration.

The custom integrations Slack page URL is similar to the following, just replace “yourteam” with your team name: https://{yourteam}

The Token will be generated for the slash command. The token value will be needed to configure the AWS Lambda bot.

Deploy Lambda Function

To deploy the function to AWS we run the following command:

claudia create --region us-west-1 --api-module bot --configure-slack-slash-command

Please note that you can use a different region if you need.

You will be prompted to enter the:

  •      Slack token – Paste the value from the Slack Slash Command token page.
  •      Outgoing webhook token – type none, because it is needed by claudia and we are not using it.

After the command creates all resources on AWS, it will display the URL of the AWS API Gateway that was created.


Your Slack slash command Request URL (POST only) is

This URL needs to be copied to the Slack Slash Command page URL field.


Open slack and insert your slash command followed by any other text.

In my example the slash command is /aws2

If I enter the command in the Slack:

lambda 0.png

The response AWS sends is:

lambda 5.png

AWS Resources

The following AWS resources were created in this process:

The API Gateway


The Lambda Function

Picture1lambda 2.png

The security role for the function

lambda 3.png

Interesting Resources


Possible use cases in healthcare?


This is a great way to do a quick test of your ideas in a secure way. All healthcare segments (payers, provider and product companies) can benefit from this tool by being able to build solutions fast while shortening the go-to market process.

In the meantime, IBM prepared their response to AWS’s Lambda, thanks to deeper partnerships with Apple, GitHub, and VMware. IBM is also launching a new cloud service called Bluemix OpenWhisk. We also had the chance to play with it and if we must pick a winner for us it would be OpenWhisk, but then again being IBM’s premier partner we might be biased.

Until the next episode of Summer in the Health Cloud our team wishes you sunny SF weather.

Author: Digital Health Team
Like this article? Share it!