How do you set up an AI to reply automatically to people on Discord?

Updated 2026-07-151,900 searches/moRanked #159 of 519· AI explained
Short answer

Create an application in the Discord Developer Portal, add a bot, invite it to your server, then wire its messages to an AI model's API. Two rules that trip everyone up: you must enable the privileged MESSAGE CONTENT intent to read messages, and Discord's Developer Policy bars using API message content to train AI models without express permission.

Why — the first-principles explanation

A Discord bot is not a feature you switch on. It's a program you run on a computer you control, which holds an open connection to Discord's servers. That's the whole idea. Discord pushes events to your program — someone posted, someone joined — and your program decides whether to call back with a message. Discord hosts nothing of yours. If your program stops, the bot goes offline instantly. This is why "my bot is offline" is the most common beginner problem and why the answer is always "is your script still running?"

Adding AI changes only one line of that loop. Without AI, the loop is: event arrives → check if it matches a rule → send canned reply. With AI, it becomes: event arrives → send the text to a model's API → wait → send whatever comes back. The bot code is identical. The AI is just a slow, expensive function call in the middle. Understanding this saves you enormous confusion: the bot and the AI are separate systems that you are gluing together, and when things break, one of the two is at fault, not some fused "AI bot" entity.

Now the permission model, which exists for a real reason. By default your bot can see that a message happened but not what it said. Reading message content is a privileged intent — you must explicitly enable MESSAGE CONTENT in the Developer Portal, and once your bot is in roughly 100 servers you need Discord's approval for it. Discord did this deliberately: a bot that reads every message in every server it's in is a surveillance tool, so they made the surveillance capability opt-in and reviewed. If your bot silently ignores everything people say, this is nearly always why.

Finally, the constraint that most tutorials skip. Discord's Developer Policy prohibits using message content obtained through the APIs to train machine learning or AI models, including large language models, without express permission from Discord. Sending a message to an API to generate a reply is normal use. Harvesting your server's chat logs to fine-tune a model on them is not. That distinction is a policy line, and it's the one most likely to get an app terminated.

An example that makes it click

Think of the bot as a receptionist you hire and the AI as a consultant across town. The receptionist sits in your lobby all day — that's your program running. When someone walks in and asks a question, the receptionist can't answer it herself. She phones the consultant, waits, and repeats what he says. If you fire the receptionist, the lobby is empty even though the consultant still exists. If the consultant's phone is busy, the receptionist stands there awkwardly — that's an API timeout.

And the intent setting? That's whether the receptionist is legally allowed to listen to what people say in the lobby, versus just noticing that someone's mouth is moving. Discord makes you ask for that permission on purpose.

How to do it

  1. Go to the Discord Developer Portal, click New Application, name it, then open the Bot tab and click Add Bot. Copy the bot token once and store it somewhere safe — treat it like a password; anyone with it controls your bot.
  2. On the Bot tab, scroll to Privileged Gateway Intents and enable MESSAGE CONTENT INTENT. Without this, your bot receives message events with empty content and will appear to ignore everyone.
  3. Open OAuth2 → URL Generator, check the "bot" scope, then check permissions: Send Messages, Read Message History, and View Channels. Grant nothing else — a bot with Administrator is a security hole waiting to happen.
  4. Open the generated invite URL and add the bot to a server where you have Manage Server permission.
  5. Install a Discord library on your machine: discord.py for Python or discord.js for JavaScript. Both are free, mature, and have official quickstarts.
  6. Get an API key from an AI provider (OpenAI, Anthropic, Google, or a local model via Ollama if you want zero cost and full privacy).
  7. Write the loop: on message received → ignore messages from bots including your own, or you'll build an infinite reply loop → send the text to the AI API → send the response back to the channel. Fewer than 30 lines in either library.
  8. Add guardrails before you let anyone else use it: only respond when @mentioned or in one designated channel, cap replies per user per minute, and cap the token length of responses. Without these, one bored user can run up a real API bill.
  9. Host it somewhere that stays on. Your laptop closing = bot offline. A small VPS, a Raspberry Pi, or a free-tier container all work.
  10. Tell your members the bot uses AI and what it does with their messages. Do not feed server chat logs into model training — Discord's Developer Policy prohibits using API message content to train AI models without express permission.

Key facts

Infographic: How do you set up an AI to reply automatically to people on Discord — short answer and key facts
Visual summary — How do you set up an AI to reply automatically to people on Discord?
▶ The 60-second explainer (script)

How do you set up an AI to auto-reply on Discord? First, understand what a bot actually is: it's a program you run, on a computer you control, that holds an open connection to Discord. Discord hosts nothing of yours. If your script stops, the bot goes offline. That's why "my bot is offline" always comes down to "is your program still running?" Adding AI changes exactly one line. Without AI: event arrives, match a rule, send a canned reply. With AI: event arrives, send the text to a model's API, wait, send back whatever comes. Same bot code. The AI is just a slow function call in the middle. Now the setup. Go to the Discord Developer Portal, make a New Application, add a Bot, copy the token — treat it like a password. Then the step everyone misses: scroll to Privileged Gateway Intents and turn on MESSAGE CONTENT. By default your bot can see that a message happened but not what it said. Discord made that opt-in on purpose — a bot reading every message is a surveillance tool. If your bot ignores everybody, this is why. Invite it with OAuth2, grant only Send Messages and Read Message History — never Administrator. Then install discord.py or discord.js, get an AI API key, and write the loop. Under thirty lines. Two guardrails: ignore messages from bots, or you'll build an infinite reply loop. And rate-limit per user, or one bored person runs up your API bill. Last thing: Discord's Developer Policy bars using API message content to train AI models without permission. Generating replies is fine. Harvesting chat logs to fine-tune is not.

What authoritative sources say

Discord — Discord Developer Policyofficial — Discord's Developer Policy prohibits using message content obtained through the APIs to train machine learning or AI models, including large language models, without express permission from Discord. source ↗
Discord Developer Platform — Documentationofficial — Discord's official developer documentation covers creating applications, adding bots, gateway intents, and OAuth2 permission scopes. source ↗
Discord Blog — Supercharge Your Moderation with AutoMod in Your Appsofficial — Discord's built-in AutoMod provides keyword and spam filtering, and developers can integrate their own applications directly with AutoMod. source ↗

People also ask

Why does my bot ignore every message?

Almost always the MESSAGE CONTENT privileged intent is off. Enable it on the Bot tab of the Developer Portal. Without it, your bot receives message events with the content field empty.

Can I do this without coding?

Yes — several hosted services connect a Discord bot to an AI model through a web dashboard. You trade flexibility and privacy for setup speed, since your server's messages then pass through a third party.

How much does it cost to run?

Discord charges nothing for bots. Your costs are AI API usage (per token, so it scales with how chatty your server is) and hosting. Running a local model with Ollama on your own hardware makes the API cost zero.

Is it against the rules to have an AI bot on Discord?

No. Bots are a supported first-class feature. The policy line is about data: you cannot use message content pulled from Discord's APIs to train AI models without Discord's express permission.

How do I stop it from replying to itself?

Check the message author at the top of your handler and return immediately if the author is any bot, including your own. Skipping this creates an infinite loop that will get your bot rate-limited within seconds.

Related questions