text classifier and list message discord and removeitemsseeninpreviousexecutions remove duplicates
Configured with Discord, Execute Workflow, Execute Workflow Trigger, Filter, and additional nodes. Review the connections and setup before adapting this template.
Node categories in this workflow
- AI & models
- Messaging
- Transform
- Code
- Routing
- Subworkflow
- Trigger
Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.
Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.
How it works
The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.
| Node | Category | Type | Operation |
|---|---|---|---|
| Spam Detection | AI & models | Text Classifier | See node parameters |
| Get Recent Messages | Messaging | Discord | message / getAll |
| Only Once | Transform | Remove Duplicates | removeItemsSeenInPreviousExecutions |
| Model | AI & models | OpenAI Chat Model | See node parameters |
| Warn User | Messaging | Discord | message |
| Warn User Only | Messaging | Discord | message |
| Group By User | Code | Code | See node parameters |
| For Each User... | Routing | Loop Over Items | See node parameters |
| Split Out | Transform | Split Out | See node parameters |
| Message to List | Code | Code | See node parameters |
| Notify Moderators with Send & Wait | Messaging | Discord | message / sendAndWait |
| Flag as Spam | Transform | Edit Fields | See node parameters |
| Flag as Not Spam | Transform | Edit Fields | See node parameters |
| Merge | Transform | Merge | See node parameters |
| Spam Messages Only | Routing | Filter | See node parameters |
| Has Flagged Messages? | Routing | If | See node parameters |
| Get Message IDs | Code | Code | See node parameters |
| Delete Messages | Messaging | Discord | message / deleteMessage |
| Receive Instructions | Routing | Switch | See node parameters |
| Moderation Subworkflow | Subworkflow | Execute Workflow | See node parameters |
| When Executed by Another Workflow | Trigger | Execute Workflow Trigger | See node parameters |
| No Action Taken | Routing | No Op | See node parameters |
| Schedule Trigger | Trigger | Schedule Trigger | See node parameters |
Setup
- Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
- Connect your own credentials through n8n’s credential store. Replace
REPLACE_WITH_*values with your resource identifiers. - Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
- Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.
Requirements
An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.
Credential types declared in the source
discordBotApiopenAiApi
Workflow notes
1. Get Channel Messages
1. Get Channel Messages
Read more about the scheduled Trigger
The scheduled trigger is used to execute this workflow throughout the day. Depending on how busy your community is, you may want to increase the messages fetched or set shorter intervals. The "Remove Duplicates" node is used to ensure we only process new messages.
2. Group Messages By User
2. Group Messages By User
Learn more about the loop node
When dealing with nested data such as user and messages, using the loop node is a great way to ensure item references are not getting mixed up. Here, we're grouping users so that we can batch their messages and help minimise the number of notifications we need to send.
3. Spam Detection using AI-powered Text Classification
3. Spam Detection using AI-powered Text Classification
Learn more about the text classification node
In this template, our goal is to moderate spam messages and one way to do this is by using an AI text classifier. This approach uses a Reasoning LLM to determine if a message falls into a generalised criteria of spam ie. promotion. You may prefer to customise this prompt for production use-case.
5. Moderation using Human-in-the-Loop
5. Moderation using Human-in-the-Loop
Read more about n8n's human-fallback functionality
In this step, we can use the "Send and Wait for Response" operation in our Discord node to allow human moderators to decide which actions to perform on the flagged messages. There are currently 3 response types available and in this template, we'll use the custom form option which allows us to specify a dropdown list from which the moderator can select from a predefined list of actions. Using this approach, we can ensure consistency across all moderators.
6. Execute Moderation Actions
6. Execute Moderation Actions
Learn more about the Discord node
Finally, moderation actions can be executed on behalf of the moderator and thus saving them time. In the case of the delete action, the template will bulk remove the flagged messages accurately and even across multiple channels.
4. Concurrent Processing using Subworkflows
4. Concurrent Processing using Subworkflows
Learn more about Subworkflow Trigger
One issue we might come across if we have a human-in-the-loop step inside another loop is that later users will not be processed until the current user is actioned. One way of solving this is to use subworkflows. Subworkflows allow us to run our remaining workflow steps in a separate execution and with specifically the "wait for subworkflow completion" set to "off", it won't block our current loop.
Try it out
Try it out
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.
Need Help?
text classifier and list message discord and removeitemsseeninpreviousexecutions remove duplicates
text classifier and list message discord and removeitemsseeninpreviousexecutions remove duplicates
Purpose and structure
This folder contains the text classifier and list message discord and removeitemsseeninpreviousexecutions remove duplicates workflow. Its executable nodes use code, discord, executeWorkflow, executeWorkflowTrigger, filter, if, lmChatOpenAi, merge, noOp, removeDuplicates, scheduleTrigger, set, splitInBatches, splitOut, switch, textClassifier. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.
Setup
Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.
Entry points
When Executed by Another Workflow, Schedule Trigger
Verification
Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.
Attribution
https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Splitout/0816_Splitout_Code_Automation_Scheduled.json MIT; preserve source notices.