building serverless chat bots - aws august webinar series
TRANSCRIPT
© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Leo Zhadanovsky, Principal Solutions Architect, Amazon Web Services
Building Serverless Chat Bots
AWS Serverless Chatbot Competition
• Create a bot for Slack that runs on AWS Lambda and Amazon API Gateway
• Sponsored by AWS and Slack• Win tickets to AWS re:Invent and more
• Winners will receive mentions in the Serverless Keynote during re:Invent
• Submissions due by September 29• Get started: awschatbot.devpost.com
Agenda
What is ChatOps and why is it useful?What are Chat Bots?What are some examples of Chat Bots?What technologies can I use to easily build Chat Bots?How do I build Chat Bots with Slack?What are some risks with building Chat Bots?
What is ChatOps?
An approach to communication that allows teams to collaborate and manage many aspects of their infrastructure, code, and data from the comfort and safety of a chat room.
Why do I care about ChatOps?
Provides visibility into operations to anyone who has access to your chatChat solutions like Slack are highly extensible, have integrations with Lambda, and third party services, such as PagerDuty, Jira, NewRelic, GitHubBetter and easier than IRCNot behind a VPNMakes operations easy from mobile devices
Why?
Built-in archivingEasy dissemination of screenshots, attachments of filesMakes incident response, across teams much easier to handle
What are Chat Bots?
A computer program designs to simulate conversation with human users, especially over the InternetIn this context, such bots allow you to improve how you handle DevOps, making the process more efficient, visible, and simple
Examples
Monitoring• Many monitoring solutions, such as DataDog have built-in Slack
integration
Examples
Examples
Examples
CI/CD• Integration with Jenkins
Examples
Lambda/CloudWatch Events Integration
Examples
Yeobot• SQL Queries against your AWS account metadata
Burner (burnerapp.com)• SMS/Voicemail to Slack• Two way
Statuspage.io• Integrate private and public status feeds
Meekan• Schedule meetings
What technologies can I use to easily build Chat Bots?
AWS Lambda + API Gateway
AWS Lambda: Serverless computing
Run code without servers. Pay only for the compute time you consume. Be happy.
Triggered by events or called from APIs:• PUT to an Amazon S3 bucket• Updates to Amazon DynamoDB table• Call to an Amazon API Gateway endpoint• Mobile app back-end call• And many more…
Makes it easy to:• Perform real-time data processing• Build scalable back-end services• Glue and choreograph systems
Continuous scaling
No servers to manage
Never pay for idle – no cold servers
(only happy accountants)
Benefits of AWS Lambda
Pay-per request
• Buy compute time in 100 ms increments for 21 microcents
• Request charge of 20 microcents
• No hourly, daily, or monthly minimums
• No per-device fees
Never pay for idle!
Free Tier1 million requests and 400,000 GBs of compute
every month, every customer
Using AWS Lambda
Bring your own code• Node.js, Java, Python• Bring your own libraries
(even native ones)
Simple resource model• Select power rating from
128 MB to 1.5 GB• CPU and network
allocated proportionately• Reports actual usage
Flexible authorization• Securely grant access to
resources, including VPCs• Fine-grained control over
who can call your functions
Flexible use• Call or send events• Integrated with other AWS
services• Build whole serverless
ecosystems
Using AWS LambdaProgramming model• AWS SDK built in (Python
and Node.js)• Eclipse plugin (Java)• Lambda is the “webserver”• Use processes, threads,
/tmp, sockets normally
Stateless• Persist data using Amazon
DynamoDB, S3, or ElastiCache
• No affinity to infrastructure (can’t “log in to the box”)
Authoring functions• Author directly using the
console WYSIWYG editor• Package code as a .zip and
upload to Lambda or S3• Plugins for Eclipse and
Visual Studio• Command line tools
Monitoring and logging• Built-in metrics for requests,
errors, latency, and throttles• Built-in logs in Amazon
CloudWatch Logs
Amazon API Gateway: Serverless APIs
Internet
Mobile apps
Websites
Services
AWS Lambda functions
AWS
API Gateway cache
Endpoints on Amazon EC2
Any other publicly accessible endpointAmazon
CloudWatch
Amazon CloudFront
Amazon API Gateway
Benefits of Amazon API Gateway
Create a unified API front end for
multiple microservices
DDoS protection and throttling for
back-end systems
Authenticate and authorize requests
Slack Integrations
Integrated Apps
Slack Integrations
Incoming WebHooks• A simple way to post messages from external sources into Slack.
They make use of normal HTTP requests with a JSON payload, which includes the message and a few other optional details described later
Slack Integrations
Outgoing WebHooks• Allow you to listen for triggers in Slack chat messages, which will
then send relevant data to external URL(s) in real-time
Slack Integrations
Slash Commands• Allow you to listen for custom triggers in chat messages across
all Slack channels. When a Slash Command is triggered, relevant data will be sent to an external URL in real-time
Risks
Unauthorized access to your chat = bad things can happen to your AWS accountUse Two-Factor Authentication!!!Scope IAM policies appropriatelyDon’t go overboard (too much info could be bad)
Live Demo
AWS Serverless Chatbot Competition
• Create a bot for Slack that runs on AWS Lambda and Amazon API Gateway
• Sponsored by AWS and Slack• Win tickets to AWS re:Invent and more
• Winners will receive mentions in the Serverless Keynote during re:Invent
• Submissions due by September 29• Get started: awschatbot.devpost.com
Thank you!
Q & A