A slackbot for controlling the music in the office.

Local development instructions

  • Make sure mysql and redis are installed and running
  • Create a mysql database called musicbot
  • Clone the repo, create a virtual environment, and run pip install -r requirements.txt
  • Create a file, and configure for your local environment. See for further instructions setting up your local config.
  • Once you have configured everything, run the following commands to provision the database:
  • python db upgrade will run all migrations and set up the playlist table
  • python seed_db will seed the database with tracks from the spotify playlist referenced in
  • Run python runserver to start the server.
  • When running locally, you will not actually be able to interact with Slack, so there is a test route set up for trying out commands. Send POST requests to localhost:2000/test/<command>?user=<user>, to interact with musicbot.
  • About the Poller: There is a separate python script that when running will poll the sonos device at regular intervals to determine if new tracks need to be added to the playlist. Running this script is not necessary for local development, but when running will call MusicBot.add_random_track() if there are no tracks left to play.


  • Tests are in the tests/ folder and are broken into suites according to the classes that they test. Tests use the SonosMock class to emulate the Sonos API, so tests will not interfere with the current Sonos playback. Tests that write to the database will cleanup after themselves as well.