Skip to main content

Automated discord spam moderation with AI and human-in-the-loop

Workflow preview

Workflow preview
100%
Automated discord spam moderation with AI and human-in-the-loop preview
Open on n8n.io

Important notice

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

1. Workflow Overview

This n8n template demonstrates how you can automate community moderation using human in the loop functionality for Discord. The use case is for detecting and dealing with spam messages in a predefi...

Best for

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

Tools used

@n8n/n8n-nodes-langchain.textclassifier, n8n-nodes-base.discord, n8n-nodes-base.removeduplicates, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.code, n8n-nodes-base.splitinbatches, n8n-nodes-base.splitout, n8n-nodes-base.set

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Automated discord spam moderation with AI and human-in-the-loop
Workflow name
Automated discord spam moderation with AI and human-in-the-loop

This n8n template demonstrates how you can automate community moderation using human-in-the-loop functionality for Discord.

The use-case is for detecting and dealing with spam messages in a predefined and consistent way. Human-in-the-loop allows for a balance between overly aggressive bots and time and effort from the moderation team.

How it works

  • A scheduled trigger is used to scan the most recent messages in a Discord Channel. Messages are tagged via the "Remove Duplicates" node so they don't get processed again in the future.
  • Messages are grouped by user to allow for minimising of number of notifications sent.
  • An AI text classifier node is then used to detect for spam in each user's message.
  • When detected, a notification is sent to a moderation channel using the Send-and-wait mode for Discord. This notification comes with an n8n form and dropdown list of predefined actions to take in dealing with the spam messages. Once sent the workflow waits until a response is received.
  • Once a moderator selects an action, the workflow continues and carries out a predefined moderation action.

How to use

  • Depending on how busy your community is and subject to spammers, you may need to increase the scheduled interval.
  • Add as many or few moderation actions as required.
  • Remember to activate the workflow to get it started.

Requirements

  • Discord channel for messages to moderate
  • OpenAI for text classification

Customising this template

  • It is possible to cover multiple channels. Add as many as your community needs.
  • Not using Discord. The template can also work in slack or other services which offer the same bot functionality.

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 - Spam Detection

Type / Role
@n8n/n8n-nodes-langchain.textClassifier - textClassifier
Config choices
Version 1

Block 2 - Get Recent Messages

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

Block 3 - Only Once

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

Block 4 - Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 5 - Warn User

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

Block 6 - Warn User Only

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

Block 7 - Group By User

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

Block 8 - For Each User...

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

Block 9 - Split Out

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 10 - Message to List

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

Block 11 - Notify Moderators with Send & Wait

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

Block 12 - Flag as Spam

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

Block 13 - Flag as Not Spam

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

Block 14 - Merge

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

Block 15 - Spam Messages Only

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

Block 16 - Has Flagged Messages?

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

Block 17 - Get Message IDs

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

Block 18 - Delete Messages

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

Block 19 - Receive Instructions

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

Block 20 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 23 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

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

3. Summary Table

Workflow Automated discord spam moderation with AI and human-in-the-loop
Complexity advanced
Nodes 30
Categories Miscellaneous, AI Summarization
Author Jimleuk
Published 29 Mar 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3351/3351.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 Automated discord spam moderation with AI and human-in-the-loop do?

This n8n template demonstrates how you can automate community moderation using human in the loop functionality for Discord. The use case is for detecting and dealing with spam messages in a predefi...

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, AI Summarization use case.