A feature that isn't natively available in Slack (at the time of writing)
Use this app to delete all messages from any slack channel, including #general.
You will need to be a Slack Administrator.
- Clone the repository
- Install dependencies with
npm install - Create a Slack App (see Guide below)
- Run the GUI with
npm run start:gui - On first launch, the Settings dialog will automatically open - enter your Bot Token and User Token
- Your tokens are saved securely in your system's user data directory
- Clone the repository
- Install dependencies with
npm install - Create a Slack App (see Guide below)
- Run the script with
node index.js - On first run, you'll be prompted to enter your tokens
- Choose whether to save tokens for future use (stored in the same location as the GUI)
To build a distributable macOS app:
npm run buildTo use the script you must create a Slack app that has the required permissions to view and delete messages. The steps are described below.
- Log in to Slack App management
- Click Create New App
- Select From Scratch
- Enter an App Name e.g. SlackDeleter
- Select the workspace to add the App to
- Click Create App
- On the left, click OAuth & Permissions
- Scroll down to Scopes
- Under Bot Token Scopes click Add an OAuth Scope and add
channels:history,channels:readandchat:writein turn - Under User Token Scopes click Add an OAuth Scope and add
chat:write
- Scroll to the top and click Install to Workspace
- Copy the User OAuth Token (starts with
xoxp-) - Copy the Bot User OAuth Token (starts with
xoxb-)
- For GUI: Click ⚙️ Settings in the app and paste your tokens there
- For CLI: Add tokens to your
.envfile asUSER_TOKENandBOT_TOKEN - Go to your Slack client and
/invite @deletorinto the channel you want to remove messages from - Run the app and start deleting!
When using the GUI application, your tokens are stored securely in your operating system's user data directory:
| OS | Location |
|---|---|
| macOS | ~/Library/Application Support/slack-delete-channel-messages-with-gui/tokens.json |
| Windows | %APPDATA%/slack-delete-channel-messages-with-gui/tokens.json |
| Linux | ~/.config/slack-delete-channel-messages-with-gui/tokens.json |
To update your tokens, simply click the ⚙️ Settings icon in the app header and enter new values.
The script allows you to specify a custom rate limit if required. This is particularly useful on channels with a lot of messages. If you decide to use the Slack API defaults, then very quickly the delete attempts will be throttled until it's quite slow. By applying a custom rate limit, you can try and keep under the official rate limit radar. You can select which option to choose when running the script.
You're most likely to encounter errors relating to the tokens and scopes, for example cant_delete_message - double check steps 8-10 in the Slack App Setup above and also make sure you have correctly inputed your BOT_TOKEN and USER_TOKEN into the app
I highly recommend you remove the app from your channel and delete the App from the Slack control panel. At the very least, revoke the tokens!
