Hermes Agent Platform Messaging Integration
The Messaging Gateway lets the same Agent - with the same memory, skills, and tools - run seamlessly across 20+ platforms.
This chapter covers Gateway configuration and deployment, the session lifecycle, multi-user isolation strategies, and secure access control.
Messaging Gateway Overview
The Messaging Gateway is a resident background process that centrally manages connections, sessions, scheduled tasks, and media delivery for all messaging platforms.
Everything you teach the Agent in the CLI - memory, skills, preferences - is exactly the same across all platforms.
Supported Platforms
Hermes supports 20+ messaging platforms: CLI, Telegram, Discord, Slack, WhatsApp, Signal, Matrix, Mattermost, Email, SMS, DingTalk, Feishu/Lark, WeCom, WeChat, QQ, Yuanbao, BlueBubbles (iMessage), Home Assistant, Microsoft Teams, Google Chat, and more.
Platform Capability Comparison
| Platform | Speech | Picture | file | Message Threads | Emoji Reactions | Typing Indicators | Streaming Output |
|---|---|---|---|---|---|---|---|
| Telegram | Supported | Supported | Supported | Supported | — | Supported | Supported |
| Discord | Supported | Supported | Supported | Supported | Supported | Supported | Supported |
| Slack | Supported | Supported | Supported | Supported | Supported | Supported | Supported |
| — | Supported | Supported | — | — | Supported | Supported | |
| Signal | — | Supported | Supported | — | — | Supported | Supported |
| Feishu/Lark | Supported | Supported | Supported | Supported | Supported | Supported | Supported |
| WeCom | Supported | Supported | Supported | — | — | — | — |
| DingTalk | — | Supported | Supported | — | Supported | — | Supported |
| Microsoft Teams | — | Supported | — | Supported | — | Supported | — |
| — | Supported | Supported | Supported | — | — | — | |
| SMS | — | — | — | — | — | — | — |
| Matrix | Supported | Supported | Supported | Supported | Supported | Supported | Supported |
Cross-platform session continuity: the same Agent can maintain context across different platforms. For example, if you are halfway through a chat with the Agent on Telegram, after switching to Discord the Agent still remembers the earlier conversation.
Gateway Startup and Configuration
Desktop App Configuration
Open Messaging Platforms in the left menu to see the supported platforms; click a platform to configure it:

Configure in Interactive Mode
Use the interactive wizard to complete the initial configuration of all platforms:
hermes gateway setup

The wizard guides you through configuring each platform: selecting the platform, filling in the Bot Token, setting the allowed user list, and so on.
For example, if you select Feishu, you can choose to create a bot by scanning a QR code or by using an APP ID:

