Skip to content

Repository files navigation

# Slack Channel Manager

A small collection of Python CLI scripts for auditing and cleaning up Slack workspaces. Useful for teams that have accumulated a large number of unused or empty channels over time.

---

## Scripts

### 1. slack\_channel\_report.py

Generates a full audit report of all public channels in your Slack workspace.

**What it produces:**

- Channel name, ID, and status (active or archived)

- Member count

- Creation date

- Date of last message

- Number of pins, files, and bookmarks

- Channel topic and purpose

Results are printed to the terminal as a summary table and saved progressively to a CSV file — so if the script is interrupted mid-run you won't lose your progress.

**Usage:**

python slack\_channel\_report.py --token xoxp-your-token-here

python slack\_channel\_report.py --token xoxp-your-token-here --output my\_report.csv

python slack\_channel\_report.py --token xoxp-your-token-here --quick

--quick skips the per-channel detail calls (pins, files, bookmarks, members) and just returns the basic channel list. Much faster for large workspaces.

**Required Slack scopes (User Token — xoxp-):**

- channels:read

- channels:history

- users:read

- pins:read

- bookmarks:read

---

### 2. archive\_empty\_slack\_channels.py

Finds all public channels with zero members and archives them after confirmation.

**What it does:**

1. Fetches all public channels

2. Filters to those with 0 members

3. Prints a preview report

4. Asks for \[y/N] confirmation

5. Joins then archives each channel

Archiving (not deleting) is used because the Slack API does not support channel deletion on free or Pro plans. Archived channels can be unarchived at any time by a workspace admin.

**Usage:**

python archive\_empty\_slack\_channels.py --token xoxb-your-token-here

**Required Slack scopes (Bot Token — xoxb-):**

- channels:read

- channels:manage

- channels:join

**Note:** Your Slack workspace must allow apps to archive channels. Check under **Workspace Settings → Permissions → Channel management**.

---

### 3. archive\_channels\_from\_csv.py

Archives a specific list of channels provided via a CSV file. Intended to be used after reviewing the report from slack\_channel\_report.py.

**What it does:**

1. Reads channel names from the first column of a CSV (expects a header row, channels with # prefix)

2. Previews the full list before doing anything

3. Asks for \[y/N] confirmation

4. Joins then archives each channel

5. Prints a results summary (archived, already archived, failed, not found)

**Usage:**

python archive\_channels\_from\_csv.py --token xoxb-your-token --input channels\_to\_archive.csv

You can use the CSV output from slack\_channel\_report.py directly as the input — filter it down to the channels you want to archive, then pass it to this script.

**Required Slack scopes (Bot Token — xoxb-):**

- channels:read

- channels:manage

- channels:join

---

## Setup

### 1. Install dependencies

pip install requests

### 2. Create a Slack App

1. Go to [api.slack.com/apps](https://api.slack.com/apps) and click **Create New App → From scratch**

2. Give it a name (e.g. Channel Manager) and select your workspace

3. Go to **OAuth & Permissions**

4. Add the required scopes listed above for each script

5. Click **Install to Workspace**

6. Copy your token — use a **User Token** (xoxp-...) for the report script, and a **Bot Token** (xoxb-...) for the archive scripts

### 3. Run

Pass your token via the --token argument or set it as an environment variable:

\# Windows

set SLACK\_BOT\_TOKEN=xoxb-your-token-here



\# Mac/Linux

export SLACK\_BOT\_TOKEN=xoxb-your-token-here

---

## Recommended workflow

1. Run slack\_channel\_report.py to get a full CSV audit of your workspace

2. Open the CSV, filter and review — identify channels to archive

3. Save your filtered list as a new CSV

4. Run archive\_channels\_from\_csv.py with your filtered CSV to archive in bulk

---

## Notes

- **Archiving is reversible.** Archived channels are hidden from the channel list but can be unarchived by a workspace admin at any time.

- **Free plan support.** These scripts work on Slack's free plan. Channel *deletion* via API is not supported on free or Pro plans — archiving is the correct approach.

- **Rate limiting.** The scripts include delays between API calls to respect Slack's rate limits. Large workspaces (500+ channels) may take 45–60 minutes for a full detailed report.

- **Private channels.** These scripts only cover public channels. Private channel support requires additional OAuth scopes and workspace admin permissions.

---

## License

MIT

About

Tools to help you audit and cull Slack channels

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages