SiteChecker Slackbot
SiteChecker is a serverless Slack bot for checking whether a website can be reached from multiple locations on the planet.
For example, Twitter has been censored multiple times in various countries. So even though a website is available from your country, it might not be from another country. You can ask SiteChecker bot "sitechecker: Is twitter.com up?"
The locations where the checking is performed from are based on the available AWS Lambda regions. SiteChecker currently only supports 8 regions, but the list will grow and it's easy to add a new region to SiteChecker infrastructure.
Architecture
SiteChecker has two components, a bot that's configured on Slack, and a piece of infrastructure on AWS.
The bot is a Slack outgoing webhook custom integration.
The infrastructure on AWS is implemented with master worker pattern. The master Lambda function receives POST requests from the Slack bot via an API Gateway, it parses the message using a simple natural language processing speakeasy-nlp package in order to understand the message from Slack user and to identify the website to be checked. The master Lambda function then distributes the tasks for checking that website to worker Lambda functions across multiple AWS regions.
Even though SiteChecker's current feature is limited to checking website availability, the architecture is suitable for any other cross-region checks. E.g. tracerouting from multiple cities, measuring response time from multiple cities.
Installation
There are two parts to install, the bot on Slack, and the infrastructure on AWS.
Let's install the bot first by creating a Slack outgoing webhook custom integration.
- Go to your Slack account's custom integrations page at
https://account.slack.com/apps/manage/custom-integrations
. - The page will show the available custom integrations. Click on Outgoing WebHooks link.
- Click Add Configuration button.
- Click Add Outgoing WebHooks integration button.
- Fill in the integration settings:
- Channel: select the channel where you want the bot to be available from.
- Trigger Word(s): specify words to trigger the bot, e.g. sitechecker:
- URL(s): leave this empty for now, we'll go back to this option after the infrastructure is built.
- Token: Slack will generate the token for you, this token will be configured in master Lambda function.
- Descriptive Label: description for this custom integration, e.g. SiteChecker Outgoing WebHook
- Customize Name: the name of your bot, e.g. SiteChecker
- Customize Icon: upload SiteChecker radar icon
- Click Save Settings button.
Next, the second part is to create the infrastructure on AWS.
- Install node.js .
- Set up AWS credential, to be used by Serverless framework.
- Clone the repository:
git clone https://github.com/shinesolutions/sitechecker-slackbot
. - Configure the Slack token from the outgoing webhook custom integration settings in
master/conf/config.json
. Add the token toallowedTokens
array property. - Install tools and dependencies:
make tools deps
. - Build the worker Lambda functions:
make deploy-workers
. - Build the master Lambda function and API Gateway:
make deploy-master
. The output of this command will show a POST endpoint, e.g.https://id.execute-api.us-east-1.amazonaws.com/prod/handle
- Return to the Slack Outgoing WebHook custom integration settings page, and copy paste the POST endpoint from the command output to URL(s) setting, then click Save Settings button.
Usage
- Join the Slack channel configured in the bot setting.
- Start asking SiteChecker bot "sitechecker: Is twitter.com up?", "sitechecker: Is facebook.com down?" .
Configuration
SiteChecker Slack bot master and worker Lambda functions can be configured in master/conf/config.json and worker/conf/config.json files respectively.
Master configuration:
Name | Description |
---|---|
allowedTokens | An array of allowed Slack tokens. If any is specified, then only incoming requests with that token are accepted. If left empty, then all incoming requests are accepted. |
regions | An array of objects with region name and description. |
Worker configuration:
Name | Description |
---|---|
method | HTTP method to be used for checking website availability. |
timeout | timeout in milliseconds for the HTTP request sent for checking the website. |
Development
Install Serverless framework and other tools:
make tools
Download library dependencies:
make deps
Build the infrastructure with default prod stage:
make deploy
Remove the infrastructure with default prod stage:
make remove
Specify custom stage:
STAGE=dev make deps deploy remove
Colophon
SiteChecker radar icon made by Trinh Ho from www.flaticon.com is licensed by CC 3.0 BY.
Demo video background music My Love (Rework) by James Mac & VALL.
This project is a submission to AWS Serverless Chatbot Hackathon 2016 - with self-imposed 24-hour total time limit scattered across several days/nights.
Built With
- amazon-web-services
- api-gateway
- lambda
- natural-language-processing
- node.js
- serverless
- slack
Log in or sign up for Devpost to join the conversation.