Skip to content
NEWMarketplace and the trig8n Agent: sell what you build, and get plans and changes that are tested before you see them. See what is new

Library / Security & Compliance

Security & Compliance

Detect and Warn Discord Spam with OpenAI

On a schedule or when called, it reads recent Discord messages, classifies spam with OpenAI and warns the users who posted it.

What it does

## 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? Join the [Discord]({{ $env.WEBHOOK_URL }} or ask in the [Forum]({{ $env.WEBHOOK_URL }}

The steps

  1. Spam Detection
  2. Get Recent Messages
  3. Only Once
  4. Model
  5. Warn User
  6. Warn User Only
  7. Group By User
  8. For Each User...
  9. Split Out
  10. Message to List
  11. Notify Moderators with Send & Wait
  12. Flag as Spam
  13. Flag as Not Spam
  14. Merge

30 steps in total.

Similar automations