Connecting AI Agents to Discord, Lessons from Real Setup Failures

How I connected Hermes Agent to a Discord bot, and the permission and intent mistakes that cost me the most time.
Markdown sourceยทAnything to add or correct?

After Telegram, I tried attaching Hermes Agent to Discord too. Telegram is done with one token from BotFather, but Discord involves bot invitation and permission settings, so that part took longer. Here is what I actually went through. (measured on the operator's environment)

1. Creating the bot: Developer Portal

Telegram has BotFather as a single bot account. Discord manages things at the project level instead.

  1. Go to Discord Developer Portal
  2. Click New Application in the top right, enter a name
  3. Select Bot in the left menu, click Reset Token to get the token
  4. On the same screen, turn MESSAGE CONTENT INTENT ON

The token format looks like this:


MTIzNDU2Nzg5MDEyMzQ1Njc4.GaBcDe.thisIsAFakeTokenExample

Pitfall 1: Without MESSAGE CONTENT INTENT, the bot cannot read messages

If this switch is off, the bot cannot access channel message content. Even if you set every permission correctly, you get no responses. It is easy to move on after just getting the token. Check the Bot screen in the portal to make sure it is on.

2. Inviting the bot to your server

  1. Left menu OAuth2 โ†’ URL Generator
  2. Check scopes bot and applications.commands
  3. Check bot permissions: View Channels, Send Messages, Read Message History, Attach Files
  4. Open the generated URL in a browser, select the server, and invite

Pitfall 2: Permission problems show up as silence

Discord does not throw errors when permissions are missing โ€” it just ignores messages. If the bot is online but silent, permission issues are the most likely cause. Check the server settings โ†’ Integrations โ†’ bot name โ†’ permissions tab.

3. Getting your Discord user ID

Turn on Developer Mode in user settings, right-click any user, and select Copy User ID.


123456789012345678

Pitfall 3: Use the numeric ID, not the username

Filtering with @myid does not work. You need the numeric ID.

4. .env configuration


DISCORD_BOT_TOKEN=MTIzNDU2Nzg5MDEyMzQ1Njc4.GaBcDe.thisIsAFakeTokenExample
DISCORD_ALLOWED_USERS=123456789012345678
DISCORD_MESSAGE_PREFIX=!

Pitfall 4: Without a prefix, every channel message becomes a request

Discord sends all channel messages to the bot. Without a prefix, casual chat goes straight to the LLM and costs add up. I set this up without understanding the prefix concept and briefly fed an entire channel's conversation into the model.

Pitfall 5: Do not put quotes around the token


DISCORD_BOT_TOKEN="MTIzNDU2..."

Quotes get included in the token and you get 401: Unauthorized. Same trap as Telegram.

5. Running


hermes gateway start

Pitfall 6: Do not run the gateway in two places at once

Telegram gave an explicit 409 Conflict, but Discord silently retries the websocket connection. If the connection seems fine but no messages arrive, check whether another process is using the same token.

6. Comparison with Telegram

TelegramDiscord
Bot creationInstant via BotFatherDeveloper Portal project
Required switchNoneMESSAGE CONTENT INTENT ON
PermissionsAllowed Users is enoughChannel permissions + Allowed Users
Duplicate run409 ConflictSilent reconnect loop
Cost controlSession message countMessage prefix is mandatory

Summary

  1. Developer Portal โ†’ create Application โ†’ Bot โ†’ get token, turn MESSAGE CONTENT INTENT ON
  2. OAuth2 URL Generator with bot + applications.commands, check 4 channel permissions
  3. Developer Mode to get numeric user ID โ†’ DISCORD_ALLOWED_USERS
  4. Write token without quotes in .env, set DISCORD_MESSAGE_PREFIX
  5. hermes gateway start โ€” if it fails, check permissions โ†’ prefix โ†’ duplicate run in that order

Discord is channel-based, so it is better for teams. Setting up permissions is heavier than Telegram, but for a team channel it is worth it.