We Built an Office Bot to Assign Chores

Nobody likes to do chores, even easy ones like loading and running the office dishwasher. Pair this sentiment that with Drake Cooper’s recent basement expansion, and you get two sinks on separate floors that fill up with dirty dishes and coffee mugs. Even though almost everyone in our office uses mugs and dishes, and for the most part, folks put them in the dishwasher when they are done, we found that no one had ownership of the easiest part: starting the dishwasher and unloading the clean dishes.

To delegate out the chores that needed to be done, we needed someone cold and unforgiving, unbiased and incorruptible to lay down the law.  So we decided to build our very own chorebot.

The Bots are Coming

Bots are the next big evolution in how we interface with technology. Movies like Her seem like fantasy, and while we aren’t falling in love with our bots just yet, most of us interact with bots every day. There are the obvious bots, like Siri or Amazon Echo, but things like predictive text are also bots in their own right. You can order a pizza by tweeting to a bot. If you use Slack, you can ask the slackbot to do all sorts of simple tasks.

We decided to solve our dishes challenge by creating our own bot, Rosie (named with love after everyone’s favorite robot housekeeper, Rosie, from the Jetsons). She has a simple task: every morning, she picks a random person to assign to each of her chores, and then sends them a message in Slack.

Here’s How Rosie Works

At Drake Cooper, we use Slack for the day-to-day chat and internal social stuff. And Slack, like most good apps, offers a robust API to connect to other apps and create your own custom integrations. Every morning, Rosie randomly assigns people to chores, then uses Slack’s API to send the assignees a message.

The #chores channel

The Brains

First, we needed a database to store usernames and chore descriptions. To handle this, we opted for Google drive, using a simple spreadsheet with individual sheets for people and chores.

Meanwhile, we set up a Slack channel called #chores. This is where Rosie will post her assignments.

Talking to Slack

There are a couple of ways an app can interact with Slack via the API. Since all of the communication will be incoming, we decided to use an incoming webhook. Here, you’re able to select a channel to post to, as well as a name and image for your bot.

Using the provided Webhook URL, we wrote a little code to post messages to #chores as Rosie. Then, all we needed is a little code to glue it all together.

Putting it All Together

Google Drive offers a ton of ways to access and interact with it through an API. But we also happened to need a place to host and run our app. And wouldn’t ya know it, Google Drive also has a scripting language called Google Apps Script. By using the Script Editor provided, we hosted the code for our bot in Google Drive without having to spin up and maintain a web server. Google Drive even has triggers that can be configured to automatically run the script daily. It’s like Google built it with our dishwasher situation in mind.

Without getting too far into the nitty gritty of the code, we wrote a simple script that loops through each chore, and then loops through each username and chooses one at random. Then, it posts a slack message using the webhook we set up. It’s even smart enough not to assign one person to multiple chores. And, it has a function that lets an admin login and post a custom message as Rosie, in case she needs to crack some skulls.

What Else?

Right now, Rosie’s skills are pretty limited. She can only assign and talk. But, what if she could listen too? What if someone didn’t know where the detergent was stored, and wanted to ask @rosie? With a little modification to the Slack integration and a little code, Rosie could be taught to respond with helpful, and maybe slightly snarky responses.

Your Turn

If you’re interested in building your own bot, feel free to check out the code that makes Rosie run in our Bitbucket repo. And, if you’re so inclined, we’d love to see what you build. Tweet us @drakecooper and share your bot.

Up Next

Culinary Trends of 2016

What are the hottest culinary trends of 2016? It depends on who you ask. Any way you slice it, the…

Drake Cooper
Drake Cooper
March 8, 20163 min read