Skip to main content

Bulk delete Slack messages with smart filtering and confirmations

Workflow preview

Workflow preview
100%
Bulk delete Slack messages with smart filtering and confirmations preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

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 Soluti...

Best for

  • Miscellaneous automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.code, n8n-nodes-base.if, n8n-nodes-base.slack, n8n-nodes-base.splitinbatches, n8n-nodes-base.wait, n8n-nodes-base.webhook, n8n-nodes-base.set, n8n-nodes-base.switch

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Elie Kattar.

Original n8n.io source

1.1 Workflow description

Title
Bulk delete Slack messages with smart filtering and confirmations
Workflow name
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

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Parse Command

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 2 - Check if Valid Command

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 3 - Send Error Message

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.3

Block 4 - Get Channel Messages

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.3

Block 5 - Filter Messages by Search Term

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 6 - Messages Found?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 7 - No Messages Found

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.3

Block 8 - Send Confirmation Message

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.3

Block 9 - Store Pending Deletion

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Delete or Cancel?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 11 - Send Cancel Message

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.3

Block 12 - Loop Over Messages

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 13 - Wait Between Deletes

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 14 - Delete Message

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.3

Block 15 - Send Completion Message

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.3

Block 16 - Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 17 - Respond to Webhook

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 18 - Check User Message

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 19 - If1

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 20 - Code Count

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 21 - Wait

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 22 - Error Report

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.3

Block 23 - Prase Set

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 24 - Switch

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Showing the first 24 of 48 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Bulk delete Slack messages with smart filtering and confirmations
Complexity advanced
Nodes 48
Categories Miscellaneous
Author Elie Kattar
Published 15 Jun 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4948/4948.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Bulk delete Slack messages with smart filtering and confirmations do?

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 Soluti...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Miscellaneous use case.