NOTE: In order to use Slack-Cleaner, you do need administrative privileges to your Slack group. Be aware – there’s a bit of coding involved, but nothing that I don’t explain in the instructions below.
You’re probably using the free version of Slack, and need to do some maintanence. Maybe there’s been a troublesome user who you need to remove all of their messages. Or maybe you went bot crazy, and there’s now too many bot messages spamming your channels.
For that, there is Slack Cleaner.
Within Slack Cleaner, the instructions aren’t super clear for a newbie. So the goal of this guide is to provide more details in the how-to,
I’m running Windows – So I’ll explain how to do it via a Windows computer (Windows 10 to be specific). If you’re a Mac, 90% of the content is the same – you’ll just need to find the Mac equivalent. (So instead of ‘How to install PIP for Windows’, Google ‘How to install Pip for Mac’.)
A Steep Learning Curve
If you are super new to this, it may feel completely over your head. But I assure you – once you set it up, you’ll feel like a bon-a-fide hacker. Let this be the first step to your journey to automating your life with scrips.
Additionally, the hurdle is just the set up! Once you are past that hurdle, everything is a lto easier.
Each step requires a separate tutorial, which I’ll link to. The tutorial links I discovered were written for novices, which is why I recommend them.
The overall process is to install PIP, which allows you to install this Slack Cleaner script. Then, you’ll get your Slack legacy API keys, and run specific commands in CMD or PowerShell.
If that’s a bunch of buzz words – don’t worry. I’ll explain in detail what each bit is.
STEP 1: In order to install PIP, you’ll need to install Python.
Python is a scripting language, and PIP is a package manager. The analog would be if you hired movers, and the mover was German. So you need to learn German, to tell the mover where to put your stuff and set it up correctly.
How to install python 3.7 (Should take 10 minutes):
Step 2: After installing Python, your next step is to install PIP.
What is PIP?
PIP is a Package Manager for Python. If you write code using Python (which may contain a folder of a bunch of python code), you’ll want to ‘pack it up’. PIP makes it easier for Python developers.
Using our German metaphor, you now speak German! You want to explain to him how you prefer to unpack your things.
Installing PIP (like 2 minutes)
Step 2.5: Install git
In the comments, @Justin shares that he needed to install Git to get this working.
To install git (for windows) – download the 32-bit or 64-bit “.exe” file here: https://github.com/git-for-windows/git/releases/tag/v2.23.0.windows.1
Note – the screenshot may not match exactly what’s on the site. New versions of Git get released all the time. Just make sure you grab the latest .exe file.
Step 3: You’ve installed Python, as well as PIP. Now install the Slack-Cleaner script.
The readme: https://github.com/sgratzl/slack-cleaner
Open up CMD or PowerEditor (with Admin access).
(1 minute Youtube video: https://www.youtube.com/watch?v=EohzkYPV6nI)
I’ll be referring to the command line as CMD.
While in the CMD and with Admin access, and run this code.
pip install -e git+https://github.com/sgratzl/slack-cleaner.git#egg=slack-cleaner
That should start the installation.
Step 4: You’ve installed Python, PIP, and hopefully Slack-Cleaner.
Now to see if the installation worked!
In the CMD line, type: “slack-cleaner –help”
If you can run this, you’ve installed it correctly.
If it isn’t working… Make sure you followed step 1 correctly (by following that tutorial), and had Python in the environmental variables.
Step 5: If Slack-cleaner works, then it’s time to get your Slack Legacy API.
You can find your Slack Legacy API tokens here: https://api.slack.com/custom-integrations/legacy-tokens
It should look like this… here is mine:
(I’m okay sharing that, since you can only see 30% of the full api token. I challenge anyone to guess the other 70%.)
6) Now write up the command, and run it in your CMD
Running this code It will give you a SIMULATION of everything that will be erased. It won’t actually do it. We’ll do it for real in Step 7.
# Delete all messages from certain user
“slack-cleaner –token <TOKEN> –message –channel gossip –user johndoe”
Replace the <TOKEN> with your token, obviously.
7) Okay now to do it for real.
We’ll add two additional parameters to your line.
Add “–rate=1 –perform”
means that it’ll take 1 second for each call. If you don’t add it, Slack cuts your access.
means to commit the actual change.
FROM: “slack-cleaner –token <TOKEN> –message –channel gossip –user johndoe”
TO: “slack-cleaner –token <TOKEN> –message –channel gossip –user johndoe –rate=1 –perform”
Alright, that should be the step by step! Leave a note in the comments if it worked, or if there’s a specific step that’s giving you issues. Cheers!