Simple interactive tool to delete all your messages (including threaded replies) in a Slack direct message conversation with a specific person.
pip install slack-sdk- Go to https://api.slack.com/apps
- Click "Create New App" → "From scratch"
- Give it a name and select your workspace
- Click "OAuth & Permissions" in the sidebar
- Under "User Token Scopes" (not Bot or App-Level), add these scopes:
channels:history- View messages in channelschannels:read- View basic channel infogroups:history- View messages in private channelsim:history- View messages in DMsim:read- View basic DM infompim:history- View messages in group DMschat:write- Delete messagesusers:read- View people in workspaceusers:read.email- View email addresses
- Click "Install to Workspace" and authorize
- Copy the "User OAuth Token" (starts with
xoxp-)
export SLACK_USER_TOKEN='xoxp-your-token-here'Interactive mode (recommended):
python /tmp/delete_slack_dm.pyThe script will:
- Show you a list of all your DM conversations
- Let you pick one by number or name
- Show you a preview of your messages
- Ask for confirmation before deleting
With a specific person:
python /tmp/delete_slack_dm.py "John Doe"Dry run (test without deleting):
python /tmp/delete_slack_dm.py --dry-run✅ Deletes only YOUR messages, not the other person's
✅ Deletes messages in threads too
✅ Shows preview before deleting
✅ Requires typing 'DELETE' to confirm
✅ Handles rate limits automatically
============================================================
Slack DM Message Deletion Tool
============================================================
✓ Authenticated as: John Smith
Fetching your DM conversations...
📋 Your DM conversations (15 total):
1. Alice Johnson (@alice)
2. Bob Williams (@bob)
3. Carol Davis (@carol)
...
============================================================
Enter the number or name of the person: 2
👤 Selected: Bob Williams (@bob)
📥 Fetching messages...
Fetched 247 messages so far...
📊 Found 143 message(s) from you
📝 Preview of messages to delete:
1. [2024-01-15 14:30] Hey, did you see the report?
2. [2024-01-15 14:32] [in thread] Yeah, looks good
3. [2024-01-16 09:15] Morning! Quick question...
... and 140 more
⚠️ WARNING: This will PERMANENTLY delete these messages!
Type 'DELETE' to confirm: DELETE
🗑️ Deleting messages...
Deleted 50/143...
Deleted 100/143...
Deleted 143/143...
✅ Done! Deleted 143 messages
============================================================
Done!
============================================================
⚠️ Deletion is permanent - cannot be undone⚠️ Only deletes your messages (verified by user ID)⚠️ Deletes all your messages including thread replies⚠️ The other person's messages remain untouched- ⏱️ Large conversations may take a while (rate limiting)
"SLACK_USER_TOKEN not set"
- Make sure you exported the token in your current terminal session
"No DM conversations found"
- Make sure you have some DM conversations in Slack
- Check that your token has the correct scopes
"Authentication failed"
- Your token might be invalid or expired
- Make sure you copied the entire token (they're quite long!)
- Verify you're using a User OAuth Token, not a Bot Token
Rate limiting
- The script automatically handles this
- Just wait, it will continue after the delay
- Interactive confirmation required
- Shows preview of what will be deleted
- Must type 'DELETE' (all caps) to confirm
- Dry run mode available for testing
- Progress reporting during deletion
Provided as-is for personal use. Use at your own risk.