الأكاديمية ← قنوات المراسلةتوثيق رسمي · إرشاد عربي

قناة Yuanbao

Yuanbao

متوسط إلى متقدم8 دقائق قراءةالدرس 234 أسئلة✓ 2026-08-18
قبل أن تقرأ

ما هذه الصفحة، وماذا تحتوي.

بوابة المراسلة: الوصلة التي تجعلك تكلّم Hermes من تطبيق تستعمله أصلًا، مثل Telegram أو WhatsApp، بدل الطرفية. الوكيل الذي تصله من هاتفك تستعمله فعلًا. الذي يحتاج فتح الحاسوب تنساه بعد أسبوع. ستستعمل هنا hermes chat وhermes gateway، والقراءة نحو 8 دقائق. انتبه: افتح القناة لنفسك فقط في البداية عبر قائمة سماح. القناة المفتوحة تعني أن أي شخص يراسل وكيلك.

11أقسام
14أمثلة برمجية
3جداول
4أوامر
1,312كلمة من المصدر
الوصف الرسمي في سطر

Connect Hermes Agent to the Yuanbao enterprise messaging platform via WebSocket gateway

ماذا ستستطيع بعدها

نتائج مأخوذة من هذه الصفحة، لا من قالب.

  • تعرف ما بوابة المراسلة ولماذا قد تحتاجه.
  • تنفّذ hermes chat وhermes gateway وتفهم ما يحدث بعدها.
  • تقرأ الجدول وتأخذ منه السطر الذي يخصّك فقط.
  • تضبط YUANBAO_APP_ID في المكان الصحيح.
ما ستقابله من أسماء

كما تظهر تمامًا داخل Hermes.

الأوامر
  • hermes chat
  • hermes gateway
  • hermes gateway run
  • hermes gateway setup
متغيرات البيئة
  • YUANBAO_APP_ID
  • YUANBAO_APP_SECRET
  • YUANBAO_WS_URL
  • YUANBAO_API_DOMAIN
  • YUANBAO_BOT_ID
  • YUANBAO_ROUTE_ENV
  • YUANBAO_HOME_CHANNEL
  • YUANBAO_HOME_CHANNEL_NAME
خريطة الصفحة

انتقل مباشرة إلى ما تحتاجه.

  1. 01Prerequisites
  2. 02Setup
  3. 03Features
  4. 04Configuration Options
  5. 05Home Channel
  6. 06Usage Tips
  7. 07Troubleshooting
  8. 08Access Control
  9. 09Advanced Configuration
  10. 10Integration with Other Features
  11. 11Related Documentation
الصفحة الرسمية كاملة

بلا اختصار أو حذف.

النص أدناه منقول من المصدر الرسمي بالإنجليزية حتى تبقى الأوامر والأسماء دقيقة كما هي. قبل كل قسم شرح عربي يوضّح ما بداخله.

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

شرح للفكرة نفسها. اقرأه ببطء، فبقية الأقسام تبني عليه. تذكير: الوصلة التي تجعلك تكلّم Hermes من تطبيق تستعمله أصلًا، مثل Telegram أو WhatsApp، بدل الطرفية.

  • A Yuanbao account with bot creation permissions
  • Yuanbao APP_ID and APP_SECRET (from platform admin)
  • Python packages: websockets and httpx
  • For media support: aiofiles

Install the required dependencies:

Shellسطر واحد
pip install websockets httpx aiofiles

Setup

خطوات عملية بالترتيب. نفّذ خطوة وتأكد أنها نجحت قبل الانتقال للتالية. الأوامر هنا: hermes gateway، hermes gateway setup.

1. Create a Bot in Yuanbao

  1. Download the Yuanbao app from https://yuanbao.tencent.com/ ↗
  2. In the app, go to PAI → My Bot and create a new bot
  3. 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:

Shellسطر واحد
hermes gateway setup

Select Yuanbao when prompted. The wizard will:

  1. Ask for your APP_ID
  2. Ask for your APP_SECRET
  3. Save the configuration automatically

3. Configure Environment Variables

After initial setup, verify these variables in ~/.hermes/.env:

Shell18 سطرًا
# 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_2

4. Start the Gateway

Shellسطر واحد
hermes gateway

The adapter will connect to the Yuanbao WebSocket gateway, authenticate using HMAC signatures, and begin processing messages.

Features

شرح للفكرة نفسها. اقرأه ببطء، فبقية الأقسام تبني عليه.

  • 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

شرح للفكرة نفسها. اقرأه ببطء، فبقية الأقسام تبني عليه.

Chat ID Formats

Yuanbao uses prefixed identifiers depending on conversation type:

Chat TypeFormatExample
Direct message (C2C)direct:<account>direct:user123
Group messagegroup:<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

إعدادات تضبطها مرة وتنساها. غيّر واحدًا في كل مرة حتى تعرف أثر كل تغيير. تضبط YUANBAO_HOME_CHANNEL، YUANBAO_HOME_CHANNEL_NAME خارج المحادثة، في بيئة التشغيل.

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:

