Send personal bulk Slack DM’s using Google Sheets + Script
By: Ben Blaine
Tags: Community Engagement, Slack, Communications Planning, Community Care, Community Engineering

Background around why I built this

As a Community Engineer I spend a lot of my time thinking about how to build and scale communities from scratch — but also how to reach each person in the community in a very personal way and care for them.

The Programmable Banking community which I’m currently building and running has just gone over 100 people and it’s going to start accelerating. It’s critical to keep in touch with members, find out how they are doing, get their feedback on what we’re doing and ask them to do things to help. The last one is the most important — you have to give your community things to do to help grow the community so that they are actually owning and responsible for it’s growth.

So why did I build this? I wanted the 100 people in the community to share a post of an upcoming talk and I know that people miss most group messages in channels, so I wanted to DM them to ask for their help spreading the word.

Keep it personal

Please note that when using bulk messaging tools from a personal account, you should always set aside time to reply immediately after your message goes out, as you would if you had personally typed the message. This obviously implies you should also not message too many people at once.

How to Bulk Slack DM

Ok maybe you didn’t need to know all that and just wanted to get the How To: so I’m going to jump straight into it. I searched for so long how to do this because I thought it was definitely documented somewhere, but it either isn’t or I suck at Google. There is a paid tool: Slack Mass Direct Messages.

If you want to save costs and learn some neat tricks, you can hack something similar with Google Sheets, Google Scripts and Slack API.

Step 1: Set up a Slack Bot

Create a Slack App here: https://api.slack.com/apps?new_app=1.

Give it a name

Choose the workspace where you want to send your Bulk Slack DM

Turn on incoming webhooks during setup using the On/Off toggle.

Tap on “Add New Webhook to Workspace”

Choose a channel where the App can post to, you can use this channel for testing. I chose the channel #testing and made it private.

Under “Your Apps” find your app, tap on “OAuth & Permissions” and then on “Add an OAuth Scope” under “User Token Scopes”.

Select “chat:write”

A message will pop up, select “reinstall your app”

Again, select a channel where messages can be posted by the bot

Now your Slack Bot is set up and allowed to post as you, we can start working on the Google Sheet + Script. You should see this screen. You will need the OAuth Access Token later, so keep this window open.

Step 2: Setup Google Sheet and Script

Create a new Google Sheet

From the menu select Tools > Script editor. This will create a Google script.

Paste this code into your Google Script — you can overwrite all of the contents. Also give your script a name. I’ve highlighted the pieces of code you will need to edit.

Copy your OAuth Access Token from the Slack API page that you left open, the one beginning with “xoxp”. Replace the text in the Google Script COPY_AND_PASTE_YOUR_OAUTH_ACCESS_TOKEN_HERE with your token.

Replace PASTE_YOUR_SLACK_MESSAGE_HERE with your Slack message. If you want to format your message nicely, you can use the Slack Block Kit Builder.

Step 3: Add users to your Google Sheet and send your message

In Slack Admin, go to “Manage members” and export your member list.

In your Google Sheet, create a tab called “Slack Member List” and import your member list. You need the User ID’s of the members you want to message. If you need to message a specific subset of users, you will need to select only their User IDs. I had a list of email addresses for a subset of my community I wanted to message, so I used VLOOKUP() in Google Sheets to get the User IDs for the list of emails.

Switch to Sheet1 in your Google Sheet, and rename Sheet1 to Input. Then Add a title to column A “User ID” and paste the list of User ID’s for the users that you want to message.

Go back to your Google Script and click on “Run” to Authorize it. You will need to click through a series of screens to Authorize your app. You may even be told it is potentially unsafe, but I wouldn’t worry about this because it’s your app (you need to be wary of 3rd party apps).

Now you can go back to your Google Sheet. You may need to reload the page. You will now see Message Menu in the toolbar.

As a test you might want to just put your User ID in the list to send the message, and when you are ready you can add other users back again.

In Message Menu, select Send to Recipients. The first time you may again need to Authorize the sheet.

In Slack, you should have received a DM from yourself 🎉 You can now change the message in the Google Script and the list of users in the Google Sheet if you want to send Bulk Messages.

Improvements

This is pretty damn hacky, but it works for now. When I have another inspired Saturday morning I will improve on the design by