See llms.txt for all machine-readable content.

Back to Templates

Bulk delete Slack messages with smart filtering and confirmations

๐Ÿงน 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