Shell4 أسطر
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

  1. Start a conversation with the bot in Yuanbao
  2. Send the command: /sethome
  3. The bot responds: "Home channel set to [chat_name] with ID [chat_id]. Cron jobs will deliver to this location."
  4. Future cron jobs and notifications will be sent to this channel

Example: Cron Job Delivery

Create a cron job:

Shellسطر واحد
/cron "0 9 * * *" Check server status

The scheduled output will be delivered to your Yuanbao home channel every day at 9 AM.

Usage Tips

جدول مرجعي. لا تقرأه كله، ابحث عن السطر الذي يخصّك فقط.

Starting a Conversation

Send any message to the bot in Yuanbao:

Textسطر واحد
hello

The bot responds in the same conversation thread.

Available Commands

All standard Hermes commands work on Yuanbao:

CommandDescription
/newStart a fresh conversation
/model [provider:model]Show or change the model
/sethomeSet this chat as the home channel
/statusShow session info
/helpShow 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:

Textسطر واحد
Please analyze this document

Receiving Files

When you ask the bot to create or export a file, it sends the file directly to your Yuanbao chat.

Troubleshooting

قسم لحل المشكلات. ابحث فيه عن العطل الذي يشبه حالتك بدل قراءته كاملًا.

Bot is online but not responding to messages

Cause: Authentication failed during WebSocket handshake.

Fix:

  1. Verify APP_ID and APP_SECRET are correct
  2. Check that the WebSocket URL is accessible
  3. Ensure the bot account has proper permissions
  4. Review gateway logs: tail -f ~/.hermes/logs/gateway.log

"Connection refused" error

Cause: WebSocket URL is unreachable or incorrect.

Fix:

  1. Verify the WebSocket URL format (should start with wss://)
  2. Check network connectivity to the Yuanbao API domain
  3. Confirm firewall allows WebSocket connections
  4. Test URL with: curl -I https://[YUANBAO_API_DOMAIN]

Media uploads fail

Cause: COS credentials are invalid or media server is unreachable.

Fix:

  1. Verify API_DOMAIN is correct
  2. Check that media upload permissions are enabled for your bot
  3. Ensure the media file is accessible and not corrupted
  4. 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:

  1. Verify YUANBAO_HOME_CHANNEL is in correct format
  2. Test with /sethome command to auto-detect correct format
  3. Check cron job schedule with /status
  4. Verify bot has send permissions in the target chat

Frequent disconnections

Cause: WebSocket connection is unstable or network is unreliable.

Fix:

  1. Check gateway logs for error patterns
  2. Increase heartbeat timeout in connection settings
  3. Ensure stable network connection to Yuanbao API
  4. Consider enabling verbose logging: hermes gateway run -vv

Access Control

إعدادات تضبطها مرة وتنساها. غيّر واحدًا في كل مرة حتى تعرف أثر كل تغيير. تضبط YUANBAO_DM_POLICY، YUANBAO_DM_ALLOW_FROM خارج المحادثة، في بيئة التشغيل.

Yuanbao supports fine-grained access control for both DM and group conversations:

Shell9 أسطر
# 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_2

These can also be set in config.yaml:

YAML7 أسطر
platforms:
  yuanbao:
    extra:
      dm_policy: allowlist
      dm_allow_from: "user1,user2"
      group_policy: open
      group_allow_from: ""

Advanced Configuration

جدول مرجعي. لا تقرأه كله، ابحث عن السطر الذي يخصّك فقط. الأوامر هنا: 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:

ParameterDefault ValueDescription
WebSocket connect timeout15 secondsTime to wait for WS handshake
Heartbeat interval30 secondsPing frequency to keep connection alive
Max reconnect attempts100Maximum number of reconnection tries
Reconnect backoff1s → 60s (exponential)Wait time between reconnect attempts
Reply heartbeat interval2 secondsRUNNING status send frequency
Send timeout30 secondsTimeout for outbound WS messages

Verbose Logging

Enable debug logging to troubleshoot connection issues:

Shellسطر واحد
hermes gateway run -vv

Integration with Other Features

أوامر تكتبها في الطرفية. افهم ما يفعله الأمر قبل نسخه. الأوامر هنا: hermes chat.

Cron Jobs

Schedule tasks that run on Yuanbao:

Textسطر واحد
/cron "0 */4 * * *" Report system health

Results are delivered to your home channel.

Background Tasks

Run long operations without blocking the conversation:

Textسطر واحد
/background Analyze all files in the archive

Cross-Platform Messages

Send a message from CLI to Yuanbao:

Shellسطر واحد
hermes chat -q "Send 'Hello from CLI' to yuanbao:group:group_code"
اختبار الفهم

4 أسئلة إجاباتها كلها في هذه الصفحة.

كل خيار اسم حقيقي من توثيق Hermes. حتى الخيارات الخاطئة حقيقية، لكنها من صفحات أخرى.

1. في جدول هذا الدرس، ما «Description» المقابل لـ«/status»؟
2. أي متغير بيئة من التالي يظهر فعليًا في هذا الدرس؟
3. أي عنوان من التالي لا يظهر في هذا الدرس؟
4. أي مفتاح إعداد يظهر في أمثلة هذا الدرس؟