+ All Categories
Home > Technology > Building your own slack bot on the AWS stack

Building your own slack bot on the AWS stack

Date post: 15-Apr-2017
Category:
Upload: torontonodejs
View: 719 times
Download: 0 times
Share this document with a friend
28
Building your own Slack bot on the modern AWS stack Andrew Carreiro Platform Architect, Klick Health
Transcript
Page 1: Building your own slack bot on the AWS stack

Building your own Slack bot on the modern AWS stackAndrew CarreiroPlatform Architect, Klick Health

Page 2: Building your own slack bot on the AWS stack

Demo

Page 3: Building your own slack bot on the AWS stack

Basic Structure

Page 4: Building your own slack bot on the AWS stack

SlackChat app that lets us POST data by typing /8ball

Page 5: Building your own slack bot on the AWS stack

Amazon API GatewayReceives the request from Slack, and routes the request to Lambda

Page 6: Building your own slack bot on the AWS stack

Amazon LambdaEvaluates the chat command, and returns a response.

Page 7: Building your own slack bot on the AWS stack

Amazon DynamoDBNoSQL backend for the app

Page 8: Building your own slack bot on the AWS stack

API Gateway

Lambda

DynamoDB

/8ball Should I try AWS?

POSTInvokes

Possible answers are saved & read

Responds

Responds

“Absolutely!” 8

Page 9: Building your own slack bot on the AWS stack

DynamoDB

Page 10: Building your own slack bot on the AWS stack

Why DynamoDB?

- Need for this app: persistent data store across requests- A JSON file on S3 also a possibility given scale- Something like Redis (Amazon Elasticache) could also work, but price

prohibitive- DynamoDB pricing structure is confusing, but you get 25GB storage and

~200M requests per month in the Free Tier

Page 11: Building your own slack bot on the AWS stack

API Gateway

Lambda

DynamoDB

/8ball Should I try AWS?

POSTInvokes

Possible answers are saved & read

Responds

Responds

“Absolutely!” 8

Page 12: Building your own slack bot on the AWS stack

Writing the Lambda Function

Page 13: Building your own slack bot on the AWS stack

What is Amazon Lambda?

- Old method: I need a server to execute my code- Server sits idle sometimes, other times is completely overwhelmed

- Use AWS computing power, and be billed by the 100ms- Theoretically infinitely scalable, if you have the money- Can run Node, Java, or Python

Page 14: Building your own slack bot on the AWS stack

Coding for Lambda

- Amazon Lambda uses Node.js: v0.10.36- Deployment in it’s most basic state involves a manual zip upload

- lightweight is best-- adding Babel.js was a pain for uploads

- Expect your tests to work locally

Page 15: Building your own slack bot on the AWS stack

Coding for Lambda

Create a user and credentials for what you need:https://console.aws.amazon.com/iam/home?region=us-east-1#users

Page 16: Building your own slack bot on the AWS stack

~/.aws/config

[default]output = jsonregion = us-east-1

Coding for Lambda: Config and Credentials

~/.aws/credentials

[default]aws_access_key_id = LINDNWVQQKAKP7BIA5TXaws_secret_access_key = L4Q8mgs4o4dO4qe3RBbXPSZPfhOQFnj1U2dlDn30

Page 17: Building your own slack bot on the AWS stack

Lambda Example Code

Page 18: Building your own slack bot on the AWS stack

Deploying Lambda

Page 19: Building your own slack bot on the AWS stack

Approaches

https://github.com/mentum/lambdaws

https://github.com/jaws-framework/JAWS

Page 20: Building your own slack bot on the AWS stack

Manual Lambda setup

Page 21: Building your own slack bot on the AWS stack

API Gateway

Lambda

DynamoDB

/8ball Should I try AWS?

POSTInvokes

Possible answers are saved & read

Responds

Responds

“Absolutely!” 8

Page 22: Building your own slack bot on the AWS stack

Setting up API Gateway

Page 23: Building your own slack bot on the AWS stack

API Gateway

Lambda

DynamoDB

/8ball Should I try AWS?

POSTInvokes

Possible answers are saved & read

Responds

Responds

“Absolutely!” 8

Page 24: Building your own slack bot on the AWS stack

Adding a Slash Command on Slack

Page 25: Building your own slack bot on the AWS stack

GitHub Repogithub.com/andrewcarreiro/slack-8ball

Page 26: Building your own slack bot on the AWS stack

RyanRay URL Encoding gisthttps://gist.github.com/ryanray/668022ad2432e38493df

Page 27: Building your own slack bot on the AWS stack

Klick Health is hiring!

Page 28: Building your own slack bot on the AWS stack

Thanks


Recommended