Skip to content

alexanderscott/burrito-bot

Repository files navigation

burrito-bot

build CI

Slack app for giving teammates the gratitude of burritos after doing something awesome. Similar concept to HeyTaco

BurritoBot

App is serverless, running via AWS lambda and using DynamoDB for storage. Uses Chalice serverless framework for lambda scaffolding and Bolt for handling to Slack @mentions and new emoji reactions.

Install Locally

Create a python virtualenv and install python deps

# Python 3.6+ required
python -m venv .venv
source .venv/bin/activate

pip install -U pip
pip install -r requirements.txt

Install local dynamodb and run it:

brew install dynamodb-local && dynamodb-local

Run dynamo migration to insert the table:

python scripts/migrate_db.py

Run Locally

# start local dynamodb
dynamodb-local

# start the app
chalice local --port 3000

# in another terminal
ngrok http 3000

Then edit the Event Subscriptions callback URL in Slack App settings to point to local ngrok tunnel.

See the scripts directory for db helpers to create the dynamodb table locally and seed it.

Run Tests

These are primarily integration tests and rely on having dynamodb-local running

python -m unittest discover ./tests "test_*.py"

Configure a New Slack App

Follow the Bolt guide here for details on how to create and configure a new Slack app. The oauth tokens provided by Slack during setup are needed in app configuration.

Note: you must be a Slack admin or receive approval from an admin in order to install to a Slack workspace.

Environment Variables

Copy .chalice/config.json.sample to .chalice/config.json and add Slack tokens/secrets.

export SLACK_SIGNING_SECRET=
export SLACK_BOT_TOKEN=
export VERIFICATION_TOKEN=
export BOT_NAME=BurritoBot
export EMOJI_PLURAL=burritos
export EMOJI=burrito
export SLASH_COMMAND=burritobot
export MAX_POINTS_PER_SENDER_PER_DAY=5
export DYNAMO_TABLE_NAME=burrito_points
export DYNAMO_ENDPOINT_URL=http://localhost:8000
export ADMIN_SLACK_USER=U01AP4BM8SD
export LOG_LEVEL=DEBUG

Deploy to AWS with Chalice

Create the dynamodb table in AWS using CloudFormation:

aws cloudformation create-stack --stack-name burrito-points \
  --template-body file://cloudformation.yaml

Fill in the environment variables in .chalice/config.json.

Then to deploy:

chalice deploy --stage dev --no-autogen-policy

TODO

  • [ ] Handle direct messages to the bot similar to slash command request types
  • Clear explanation & help text from /burritobot help or DM to @BurritoBot
  • Weekly leaderboard roll-up message to individuals (or channel)
  • Sentry integration for observability
  • Message or reaction deletion handling
  • Reactions should look for direct mentions in message text and award to those users?
  • Testing for messages and reactions inside threads
  • CI/CD for autotest + autodeploy
  • Display emoji points remaining (under the max cap) inside the response to sender
  • AWS Cloudformation template for deploy/teardown (chalice integration)
  • Monthly and all-time leaderboards in addition to weekly
  • Direct messages to recipients to notify of emoji reward

Future Enhancement Ideas

  • Cronjob to send leaderboard update using scheduled jobs?
  • Message text storage for context?
  • Lookup for readable usernames and persist to db?
  • Webpage for viewing leaderboard?

License

MIT

About

Slack bot similar to HeyTaco, to give teammates kudos

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages