Fix Hermes Agent Profile Routing Error: Discord & Telegram Bots
If you've ever tried switching profiles in Hermes Agent and got hit with "AttributeError: 'str' object has no attribute 'get'", you're not alone. This Discord and Telegram routing bug happens when bot tokens live inside a profile-specific .env file instead of the root configuration.
Here's what goes wrong — and how to fix it in under five minutes.
The Problem: Bots Bind to the Wrong Profile
Hermes Agent stores Discord and Telegram bot tokens inside a .env file. When that file sits inside a named profile folder — for example profiles/teknoding-content-creator/.env — the bot binds itself to that profile by default, not to the default profile.
Trying to switch profiles with hermes use profile <name> then causes the routing system to break, throwing the AttributeError mentioned above. The bot's configuration becomes misaligned with the running gateway.
The Fix: Three Simple Steps
The solution is straightforward. Move your bot tokens from profile-level storage to root-level storage, clean up leftovers, and restart the service.
Step 1 — Migrate Tokens to Root .env
Locate the .env file inside your profile folder:
c:\Users\YOUR-PC-NAME\AppData\Local\hermes\profiles\teknoding-content-creator\.env
From there, extract these values:
DISCORD_BOT_TOKENTELEGRAM_BOT_TOKENTELEGRAM_ALLOWED_USERSTELEGRAM_HOME_CHANNELDISCORD_ALLOWED_USERSDISCORD_HOME_CHANNEL
And move them to the root .env at:
c:\Users\YOUR-PC-NAME\AppData\Local\hermes\.env
This is the main Hermes configuration file — the one the gateway reads first when starting up.
Step 2 — Clean Up Profile-Level Config
After migration, remove the leftover bot configuration from your profile's .env. Keeping duplicate entries causes overlapping gateway processes and routing conflicts.
The goal is a single source of truth — the root .env owns all bot tokens, and profile .env files contain only profile-specific settings (API keys, model preferences, etc.).
Step 3 — Restart the Hermes Gateway
Restart the Hermes Gateway service so it picks up the new environment variables. Once restarted, the gateway boots into the default profile correctly, and the AttributeError disappears.
Your Discord and Telegram bots now route to the intended profile without conflict.
How to Set Up Bots for a New Profile
If you want a dedicated bot for a specific profile — say, a personal assistant called asisten-pribadi — the process is similar but with a critical rule:
Token Isolation
Each profile needs its own unique bot token. Do NOT reuse the same token across profiles. One token = one bot = one gateway. Sharing a token between two profiles causes both gateways to fight over the same connection.
Profile .env Location
For a new profile named asisten-pribadi, create or edit this file:
c:\Users\YOUR-PC-NAME\AppData\Local\hermes\profiles\asisten-pribadi\.env
Add Profile-Specific Bot Config
Inside that file, insert the new bot's tokens:
TELEGRAM_BOT_TOKEN=token_bot_telegram_yang_baru TELEGRAM_ALLOWED_USERS=123456789 TELEGRAM_HOME_CHANNEL=123456789 DISCORD_BOT_TOKEN=token_bot_discord_yang_baru DISCORD_ALLOWED_USERS=987654321 DISCORD_HOME_CHANNEL=987654321
Start the Gateway for That Profile
Run the gateway targeting your new profile:
hermes --profile asisten-pribadi gateway start
The bot now binds exclusively to asisten-pribadi, leaving the default profile's bot untouched.
Why This Works
Hermes Agent reads .env files in a priority chain. The root .env is loaded first and sets the baseline configuration. Profile-level .env files overlay profile-specific settings on top. When bot tokens live at the root level, they apply globally — meaning the gateway can route them correctly regardless of which profile is active.
Putting tokens inside a profile folder tells Hermes "this token belongs to this profile only." That's useful for multi-bot setups but breaks routing when you try to switch profiles mid-session.
Key Takeaways
- Bot tokens belong in the root
.envunless you specifically want multi-bot isolation. - Never reuse the same bot token across multiple profiles.
- Always restart the gateway after changing
.envfiles. - Profile
.envfiles are for profile-specific settings — not shared bot configuration.
This fix clears the AttributeError and gives you clean, predictable profile routing. If you're running multiple Hermes profiles with their own bots, just remember the one-token-per-profile rule and you'll never hit this issue again.
Post a Comment for "Fix Hermes Agent Profile Routing Error: Discord & Telegram Bots"