Using a Postman app to … Run the Dishwasher

Like many small offices, we have a kitchen that suffers from a chronic lack of attention. While we all make time to order snacks, make coffee, and separate the recycling from the green waste, we never have time to load & run the dishwasher. Turns out, when doing the dishes is everyone’s responsibility, it’s really … no one’s responsibility. Since we’re a software company, naturally, we created an app to fix this.  

Specifically, we needed something that was a) fair, b) automated, c) and worked in Slack, where it couldn’t be missed, misunderstood, or easily ignored. So, I created a small app to assign daily dishwasher responsibility – one that runs entirely within Postman as a Postman collection. The collection runs daily to select the kitchen-volunteer-of-the-day, keep track of who’s done what, and remind the volunteer (in Slack) to manage the dishwasher.

Airtable Database of Possible Volunteers

To start, I created an Airtable called SF Office Kitchen Duty, with everyone in the office listed, including name, Slack id, and how many times they’d had volunteer kitchen duties.

Then I created a Postman collection with three requests, and a Postman monitor:

  1. (GET) Select the lucky person who has KP (kitchen patrol) today. This request accesses the SF Office Kitchen Duty via the Airtable API, sorting the table by count and first name, and selecting the alphabetically-first person from the least-volunteered group
  2. (PATCH) Give the volunteer credit.  This request updates the SF Office Kitchen Duty Airtable, by incrementing the count for that day’s volunteer.
  3. (POST) Tell everyone who is today’s volunteer.  This request posts and tags the person who will be taking care of the kitchen for the day to our team Slack channel, using a Slack webhook.

Once the collection was finished, it needed to be automated. I used a Postman monitor to set a scheduled run of the collection every M-F at 8 a.m. 

Details on all 3 requests and the monitor below! If you want to look at code while you're reading, you can look over the documentation for the published collection, or click on the Run in Postman button to download the collection into your instance of Postman:

Run in Postman

First Request: Creating an Environment and Accessing Airtable

To access the SF Office Kitchen Duty Airtable, I got the appropriate endpoint and the Airtable API key from the very-lovely Airtable API documentation. I stored these values in variables stored in a Postman environment, called Kitchen Duty Environment. The Airtable URL is unique to my SF Office Kitchen Duty Airtable, and the Airtable Key from my Airtable account. The environment also contains the URL for the Slack webhook – more on that later.

The first request of the collection hits the url for my Airtable table, asking for all the records and sorting them in ascending order for the count of prior volunteer assignments, then in alphabetical order. Sorting requires passing in an array of objects, which in turn needs to be encoded in the Params section of Postman. The documentation on how to do this was not terribly clear, but this helpful Airtable API URL Encoder helped quite a bit in creating the request.

What I get in the response body is a JSON object, for which the top result is the alphabetically-first person among the folks with the least-prior kitchen duty – in this case, my colleague Stacee.

In the tests section of the request, I set a few more environment variables – the ID, slack handle, and count of today’s volunteer, based on the response received. The collection uses these details in the next 2 requests.

 

Second Request: Updating the Airtable

Next, I need to update the Airtable, incrementing the person’s count by 1 (today). This update has the effect of moving today’s volunteer to the end of the list. The response body of this PATCH request shows me that I’ve updated the record correctly.

Third Request: Posting to Slack

Now, on to the automated nagging in the third request. I created a Slack webhook into an office news channel on our Slack team, and created a POST request that triggers the webhook and will post today’s volunteer to the channel. I got the Slack webhook endpoint from Slack and saved it in another environment variable (SlackChannel) in the Kitchen Duty Environment.

I added some clipart of a dishwasher to drive the point home, and here’s the result:

Lastly: Automating the Run

Lastly – and perhaps most importantly – I needed this to happen every day, without my having to remember. For this, I created a Postman monitor, which is a regularly scheduled run of a specified Postman collection.

Typically, a Postman monitor runs a collection with included tests, to check an API regularly for uptime, performance, and behavior. In this case, I’m using the monitor to run this collection on a schedule – like running a cron job, but entirely within the Postman app.

I can track my monitor – essentially, review the runs of my little dishwasher-volunteer-app – in my Postman dashboard.

We have aspirations to extend the tool – to schedule around holidays & vacations, allowing folks to swap days, etc., but for now, that’s it! If you’re interested (or your office has kitchen-cleanliness issues too), you can download the Postman collection and environment here, to customize it for your situation.

Run in Postman

Or, you could do what we did soon after I wrote this: hire someone to clean up after us all. 🙂