Snack Bot

Snack Bot is a Slack Bot that incentives workspace cleaning by giving snacks to those who share proof of cleaning. You'll need to spend a few minutes tidying the workspace, then you can redeem a snack. Here are possible ways to fulfill the requirement:

Cleaning Ideas

  • Put away tools left out on a table
  • Repair a broken 3D printer
  • Sweep floor
  • Organize a bin
  • Remove scraps from around 3D printers
  • Clean the whiteboard
  • Clean the break room
  • Organize cable storage rack
  • Replenish low workspace consumables (solder, wire, fasteners, etc)
  • Tidy downstairs

Usage

To check your balance, type `/snack`. Everyone is given credits at the start of the quarter, so you may already have some.

If you have a credit, you can also use `/snack` to redeem. Select the cabinet corresponding to the snack you'd like and it will unlock. All cabinets use 1 credit to unlock.

To get a credit, spend a few minutes cleaning, then send a photo of what you cleaned to Snack Bot on slack. This image will be sent to a public channel to ensure accountability, however the credit will be available immediately. You can then choose to redeem it to unlock the cabinet or save it for later.

Expectations

The expectation is that cleaning lasts at least 2 minutes, and makes a noticeable change to the workspace. Cleaning a mess you made does not count, and should benefit others in the club (i.e. not a box that only you use).

For accountability, when you send a photo it gets uploaded to #snackbot-pics. Anyone is allowed to join this channel and see what others have cleaned. If someone believes a photo was taken without cleaning, it can be flagged with the :not-clean: emoji, and it will be sent to the workspace managers for review.

Workspace Managers

Additional functionality is available to those in the #workspace-core private channel:

/workspace-add-snack-credits

Adds snack credits to the users tagged in the slash command. Multiple users can be added with any or no delimiter. Add a number, 1-9, at the beginning or end of the command to specify the number of snack credits; it otherwise defaults to one.

/workspace-unlock-snack-cabinet

Unlock the snack cabinet for 5 minutes. Intended to be used to restock the snack cabinet.

/workspace-refresh-snack-credits

Resets all free snack credits to 2. Intended to be used at the start of the quarter. Snack credits granted through photo upload or /workspace-add-snack-credits are not affected by this. Free snack credits do not roll over if unused, though.

Technical

The slack bot is run locally on a Raspberry Pi, using a Python script. Lawton maintains the Slack API access. When the button is pressed, a solenoid is actuated on the corresponding cabinet.

An SQL database stores the snack credits. They are differentiated into two segments: free credits and earned credits. Free credits are used before earned credits, as free credits do not roll over. This is abstracted to the user with a single credit number. When a user invokes any command for the first time, they are added to the database with the free snacks.

Because of confusion with the package manager, there are two virtual environments. Venv was used on my mac for testing, snackbotvenv is used on the Raspberry Pi. The latter is excluded from github.

Snack-bot is located in the home directory of the Pi. Do not move, as the directory is hard coded in the startup execution.

The Raspberry Pi is set up to run the script upon booting, so it is resilient against power outages.

The password to SSH into the raspberry pi is stored in Dashlane.