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.
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.
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
- 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 to
- Install tools and dependencies:
make tools deps.
- Build the worker Lambda functions:
- Build the master Lambda function and API Gateway:
make deploy-master. The output of this command will show a POST endpoint, e.g.
- 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.
- Join the Slack channel configured in the bot setting.
- Start asking SiteChecker bot "sitechecker: Is twitter.com up?", "sitechecker: Is facebook.com down?" .
|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.|
|method||HTTP method to be used for checking website availability.|
|timeout||timeout in milliseconds for the HTTP request sent for checking the website.|
Install Serverless framework and other tools:
Download library dependencies:
Build the infrastructure with default prod stage:
Remove the infrastructure with default prod stage:
Specify custom stage:
STAGE=dev make deps deploy remove
This project is a submission to AWS Serverless Chatbot Hackathon 2016 - with self-imposed 24-hour total time limit scattered across several days/nights.