π§ Bulk delete Slack messages with smart filtering and confirmations
β‘ 106 views Β· π§ Miscellaneous
Description
π§Ή Jedi Cleaner for Slack
β Slackβs Limitation
Slack lacks a native bulk delete feature. Users must delete messages manually, which is time-consuming and inefficient for large volumes.
β Our Solution
Jedi Cleaner automates Slack message deletion using smart filters, safety confirmations, and enterprise-grade reliability.
π Key Features & Capabilities
β‘ Lightning-Fast Bulk Operations
- Delete hundreds of messages in minutes
- Intelligent rate limiting prevents API throttling
- Auto-retry on failure ensures reliable operation
π― Smart Message Filtering
- Keyword match β Find messages with specific terms
- User mentions β Target messages that mention specific users
- Exact phrases β Use quotes for precision
- Bot/User content β Handle mixed sources seamlessly
π‘οΈ Enterprise-Grade Safety
- Confirmation workflow β No accidental deletions
- Timeout β Requests expire after 5 minutes
- Preview-first β Review messages before deletion
- Granular control β Choose exactly what to delete
π Intelligent Search & Preview
- Flexible filters (words, phrases, patterns)
- Preview + count before deletion
- Multi-channel support with context isolation
π Complete Workflow Management
- Auto-cleanup of bot messages after execution
- Real-time progress tracking
- Debug logs and audit trail
- Static data persistence and cleanup
π§ͺ How It Works
Phase 1: Search Request
User: /cleanup "error messages"
Bot Response:
π Found 15 messages containing "error messages"
π Breakdown:
β’ Will be permanently deleted
β’ Cannot be undone
β’ Respond within 5 minutes
β
Type: @cleaner_jedi yes
β Type: @cleaner_jedi cancel
Phase 2: User Confirmation
User: @cleaner_jedi yes
Bot: ποΈ Deleting 15 messages containing "error messages"
Phase 3: Completion
β
Cleanup Complete
β’ 15 messages deleted
β’ Channel cleaned
β’ Auto-deletes this message in 5 seconds
π οΈ Technical Architecture
Core Components
- Unified Webhook Handler Handles slash commands & mentions, deduplicates events
- Search Engine Integrates Slack API, parses & filters search terms
- Safety & Confirmation System Temporary storage, expiration logic, user auth
- Bulk Operations Engine Message deletion, progress tracking, error handling
- Cleanup & Memory Management Deletes bot messages, static data cleanup
π± User Commands
| Command | Description | Example |
|---|---|---|
/cleanup [term] | Search messages containing [term] | /cleanup "webhook error" |
@cleaner_jedi yes | Confirm deletion | After preview |
@cleaner_jedi cancel | Cancel pending deletion | Cancels active request |
π§© Edge Cases
| Scenario | Bot Response |
|---|---|
| No messages found | βNo messages found containing β[term]ββ |
| Expired confirmation | βRequest expired. Please run /cleanup againβ |
| No pending request | βNo pending cleanup found. Run /cleanup firstβ |
| Invalid search term | βPlease provide a valid search termβ |
βοΈ Setup Requirements
Slack App Configuration
OAuth Scopes:
β
chat:write
β
chat:write.public
β
channels:history
β
groups:history
β
app_mentions:read
β
commands
Event Subscriptions:
β
app_mention
β
message.channels
Slash Command:
Command: /cleanup
URL: https://your-n8n.app.cloud/webhook/cleanerjedi
Hint: [search term]
n8n Workflow Setup
Required Nodes:
- Webhook Trigger β Captures Slack events
- Respond to Webhook β Handles routing
- Switch Node β Event type routing
- Slack API Nodes β Search, delete, notify
- JavaScript Nodes β Logic & validation
β‘ Advanced Features
π§ Intelligent Deduplication
eventId = `cmd_${body.command}_${body.user_id}_${body.trigger_id}`;
if (staticData.recentEvents.includes(eventId)) {
return []; // Skip duplicate
}
π Flexible Search Terms
- Single words:
test - Phrases:
"error message" - Special characters:
webhook-failed - Case-insensitive by default
β»οΈ Auto-Cleanup
setTimeout(() => {
deleteMessage(completionMessage.ts);
deleteMessage(progressMessage.ts);
}, 5000);
π§ Storage Management
- Temp storage for requests
- Auto-expiry cleanup
- Memory-safe event trimming
π Error Handling & Logging
Error Scenarios
β Invalid term
β° Expired request
π« Access denied
β οΈ Rate limit hit
Debugging & Monitoring
- Event IDs, timestamps
- Key-value storage info
- API response codes
β Usage Examples
Example 1: Delete Error Messages
/cleanup "error"
β Bot: Found 23 messages
β @cleaner_jedi yes
β β
Deleted 23 messages
Example 2: Cancel Midway
/cleanup "from:@john"
β Bot: Found 8 messages
β @cleaner_jedi cancel
β β Operation cancelled
Example 3: Search by Date
/cleanup "2024-01-15"
β Bot: Found 12 messages
β @cleaner_jedi yes
β β
12 messages deleted
π Security & Safety
- β User confirmation required
- β 5-minute time limits
- β Permission-aware deletions
- β Audit trail logging
π Performance Optimizations
- Minimal webhook/API usage
- Batch deletion
- Cached recent events
Memory Handling:
- Temp data cleanup
- Key expiration
- Cache trimming
π Monitoring & Analytics
Metrics Tracked
- Messages per operation
- User response times
- Failure & error rates
- Storage performance
Logging
console.log('β
SUCCESS:', operationDetails);
console.warn('β οΈ WARNING:', warningDetails);
console.error('β ERROR:', errorDetails);
console.info('βΉοΈ INFO:', informationDetails);
π Summary
For Users
- β Simple commands
- β Preview + safety
- β Fast processing
- β Clear status feedback
For Admins
- β Lower API load
- β Full logging
- β Resilient to errors
- β Lightweight memory footprint
For Developers
- β Modular, clean code
- β Well-documented
- β Scalable & robust
- β Easy to extend
PDF how to do Document Included
π Nodes Used
Slack, Webhook
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File