Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Building your own Slack bot on
the modern AWS stack
Andrew Carreiro
Platform Architect, Klick Health
Demo
Basic Structure
Slack
Chat app that lets us POST data by typing /8ball
Amazon API Gateway
Receives the request from Slack, and routes the
request to Lambda
Amazon Lambda
Evaluates the chat command, and returns a response.
Amazon DynamoDB
NoSQL backend for the app
API Gateway
Lambda
DynamoDB
/8ball Should I try AWS?
POST
Invokes
Possible
answers are
saved & read
Responds
Responds
“Abs...
DynamoDB
Why DynamoDB?
- Need for this app: persistent data store across requests
- A JSON file on S3 also a possibility given scal...
API Gateway
Lambda
DynamoDB
/8ball Should I try AWS?
POST
Invokes
Possible
answers are
saved & read
Responds
Responds
“Abs...
Writing the Lambda
Function
What is Amazon Lambda?
- Old method: I need a server to execute my code
- Server sits idle sometimes, other times is compl...
Coding for Lambda
- Amazon Lambda uses Node.js: v0.10.36
- Deployment in it’s most basic state involves a manual zip uploa...
Coding for Lambda
Create a user and credentials for what you need:
https://console.aws.amazon.com/iam/home?region=us-east-...
~/.aws/config
[default]
output = json
region = us-east-1
Coding for Lambda: Config and Credentials
~/.aws/credentials
[def...
Lambda Example
Code
Deploying Lambda
Approaches
https://github.com/mentum/lambdaws
https://github.com/jaws-framework/JAWS
Manual Lambda
setup
API Gateway
Lambda
DynamoDB
/8ball Should I try AWS?
POST
Invokes
Possible
answers are
saved & read
Responds
Responds
“Abs...
Setting up API
Gateway
API Gateway
Lambda
DynamoDB
/8ball Should I try AWS?
POST
Invokes
Possible
answers are
saved & read
Responds
Responds
“Abs...
Adding a Slash
Command on Slack
GitHub Repo
github.com/andrewcarreiro/slack-8ball
RyanRay URL Encoding gist
https://gist.github.com/ryanray/668022ad2432e38493df
Klick Health is hiring!
Thanks
Upcoming SlideShare
Loading in …5
×

Building your own slack bot on the AWS stack

978 views

Published on

Andrew Carreiro presents at the Fall 2015 Toronto Node.js meetup.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Building your own slack bot on the AWS stack

  1. 1. Building your own Slack bot on the modern AWS stack Andrew Carreiro Platform Architect, Klick Health
  2. 2. Demo
  3. 3. Basic Structure
  4. 4. Slack Chat app that lets us POST data by typing /8ball
  5. 5. Amazon API Gateway Receives the request from Slack, and routes the request to Lambda
  6. 6. Amazon Lambda Evaluates the chat command, and returns a response.
  7. 7. Amazon DynamoDB NoSQL backend for the app
  8. 8. API Gateway Lambda DynamoDB /8ball Should I try AWS? POST Invokes Possible answers are saved & read Responds Responds “Absolutely!” 8
  9. 9. DynamoDB
  10. 10. 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
  11. 11. API Gateway Lambda DynamoDB /8ball Should I try AWS? POST Invokes Possible answers are saved & read Responds Responds “Absolutely!” 8
  12. 12. Writing the Lambda Function
  13. 13. 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
  14. 14. 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
  15. 15. Coding for Lambda Create a user and credentials for what you need: https://console.aws.amazon.com/iam/home?region=us-east-1#users
  16. 16. ~/.aws/config [default] output = json region = us-east-1 Coding for Lambda: Config and Credentials ~/.aws/credentials [default] aws_access_key_id = LINDNWVQQKAKP7BIA5TX aws_secret_access_key = L4Q8mgs4o4dO4qe3RBbXPSZPfhOQF nj1U2dlDn30
  17. 17. Lambda Example Code
  18. 18. Deploying Lambda
  19. 19. Approaches https://github.com/mentum/lambdaws https://github.com/jaws-framework/JAWS
  20. 20. Manual Lambda setup
  21. 21. API Gateway Lambda DynamoDB /8ball Should I try AWS? POST Invokes Possible answers are saved & read Responds Responds “Absolutely!” 8
  22. 22. Setting up API Gateway
  23. 23. API Gateway Lambda DynamoDB /8ball Should I try AWS? POST Invokes Possible answers are saved & read Responds Responds “Absolutely!” 8
  24. 24. Adding a Slash Command on Slack
  25. 25. GitHub Repo github.com/andrewcarreiro/slack-8ball
  26. 26. RyanRay URL Encoding gist https://gist.github.com/ryanray/668022ad2432e38493df
  27. 27. Klick Health is hiring!
  28. 28. Thanks

×