This repository contains a Slack bot that finds COVID-19 vaccines in the United States.
The application registers each vaccine as a Slack slash command
:
/pfizer <postal code>
/moderna <postal code>
/jj <postal code>
For example, if you wanted to find Pfizer
vaccinations near 60601
, you'd run the following command:
/pfizer 60601
This repository uses Serverless to provide bot functionality to Slack. We use Serverless to spin up the infrastructure needed to run an AWS lambda (we could also spin up BCP or Azure functions using Serverless).
The functions are stored in the functions
directory, by chat program.
Within the Slack directory, there are two folders -- backend
and handler
. The handler
is the interface that we
provide to the Slack. The backend
is the interface that gathers the providers, and presents them to the user. We use
this pattern because Slack slash commands need to be acknowledged within 3 seconds. Some provider searches can take over
8 seconds.
The handler receives the request, and immediately responds to Slack with a 200, indicating that
we've acknowledged the request. The handler also asynchronously invokes the backend
lambda, which can take a little
bit longer to load the providers and notify the user in Slack.
If you want to test out this application locally, you'll need to set up a Slack App for your workspace. You'll also want to setup the following environment variables:
SLACK_API_TOKEN
- the token for your botMAPBOX_API_TOKEN
- the token to use to communicate with MapboxSENTRY_DSN
- URL to post messages to sentrySENTRY_ENVIRONMENT
- which environment the application is running onSENTRY_RELEASE
- used to tag the errors in sentry
Useful files:
examples/sample_bot.go
-- how to search for a vaccine and post a message to Slack with the results.slack/bot_manifest.yml
-- example configuration settings for a Slack app.
To run the example:
go run example.go
- Test entire suite:
go test ./...
ormake test
- Test individual package:
go test <package>
- Test vaccines package:
go test github.com/hectron/fauci.d/vaccines
The application is now automatically deployed using Github Actions when a new Release is created. Check the file .github/workflows/cd.yml
for more information.
If you add any environment variable dependencies, add them to the repository's secrets in Github.
In order to manually deploy the application, you will need:
- Make
- serverless CLI, configured to support AWS
- Environment variables required in
serverless.yml
(these can be available using.envrc
)
make deploy
serverless invoke -f slackbot -t
serverless remove