Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Delete all messages from a Slack channel with GUI

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.

Demo

til

Quick Start

GUI Application (Recommended)

  1. Clone the repository
  2. Install dependencies with npm install
  3. Create a Slack App (see Guide below)
  4. Run the GUI with npm run start:gui
  5. On first launch, the Settings dialog will automatically open - enter your Bot Token and User Token
  6. Your tokens are saved securely in your system's user data directory

CLI Application

  1. Clone the repository
  2. Install dependencies with npm install
  3. Create a Slack App (see Guide below)
  4. Run the script with node index.js
  5. On first run, you'll be prompted to enter your tokens
  6. Choose whether to save tokens for future use (stored in the same location as the GUI)

Building the App

To build a distributable macOS app:

npm run build

Slack App Setup

To use the script you must create a Slack app that has the required permissions to view and delete messages. The steps are described below.

  1. Log in to Slack App management
  2. Click Create New App
  3. Select From Scratch
  4. Enter an App Name e.g. SlackDeleter
  5. Select the workspace to add the App to
  6. Click Create App
  7. On the left, click OAuth & Permissions
  8. Scroll down to Scopes
  9. Under Bot Token Scopes click Add an OAuth Scope and add channels:history, channels:read and chat:write in turn
  10. Under User Token Scopes click Add an OAuth Scope and add chat:write til
  11. Scroll to the top and click Install to Workspace
  12. Copy the User OAuth Token (starts with xoxp-)
  13. Copy the Bot User OAuth Token (starts with xoxb-) til
  14. For GUI: Click ⚙️ Settings in the app and paste your tokens there
  15. For CLI: Add tokens to your .env file as USER_TOKEN and BOT_TOKEN
  16. Go to your Slack client and /invite @deletor into the channel you want to remove messages from
  17. Run the app and start deleting!

Token Storage (GUI)

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.

Rate Limiting

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.

Troubleshooting

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

After Use

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!

About

Node script to delete all messages in a Slack channel

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages