Yuanbao
قناة Yuanbao
What this page is, and what it holds.
This page covers Yuanbao. You will use hermes chat and hermes gateway here; about 8 minutes to read. Open the channel to yourself first with an allowlist. An open channel means anyone can message your agent.
Connect Hermes Agent to the Yuanbao enterprise messaging platform via WebSocket gateway
Outcomes taken from this page, not a template.
- Understand what بوابة المراسلة is and when you need it.
- Run
hermes chatandhermes gatewayand understand what happens next. - Read the table and take only the row that applies to you.
- Set
YUANBAO_APP_IDin the right place.
Exactly as they appear in Hermes.
hermes chathermes gatewayhermes gateway runhermes gateway setup
YUANBAO_APP_IDYUANBAO_APP_SECRETYUANBAO_WS_URLYUANBAO_API_DOMAINYUANBAO_BOT_IDYUANBAO_ROUTE_ENVYUANBAO_HOME_CHANNELYUANBAO_HOME_CHANNEL_NAME
Jump to the part you need.
Nothing summarised away.
The documentation body below is reproduced from the official source so commands and identifiers stay exact. Each section carries a short note describing what it contains.
Connect Hermes to Yuanbao ↗, Tencent's enterprise messaging platform. The adapter uses a WebSocket gateway for real-time message delivery and supports both direct (C2C) and group conversations.
Prerequisites
Explains the idea itself. Read it slowly; the later sections build on it.
- A Yuanbao account with bot creation permissions
- Yuanbao APP_ID and APP_SECRET (from platform admin)
- Python packages:
websocketsandhttpx - For media support:
aiofiles
Install the required dependencies:
pip install websockets httpx aiofilesSetup
Ordered, practical steps. Run one and confirm it worked before moving on. Commands here: hermes gateway, hermes gateway setup.
1. Create a Bot in Yuanbao
- Download the Yuanbao app from https://yuanbao.tencent.com/ ↗
- In the app, go to PAI → My Bot and create a new bot
- After the bot is created, copy the APP_ID and APP_SECRET
2. Run the Setup Wizard
The easiest way to configure Yuanbao is through the interactive setup:
hermes gateway setupSelect Yuanbao when prompted. The wizard will:
- Ask for your APP_ID
- Ask for your APP_SECRET
- Save the configuration automatically
3. Configure Environment Variables
After initial setup, verify these variables in ~/.hermes/.env:
# Required
YUANBAO_APP_ID=your-app-id
YUANBAO_APP_SECRET=your-app-secret
YUANBAO_WS_URL=wss://api.yuanbao.example.com/ws
YUANBAO_API_DOMAIN=https://api.yuanbao.example.com
# Optional: bot account ID (normally obtained automatically from sign-token)
# YUANBAO_BOT_ID=your-bot-id
# Optional: internal routing environment (e.g. test/staging/production)
# YUANBAO_ROUTE_ENV=production
# Optional: home channel for cron/notifications (format: direct:<account> or group:<group_code>)
YUANBAO_HOME_CHANNEL=direct:bot_account_id
YUANBAO_HOME_CHANNEL_NAME="Bot Notifications"
# Optional: restrict access (legacy, see Access Control below for fine-grained policies)
YUANBAO_ALLOWED_USERS=user_account_1,user_account_24. Start the Gateway
hermes gatewayThe adapter will connect to the Yuanbao WebSocket gateway, authenticate using HMAC signatures, and begin processing messages.
Features
Explains the idea itself. Read it slowly; the later sections build on it.
- WebSocket gateway — real-time bidirectional communication
- HMAC authentication — secure request signing with APP_ID/APP_SECRET
- C2C messaging — direct user-to-bot conversations
- Group messaging — conversations in group chats
- Media support — images, files, and voice messages via COS (Cloud Object Storage)
- Markdown formatting — messages are automatically chunked for Yuanbao's size limits
- Message deduplication — prevents duplicate processing of the same message
- Heartbeat/keep-alive — maintains WebSocket connection stability
- Typing indicators — shows "typing…" status while the agent processes
- Automatic reconnection — handles WebSocket disconnections with exponential backoff
- Group information queries — retrieve group details and member lists
- Sticker/Emoji support — send TIMFaceElem stickers and emoji in conversations
- WeChat forwarded chat-history support — when a user forwards a WeChat chat-history bundle into Yuanbao, the adapter decodes the forwarded records (sender nicknames, text, and multimedia entries, including nested forwards) and injects them into the conversation so the agent can read the full forwarded thread
- Auto-sethome — first user to message the bot is automatically set as the home channel owner
- Slow-response notification — sends a waiting message when the agent takes longer than expected
Configuration Options
Explains the idea itself. Read it slowly; the later sections build on it.
Chat ID Formats
Yuanbao uses prefixed identifiers depending on conversation type:
| Chat Type | Format | Example |
|---|---|---|
| Direct message (C2C) | direct:<account> | direct:user123 |
| Group message | group:<group_code> | group:grp456 |
Media Uploads
The Yuanbao adapter automatically handles media uploads via COS (Tencent Cloud Object Storage):
- Images: Supports JPEG, PNG, GIF, WebP
- Files: Supports all common document types
- Voice: Supports WAV, MP3, OGG
Media URLs are automatically validated and downloaded before upload to prevent SSRF attacks.
Home Channel
Settings you configure once. Change one at a time so you can see what each does. Set YUANBAO_HOME_CHANNEL, YUANBAO_HOME_CHANNEL_NAME in your environment, not in the chat.
Use the /sethome command in any Yuanbao chat (DM or group) to designate it as the home channel. Scheduled tasks (cron jobs) deliver their results to this channel.
You can also set it manually in ~/.hermes/.env:
YUANBAO_HOME_CHANNEL=direct:user_account_id
# or for a group:
# YUANBAO_HOME_CHANNEL=group:group_code
YUANBAO_HOME_CHANNEL_NAME="My Bot Updates"Example: Set Home Channel
- Start a conversation with the bot in Yuanbao
- Send the command:
/sethome - The bot responds: "Home channel set to [chat_name] with ID [chat_id]. Cron jobs will deliver to this location."
- Future cron jobs and notifications will be sent to this channel
Example: Cron Job Delivery
Create a cron job:
/cron "0 9 * * *" Check server statusThe scheduled output will be delivered to your Yuanbao home channel every day at 9 AM.
Usage Tips
A lookup table. Do not read it all; find the row that applies to you.
Starting a Conversation
Send any message to the bot in Yuanbao:
helloThe bot responds in the same conversation thread.
Available Commands
All standard Hermes commands work on Yuanbao:
| Command | Description |
|---|---|
/new | Start a fresh conversation |
/model [provider:model] | Show or change the model |
/sethome | Set this chat as the home channel |
/status | Show session info |
/help | Show available commands |
Sending Files
To send a file to the bot, simply attach it directly in the Yuanbao chat. The bot will automatically download and process the file attachment.
You can also include a message with the attachment:
Please analyze this documentReceiving Files
When you ask the bot to create or export a file, it sends the file directly to your Yuanbao chat.
Troubleshooting
A troubleshooting section. Find the symptom that matches yours rather than reading it end to end.
Bot is online but not responding to messages
Cause: Authentication failed during WebSocket handshake.
Fix:
- Verify APP_ID and APP_SECRET are correct
- Check that the WebSocket URL is accessible
- Ensure the bot account has proper permissions
- Review gateway logs:
tail -f ~/.hermes/logs/gateway.log
"Connection refused" error
Cause: WebSocket URL is unreachable or incorrect.
Fix:
- Verify the WebSocket URL format (should start with
wss://) - Check network connectivity to the Yuanbao API domain
- Confirm firewall allows WebSocket connections
- Test URL with:
curl -I https://[YUANBAO_API_DOMAIN]
Media uploads fail
Cause: COS credentials are invalid or media server is unreachable.
Fix:
- Verify API_DOMAIN is correct
- Check that media upload permissions are enabled for your bot
- Ensure the media file is accessible and not corrupted
- Check COS bucket configuration with platform admin
Messages not delivered to home channel
Cause: Home channel ID format is incorrect or cron job hasn't triggered.
Fix:
- Verify YUANBAO_HOME_CHANNEL is in correct format
- Test with
/sethomecommand to auto-detect correct format - Check cron job schedule with
/status - Verify bot has send permissions in the target chat
Frequent disconnections
Cause: WebSocket connection is unstable or network is unreliable.
Fix:
- Check gateway logs for error patterns
- Increase heartbeat timeout in connection settings
- Ensure stable network connection to Yuanbao API
- Consider enabling verbose logging:
hermes gateway run -vv
Access Control
Settings you configure once. Change one at a time so you can see what each does. Set YUANBAO_DM_POLICY, YUANBAO_DM_ALLOW_FROM in your environment, not in the chat.
Yuanbao supports fine-grained access control for both DM and group conversations:
# DM policy: open (default) | allowlist | disabled
YUANBAO_DM_POLICY=open
# Comma-separated user IDs allowed to DM the bot (only used when DM_POLICY=allowlist)
YUANBAO_DM_ALLOW_FROM=user_id_1,user_id_2
# Group policy: open (default) | allowlist | disabled
YUANBAO_GROUP_POLICY=open
# Comma-separated group codes allowed (only used when GROUP_POLICY=allowlist)
YUANBAO_GROUP_ALLOW_FROM=group_code_1,group_code_2These can also be set in config.yaml:
platforms:
yuanbao:
extra:
dm_policy: allowlist
dm_allow_from: "user1,user2"
group_policy: open
group_allow_from: ""Advanced Configuration
A lookup table. Do not read it all; find the row that applies to you. Commands here: hermes gateway run.
Message Chunking
Yuanbao has a maximum message size. Hermes automatically chunks large responses with Markdown-aware splitting (respects code fences, tables, and paragraph boundaries).
Connection Parameters
The following connection parameters are built into the adapter with sensible defaults:
| Parameter | Default Value | Description |
|---|---|---|
| WebSocket connect timeout | 15 seconds | Time to wait for WS handshake |
| Heartbeat interval | 30 seconds | Ping frequency to keep connection alive |
| Max reconnect attempts | 100 | Maximum number of reconnection tries |
| Reconnect backoff | 1s → 60s (exponential) | Wait time between reconnect attempts |
| Reply heartbeat interval | 2 seconds | RUNNING status send frequency |
| Send timeout | 30 seconds | Timeout for outbound WS messages |
Verbose Logging
Enable debug logging to troubleshoot connection issues:
hermes gateway run -vvIntegration with Other Features
Commands you type in a terminal. Understand what one does before copying it. Commands here: hermes chat.
Cron Jobs
Schedule tasks that run on Yuanbao:
/cron "0 */4 * * *" Report system healthResults are delivered to your home channel.
Background Tasks
Run long operations without blocking the conversation:
/background Analyze all files in the archiveCross-Platform Messages
Send a message from CLI to Yuanbao:
hermes chat -q "Send 'Hello from CLI' to yuanbao:group:group_code"4 questions answered by this page alone.
Every option is a real identifier from the Hermes documentation. The wrong ones are real too, just from other pages.