Day 3 · Move In: WeChat / Telegram / Discord / Slack
Today’s Goal
Section titled “Today’s Goal”Get Hermes running inside the messaging app you actually use — WeChat if that’s your daily driver, Telegram otherwise. Finish one main track today and you’ll be able to @ Hermes from your phone and get a reply.
Prerequisites
Section titled “Prerequisites”- Day 2 complete —
hermescan hold a conversation in the terminal - Choose one platform to start. Not sure which?
- Daily WeChat user → Track 1 (WeChat)
- Want the lowest barrier → Track 2 (Telegram)
- Discord / Slack → scroll down to the Branch sections
First: the gateway is a separate process
Section titled “First: the gateway is a separate process”Hermes talks in messaging apps through the messaging gateway — a long-running process independent of the hermes CLI. Its job is to translate messages from each platform into conversations Hermes can handle.
┌──────────────┐ ┌────────────────────┐ ┌────────────┐│ WeChat / │ ←→ │ hermes gateway │ ←→ │ Hermes ││ Telegram / │ │ (long-running) │ │ core (LLM) ││ Discord / │ └────────────────────┘ └────────────┘│ Slack ... │└──────────────┘Two things this means:
- Closing
hermesin the terminal has no effect on the gateway — they’re independent processes. - The gateway must keep running for the bot to stay online. You can run it in the foreground (
hermes gateway) or install it as a system service (hermes gateway install).
Track 1: WeChat (primary for China · 30–45 min)
Section titled “Track 1: WeChat (primary for China · 30–45 min)”Step 1: Install dependencies
Section titled “Step 1: Install dependencies”The WeChat adapter needs two extra Python packages:
pip install aiohttp cryptography# For QR code rendering directly in the terminal (recommended):pip install "hermes-agent[messaging]"Step 2: Run the setup wizard and scan to log in
Section titled “Step 2: Run the setup wizard and scan to log in”hermes gateway setupSelect Weixin when the wizard asks for a platform. Then:
- The terminal shows a QR code (if you installed
hermes-agent[messaging]), or gives you an image path - Scan the QR code with your phone’s WeChat
- Tap “Confirm login” on your phone
- The wizard writes
account_id,token, andbase_urlto~/.hermes/.env; credentials land in~/.hermes/weixin/accounts/(plaintext — don’t commit to git)
After the wizard finishes, .env will look like:
WEIXIN_ACCOUNT_ID=xxxxxxxxWEIXIN_TOKEN=xxxxxxxxxxxxxxxxxxxxxxWEIXIN_DM_POLICY=pairingWEIXIN_HOME_CHANNEL= # fill in if you want to send proactive notificationsStep 3: Tighten access policy
Section titled “Step 3: Tighten access policy”The default at first login is dm_policy=pairing (anyone can DM and go through the pairing flow). For daily use, switch to allowlist so only you and specific people can chat:
WEIXIN_DM_POLICY=allowlistWEIXIN_ALLOWED_USERS=wxid_xxxxxxxxxxxx # your own WeChat wxidDon’t know your wxid? Start the gateway and send the bot a message. The logs print the sender’s wxid — copy it and paste it back.
Step 4: Start the gateway
Section titled “Step 4: Start the gateway”hermes gatewayA log line like this means it’s working:
gateway online · weixin connected · account=xxxx · long-poll=35sStep 5: Chat in WeChat
Section titled “Step 5: Chat in WeChat”Open your bot’s WeChat account on your phone (or open a DM with it) and send:
Hello, what time is it?The bot should reply with the current time. If there’s no response, check the Troubleshooting section below.
Step 6: Install as a background service (recommended)
Section titled “Step 6: Install as a background service (recommended)”Running in the foreground is fine for testing. For 24/7 uptime:
hermes gateway installhermes gateway starthermes gateway statusWeChat media and message limits
Section titled “WeChat media and message limits”| Capability | Notes |
|---|---|
| Images / video / files / voice | All supported. Tencent CDN’s AES-128-ECB encryption is decrypted automatically by the gateway |
| Single message length | Up to 4000 characters; longer messages are split at natural boundaries |
| Markdown links | The gateway renders [text](url) as a tappable reference card in WeChat |
| Proactive push | Set WEIXIN_HOME_CHANNEL to push messages from cron jobs or scheduled tasks to that conversation |
Enterprise WeChat (WeCom)
Section titled “Enterprise WeChat (WeCom)”If you’re connecting WeCom (enterprise WeChat) rather than personal WeChat, the path is different:
| Dimension | Personal WeChat (Weixin) | Enterprise WeChat (WeCom) |
|---|---|---|
| Adapter | weixin (iLink Bot) | wecom |
| Transport | HTTP long-polling | WebSocket long connection |
| Credentials | QR code login, stateful token | Create an AI Bot in the admin portal, get BOT_ID / SECRET |
| Group chat default | disabled | open (enterprise context expects it) |
| Encryption | AES-128-ECB | AES-256-CBC |
Setup is the same: hermes gateway setup, then select WeCom. The .env changes to:
WECOM_BOT_ID=your-bot-idWECOM_SECRET=your-secretFull steps: official WeCom docs.
Track 2: Telegram (30 min)
Section titled “Track 2: Telegram (30 min)”-
Register a bot with BotFather
Search for @BotFather in Telegram or open t.me/BotFather, then send:
/newbotHermes Agent ← display name (anything)my_hermes_bot ← username (must end in "bot", globally unique)BotFather returns a token like
123456789:ABCdef.... This is your bot’s password — treat it like a secret key. -
Find your Telegram user ID
The gateway allowlist uses your numeric user ID, not your username. Search for @userinfobot in Telegram, send any message, and it returns your ID (e.g.
987654321). -
Run the configuration wizard
Back in the terminal:
Terminal window hermes gateway setupThe wizard asks: which platform (select Telegram) → paste the token → paste the allowed user ID. It writes to
~/.hermes/.envautomatically:Terminal window TELEGRAM_BOT_TOKEN=123456789:ABCdef...TELEGRAM_ALLOWED_USERS=987654321 -
Start the gateway (foreground)
Terminal window hermes gatewayA log line like
gateway online · telegram connectedmeans it’s working. Don’t close this terminal — closing it takes the bot offline. -
Chat in Telegram
Open the bot you just created (the BotFather response includes a
t.me/xxxlink), tap Start, then send:Hello, what time is it?Expected response: the bot replies with the current time and mentions it used the terminal tool to check.
-
Install as a background service (optional but recommended)
Same commands as WeChat Track Step 6:
hermes gateway install && hermes gateway start.
Telegram group chats: privacy mode and @mentions
Section titled “Telegram group chats: privacy mode and @mentions”After adding your bot to a group, it will not see most messages by default — this is Telegram’s privacy mode: the bot can only see / commands, direct replies to its messages, and messages that @mention it.
Two options:
| Option | How | Effect |
|---|---|---|
| Keep privacy mode (recommended) | Leave the setting alone; trigger with @my_hermes_bot question | Bot only responds when @mentioned — no spam |
| Disable privacy mode | BotFather → /mybots → Bot Settings → Group Privacy → Turn off, then kick and re-add the bot | Bot sees all messages. Combine with require_mention: true to avoid random replies |
After disabling privacy mode, use this ~/.hermes/config.yaml snippet to limit responses:
telegram: require_mention: true mention_patterns: - "^\\s*hermes\\b" # also trigger on "hermes" without @Branch: Discord key steps
Section titled “Branch: Discord key steps”-
Create an Application + Bot: Discord Developer Portal → New Application → Bot (sidebar) → Reset Token (shown only once — copy it immediately).
-
Enable two Privileged Intents (90% of “bot doesn’t reply” issues come from missing these):
- Server Members Intent
- Message Content Intent ← without this, the bot receives message events but the text is empty
-
Invite the bot to your server using the recommended permissions integer
274878286912(send messages, read history, attach files, add reactions, etc.):https://discord.com/oauth2/authorize?client_id=YOUR_APP_ID&scope=bot+applications.commands&permissions=274878286912 -
Find your user ID: Discord Settings → Advanced → enable Developer Mode → right-click your name → Copy User ID.
-
.enventries needed:Terminal window DISCORD_BOT_TOKEN=...DISCORD_ALLOWED_USERS=your_user_id -
Run
hermes gateway setupand select Discord, or start directly withhermes gateway.
Branch: Slack key steps
Section titled “Branch: Slack key steps”Create an app at api.slack.com/apps, then:
| Step | Key point |
|---|---|
| OAuth & Permissions | Add at minimum: chat:write, app_mentions:read, channels:history, im:history, im:write, users:read, files:read, files:write |
| Socket Mode | Enable the toggle, generate an App-Level Token (starts with xapp-) |
| Event Subscriptions | Subscribe to message.im, message.channels, app_mention ← 90% of “bot doesn’t respond” issues are a missing subscription here |
| Install to Workspace | Generates the Bot Token (starts with xoxb-) |
Write both tokens to ~/.hermes/.env:
SLACK_BOT_TOKEN=xoxb-...SLACK_APP_TOKEN=xapp-...SLACK_ALLOWED_USERS=U01XXXXX # Slack user ID, not usernameFinally, run /invite @Hermes Agent in the target channel — without this, the bot won’t see that channel’s messages.
Expected Output
Section titled “Expected Output”Regardless of platform, completion looks like:
$ hermes gateway status● gateway: running● weixin: connected # or telegram / discord / slack● session: readyThen in your chosen messaging app:
You: @Hermes Which is larger: 9.8 or 9.11?Hermes: 9.8 is larger. Since 9.8 = 9.80 and 9.11 = 9.11, we have 9.80 > 9.11.