Gateway Management Commands
Example
Run in the foreground (for debugging)
hermes gateway
Install as a user-level system service (Linux systemd / macOS launchd)
hermes gateway
install
Linux: install as a system service that starts on boot
sudo
hermes gateway
install
--system
Service Control
hermes gateway start
Start the service
hermes gateway stop
Stop a service
hermes gateway restart
Restart the service
hermes gateway status
Check service status
Practical Guide: Connecting a Telegram Bot
Take Telegram as an example to walk through a complete Bot integration process.
Step 1: Create a Telegram Bot.
Search for @BotFather in Telegram, send the /newbot command, and follow the prompts to set the Bot name and username.
BotFather will return a Bot API Token in a format like:1234567890:ABCdefGHIjklMNOpqrsTUVwxyz.
Step 2: Configure Hermes Gateway.
Example
File path: ~/.hermes/config.yaml
Telegram platform configuration
platforms
:
telegram
:
enabled
:
true
bot_token
:
"1234567890:ABCdefGHIjklMNOpqrsTUVwxyz"
Optional: list of allowed user IDs (whitelist mode)
allowed_users
:
-
"123456789"
Optional: whether it must be @mentioned in a group to respond
require_mention
:
true
Optional: list of channels exempt from @mentions
free_response_channels
:
-
"-1001234567890"
Step 3: Start and test.
Example
Start the Gateway
hermes gateway start
Send a message to your Bot in Telegram to test it
For the first integration, it is recommended to use whitelist mode (allowed_users), allowing only your own account to interact with the Agent, and open it up to others only after everything is verified to work.
Slash Commands Available Within Platforms
The following commands can be used within any messaging platform:
| Command | Function |
|---|---|
| /new or /reset | Start a new session |
| /model [name] | View or switch models |
| /retry | Retry the last message |
| /undo | Undo the previous conversation turn |
| /stop | Interrupt the current task |
| /approve / /deny | Approve/reject dangerous commands |
| /background |
Run a task in a background session |
| /status | Show current session information |
| /usage | Show token usage for this session |
| /voice [on/off/tts] | Control voice replies |
| /compress | Manually compress the conversation context |
| /resume [title] | Restore a previously named session |
| / |
Invoke any installed skill |
| /reload-mcp | Reload MCP servers |
| /update | Update Hermes to the latest version |
| /help | Show all available commands |
Session Lifecycle
A Session is the core concept for managing conversations in Hermes Gateway.
Understanding how Sessions work helps you configure appropriate session isolation policies and reset rules.
SessionSource: message source descriptor
Every message entering the Gateway carries a SessionSource, which records "where this message came from".
| Field | Type | Description |
|---|---|---|
| platform | string | Platform name (telegram, discord, slack, etc.) |
| chat_id | string | Conversation identifier (DM ID, group ID, channel ID) |
| chat_type | string | Conversation type: dm (direct message), group, channel, thread |
| user_id | string | The sender's platform ID |
| user_name | string | The sender's display name |
| thread_id | string | Forum topic ID (Telegram forum) / Discord thread ID |
| guild_id | string | Discord server ID (for server isolation) |
Session Key Generation Rules
The Session Key is a deterministic string composed of fields from the SessionSource.
It determines which messages belong to the same session, with the following format:
agent:main:{platform}:{chat_type}:{chat_id}:{thread_id}:{user_id}
Examples of Session Keys in different scenarios:
| Scenario | Session Key |
|---|---|
| Telegram DM | agent:main:telegram:dm:12345 |
| Telegram group | agent:main:telegram:group:-10012345:user_abc |
| Telegram forum topic | agent:main:telegram:group:-10012345:thread_678:user_abc |
| Discord DM | agent:main:discord:dm:12345 |
| Discord server channel | agent:main:discord:channel:12345:user_abc |
| Discord thread | agent:main:discord:thread:12345:thread_678 |
The Session Key generation rule is one of the most important gateway configurations. If configured improperly, it can cause sessions of different users to "cross wires" - two different people seeing each other's conversation content.
SessionEntry: active session record
Each Session Key corresponds to a SessionEntry, which records the session's metadata and state.
| Field | Description |
|---|---|
| session_id | Unique session identifier, format: YYYYMMDD_HHMMSS_8-digit random hex |
| created_at | Session creation time |
| updated_at | Last activity time (used to determine idle timeout) |
| total_tokens | Cumulative token consumption |
| estimated_cost_usd | Cumulative cost estimate (USD) |
| suspended | Whether it was forcibly suspended (/stop command or an abnormal loop) |
| resume_pending | Whether it is awaiting recovery (a recovery flag for restart after a crash) |
Multi-User Isolation Strategy
Multi-user isolation determines whether multiple users in the same group or channel share one session or each have their own.
This configuration directly affects the user experience - a shared session means user A can see user B's conversation context.
Isolation Policy Configuration
| Configuration Item | Default value | Meaning |
|---|---|---|
| group_sessions_per_user | true | Each user in a group/channel has an independent session |
| thread_sessions_per_user | false | All users in a thread share the same session |
Behavior in Different Scenarios
| Scenario | Default behavior | Description |
|---|---|---|
| Direct Message (DM) | Always independent | DMs are always private and not configurable |
| Group/Channel | Independent session per user | User A and User B each have their own independent session context in the same group |
| Thread (forum topic) | All users share the session | In Telegram forum topics and Discord threads, all participants share the same context |
System Prompt Changes for Shared Sessions
When the session is in shared mode (shared_multi_user_session = true), the system prompt changes:
- Instead of fixing a single username, it prompts "multi-user session - message prefixes carry the sender's name"
- Each user message is prefixed with the sender's display name so the Agent knows who is speaking
- This design keeps the prompt cache effective (the system prompt does not change with the sender)
The default isolation policy (per-user for groups, shared for threads) is a best practice validated by extensive real-world use. It is not recommended to change it unless you have special requirements.
Gateway Security Configuration
User Access Control
By default, the gateway rejects all users not on the whitelist - a secure default for a Bot with terminal access.
Configure the users allowed access (in the .env file):
Example
File path: ~/.hermes/.env
Per-platform user whitelist
TELEGRAM_ALLOWED_USERS
=
123456789
,
987654321
DISCORD_ALLOWED_USERS
=
123456789012345678
SLACK_ALLOWED_USERS
=U012AB3CD,U012EF4GH
FEISHU_ALLOWED_USERS
=ou_xxxxxxxx,ou_yyyyyyyy
WECOM_ALLOWED_USERS
=user-id-
1
,user-id-
2
TEAMS_ALLOWED_USERS
=aad-object-id-
1
A whitelist that applies across all platforms
GATEWAY_ALLOWED_USERS
=
123456789
,
987654321
Allow all users (not recommended for Bots with terminal access)
GATEWAY_ALLOW_ALL_USERS
=
true
DM Pairing (an alternative to whitelists)
No need to manually configure user IDs; when a new user DMs the Bot, they receive a one-time pairing code:
Example
After a user DMs the Bot, they will see: "Pairing code: XKGH5N7P"
You then approve that user's access
hermes pairing approve telegram XKGH5N7P
View the list of pending + approved users
hermes pairing list
Revoke a user's access
hermes pairing revoke telegram
123456789
Pairing codes expire after 1 hour, are rate-limited, and are generated with cryptographically secure random numbers.
Silence Token
Used in group chats, Hooks, and automated workflows to make the Agent send no message under certain conditions:
# When the Agent response contains only one of the following contents, the gateway will not send any message to the platform:
[SILENT]
SILENT
NO_REPLY
NO REPLY
Silence is a delivery decision and does not affect the session record - the reply is still stored in the session history, keeping the turn-taking logic intact.
Session Reset Policy
Configure when sessions are automatically reset to prevent unbounded context growth:
Example
{
"reset_by_platform": {
"telegram": { "mode": "idle", "idle_minutes": 240 },
"discord": { "mode": "idle", "idle_minutes": 60 },
"slack": { "mode": "daily", "reset_hour": 4 }
}
}
| Strategy | Default value | Description |
|---|---|---|
| daily | 4:00 AM | Reset sessions at a specific time each day |
| idle | 1440 minutes | Reset the session after an idle timeout |
| both | Combination | Whichever triggers first resets the session |
Common Command Quick Reference
Example
─── Gateway Management ────────────────────────────────────────────────
hermes gateway setup
Interactive platform configuration
hermes gateway
Run in the foreground (debug)
hermes gateway
install
Install as a user service
hermes gateway start
/
stop
/
restart
Service Control
hermes gateway status
Check service status
─── User Pairing ────────────────────────────────────────────────
hermes pairing list
View the pairing list
hermes pairing approve
<
platform
<
codehermes pairing revoke
<
platform
<
user_id
/
new
/
model
[
Name
]
/
retry
/
undo
/
stop
/
approve
/
/
deny
/
background
<
Task
/
status
/
usage
/
voice
[
on
/
off
/
tts
]
/
compress
/
resume
[
Title
]
/<
skill-name
/
reload-mcp
/
update
/
help