Building a ChillBot

code • May 9, 2017

I wrote Keep your streak in the work week on The Human In The Machine today. My article is about how I built ChillBot, a Slack bot that messages me on the weekends to let me know if I’ve contributed on GitHub for seven consecutive days and to encourage me to take a break.

The message looks something like this:

ChillBot alert

How it works

  1. Fetch all my activity on GitHub through the Events API. (The API only retrieves up to 300 events, so if you’re a power user, the API may not retrieve enough data to decide if you have a streak or not.)
  2. Get every unique date when I did something on GitHub.
  3. Figure out how many days I’ve contributed on GitHub by looping through every day starting with yesterday through my decided streak (7 days). And if that day matches a day that I contributed on GitHub then mark it, if it doesn’t then break the loop.
  4. If my streak is greater or equal to the number of days I contributed, ping me on Slack.

Ironically, it took a little bit to break my streak as I was working on this bot on the weekend, but I am proud of any of my gray-square weekends.

You can check out the code on GitHub and learn how to automate the bot with Amazon Web Services with the steps I wrote up.

Keep reading code