A Slack & Google script that randomly pairs people weekly for coffee chats to encourage random introductions within an office

Posted by mh on Dec 23, 2016

This tool consists of two parts, the Apps Script, and the Google Sheet log/database, Both are view only, so copy both over to your Google Account. It'll need to auth the first time it manually runs.


  1. Copy both documents over to your Google account
  2. Set up an incoming webhook for your Slack domain here and write down the webhook url
  3. Set up a slash command called /coffeegrinder here and write down the Token. We'll update the URL later, so leave this window open
  4. Update the following fields in the script:
    • [[OutgoingWebhookURL]]: Slack's incoming webhook URL (step 2)
    • [[Token]]: Token from Slack's slash command (step 3)
    • [[your slack username]]: your username on slack
    • [[CompanyID]]: the 'xxx' in
    • [[SpreadsheeetID]]: the long string in google sheets after
    • [[ChannelID]]: trickier; the way I found mine was by testing the slash command in the channel I wanted, and parsing it from the logs (tab in Google Sheet)
    • [[IncomingWebHookURL]]: IncomingWebhookURL that Slack will post to. Doesn't actually need to be in the script, I just added it to not lose track of it
  5. In the script, go to "Publish" -> "Deploy as Web App". Set a new project version, execute as yourself, and allow "Anyone, even anonymous" to access
    Note: I run this app on my personal gmail account, as my company (wisely) disabled the anonymous option. YMMV
    Note 2: you will need to republish (as a new version) anytime you make changes to the app
  6. Take that URL and add it to the Slack slash command (step 3). Additionally, I added this as the IncomingWebHook URL
  7. Manually run testWrite to trigger auth (Run menu)
  8. Create a #coffeegrinder channel in Slack, and run '/coffeegrinder join' from that channel
  9. If you haven't, check the logs for ChannelID and update the script. Make sure to republish as a new version, otherwise it won't update
  10. Run the various other test functions to ensure things are working and to give permissions (Run menu)
  11. Click the button for "Current project's triggers", and set grinder to run weekly (I do between 9 and 10 AM on Mondays)