# Automated Discord spam moderation with OpenAI: n8n workflow

> Started by a clock, and works across Discord. It hands the judgement calls to OpenAI. 23 steps, 2 branches, 1 loop or waits: large, and worth reading before...

Source: https://millionrounds.com/workflow/automated-discord-spam-moderation-with-openai (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Chat assistants](https://millionrounds.com/workflows?category=Chat+assistants#library)

# Automated Discord spam moderation with OpenAI

Started by a clock, and works across Discord. It hands the judgement calls to OpenAI. 23 steps, 2 branches, 1 loop or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fautomated-discord-spam-moderation-with-openai)

**23 steps** Large: read it before trusting it with anything live

**2** Branches: places the flow splits

**1** Loop or waits

**1** Service it connects to

## The flow

Starts it 2 Model 2 Logic 14 Service 5

The steps in the order they run, from what starts it.

- 1 **Model** Lm Chat Open Ai *Model*
- 2 **When Executed by Another Workflow** Execute Workflow trigger *Starts it*
- 3 **Schedule Trigger** Schedule trigger *Starts it*
- 4 **Spam Detection** Text Classifier *Model*
- 5 **Notify Moderators with Send & Wait** Discord *Service*
- 6 **Get Recent Messages** Discord *Service*
- 7 **Flag as Spam** Set *Logic*
- 8 **Flag as Not Spam** Set *Logic*
- 9 **Receive Instructions** Switch *Logic*
- 10 **Only Once** Remove Duplicates *Logic*
- 11 **Merge** Merge *Logic*
- 12 **Get Message IDs** Code *Logic*
- 13 **Warn User Only** Discord *Service*
- 14 **No Action Taken** No Op *Logic*
- 15 **Group By User** Code *Logic*
- 16 **Spam Messages Only** Filter *Logic*
- 17 **Delete Messages** Discord *Service*
- 18 **Split Out** Split Out *Logic*
- 19 **Has Flagged Messages?** If *Logic*
- 20 **Warn User** Discord *Service*
- 21 **For Each User...** Split In Batches *Logic*
- 22 **Moderation Subworkflow** Execute Workflow *Logic*
- 23 **Message to List** Code *Logic*

## How it's built

- **Starts on:** A clock
- **Steps:** 23, with 2 branches, 1 loop or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Discord
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Discord account, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on a clock.

Does it use AI?

Yes. It calls OpenAI. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 23 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 23 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fautomated-discord-spam-moderation-with-openai)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Discord](https://millionrounds.com/workflows?service=Discord#library)

## Workflows like it

Also chat assistants, with the same services where possible, closest in size first.

- [**Respond to Google reviews and send weekly digests** 23 steps · calls a model · Discord, Gmail](https://millionrounds.com/workflow/respond-to-google-reviews-and-send-weekly-digests)
- [**Find reply-worthy Hacker News and Stack Overflow threads** 22 steps · calls a model · Discord, n8n data table](https://millionrounds.com/workflow/find-reply-worthy-hacker-news-and-stack-overflow-threads)
- [**Multi-account email classifier with Gmail and Discord** 22 steps · calls a model · Discord, Gmail](https://millionrounds.com/workflow/multi-account-email-classifier-with-gmail-and-discord)
- [**Review GitHub pull requests with Mistral** 25 steps · calls a model · Discord, GitHub](https://millionrounds.com/workflow/review-github-pull-requests-with-mistral)
- [**Revive quiet client projects with OpenAI and Airtable** 26 steps · calls a model · Airtable, Discord](https://millionrounds.com/workflow/revive-quiet-client-projects-with-openai-and-airtable)
- [**Analyze event feedback with Gemini and Discord** 27 steps · calls a model · Discord, Gmail](https://millionrounds.com/workflow/analyze-event-feedback-with-gemini-and-discord)
