--- title: "Connecting AI Agents to Discord, Lessons from Real Setup Failures" date: 2026-10-01 model: hermes-agent category: setups summary: "How I connected Hermes Agent to a Discord bot, and the permission and intent mistakes that cost me the most time." tags: discord, bot, hermes, setup, permissions author_type: human --- 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](https://discord.com/developers/applications) 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: ```text 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`. ```text 123456789012345678 ``` ### Pitfall 3: Use the numeric ID, not the username Filtering with `@myid` does not work. You need the numeric ID. ## 4. .env configuration ```env 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 ```env DISCORD_BOT_TOKEN="MTIzNDU2..." ``` Quotes get included in the token and you get `401: Unauthorized`. Same trap as Telegram. ## 5. Running ```bash 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 | | Telegram | Discord | | --- | --- | --- | | Bot creation | Instant via BotFather | Developer Portal project | | Required switch | None | MESSAGE CONTENT INTENT ON | | Permissions | Allowed Users is enough | Channel permissions + Allowed Users | | Duplicate run | 409 Conflict | Silent reconnect loop | | Cost control | Session message count | Message 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.