JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
docs(channels): 更新频道文档结构,拆分国内频道和国外频道
xiaoxiawang96f42e1d7470
diff --git a/docs/en/Channels.md b/docs/en/Channels.mdindex 3260afaa06..1d0c1a1296 100644--- a/docs/en/Channels.md+++ b/docs/en/Channels.md@@ -13,6 +13,16 @@ A **Channel** is JiuwenSwarm's message ingress layer. As a unified messaging hub| **Identity Mapping** | Establishes unique identifiers for users on each platform and maintains independent conversation contexts || **Security Isolation** | Message flows across channels are isolated from each other; supports whitelists, permission controls, etc. |+### Relationship between Channels, Web Chat, and Agents++These three components form JiuwenSwarm's complete conversation system:++- **Channel**: The message ingress layer that receives and normalizes messages from different platforms. Besides external channels like Feishu and Xiaoyi, **the Web UI itself is also a built-in channel**.+- **Agent**: The message processing engine. All messages from any channel are ultimately processed by an Agent for understanding, reasoning, and response.+- **Web Chat**: A built-in web channel that provides a visual interface for users to interact directly with Agents.++**Data Flow**: User message → Any channel (Feishu/Xiaoyi/Web, etc.) → JiuwenSwarm Gateway → Agent processing → Response → Original channel → User+### IntroductionJiuwenSwarm's **Channels** are the **gateways** through which you converse with different chat platforms. JiuwenSwarm has already achieved seamless integration with **HarmonyOS Xiaoyi**, **Feishu**, and more, with continuous expansion to additional platforms. You can talk to JiuwenSwarm directly through **Feishu**, the **Xiaoyi app on HarmonyOS devices**, and others.@@ -25,728 +35,45 @@ This feature is disabled by default. See the configuration instructions under ea### Configuration Methods-Configure channels in either of two ways:--- **Web UI** (recommended) — In JiuwenSwarm's frontend, click the **Agent** / **Channels** card, then fill in the channel management form.--- **Edit `config.yaml` manually** — Default location is `~/.jiuwenswarm/config.yaml` (created automatically on first `jiuwenswarm-start`). Set the desired channel to `enabled: true` and fill in the credentials; saving triggers an automatic reload without restarting.-------## Channel Setup--### Xiaoyi--[Demo video](../assets/videos/xiaoyi_channel.mp4)--#### 1. Create a Xiaoyi Agent--Create a **JiuwenSwarm-mode** agent on the [Xiaoyi Open Platform](https://developer.huawei.com/consumer/cn/hag/abilityportal/#/) to connect to your JiuwenSwarm service.----Step 1: Create a JiuwenSwarm-mode agent.----Step 2: Create credentials and whitelist--Click to create new credentials and **save the AK and SK**.--------The Xiaoyi Open Platform provides on-device debugging capabilities. By configuring whitelist groups and adding user accounts, you can test the agent on HarmonyOS terminals. After successful addition and publishing, the agent can be used in the Xiaoyi app on the terminal.--------Select the new user group:----Step 3: Publish the agent--Fill in the opening dialogue and click the publish button:----Step 4: Enable push notifications (optional)--Click to enable the trigger, fill in the name and save, then enter the apiID in JiuwenSwarm:----Click variable editing and enable the push_id system variable:----> 💡 **Note**: `api_id` is the API identifier of the trigger, and `push_id` is the identifier for receiving push messages. When enabling push notifications, both must be used together — neither can be omitted.--#### 2. Bind the Channel--**Option A: Web UI**--Paste the **AK**, **SK**, and **agentId** from the Xiaoyi Open Platform into JiuwenSwarm's Xiaoyi channel, enable it, and save to start chatting. If push is enabled, you can also fill in the api_id (optional):----**Option B: Edit config file**--Edit `~/.jiuwenswarm/config/config.yaml`:--``````-channels:- xiaoyi:- # Huawei Xiaoyi A2A configuration- mode: xiaoyi_channel- ak: "<ak from platform>"- sk: "<sk from platform>"- agent_id: "<your agent id>"- api_id: "<trigger apiId>"- push_id: "<trigger push_id (required when push notifications are enabled, used together with api_id)>"- uid: "" # User identifier (optional)- api_key: "" # API key (optional)- push_url: "" # Push URL (optional)- file_upload_url: "" # File upload URL (optional)- phone_tools_enabled: false # Enable phone tools (optional)- send_file_allowed: true # Allow sending files (optional)- enable_streaming: true- enabled: true-``````--If the service is already running it will auto-reload; otherwise run `jiuwenswarm-start`.--#### 3. Chat with the Agent--**Option 1:** Chat directly on the web with the agent application----**Option 2:** On a HarmonyOS terminal, open the Xiaoyi app, find the published agent, and chat directly------### Feishu (Lark)--#### 1. Create a Feishu Custom App--1. Visit [Feishu Open Platform](https://open.feishu.cn/) and sign in.--2. In the developer console, click **Create custom app**.--3. Fill in the app name, description, and upload an icon, then click **Create**.-- --#### 2. Add Bot Capability--1. In the app configuration page, select **Add capability** from the left sidebar.--2. Under **Bot**, click **Add**.-- --#### 3. Save App Credentials--1. Open the Feishu bot admin console.--2. Copy **App ID** and **App Secret** into JiuwenSwarm's Feishu channel, enable, and save.-- -- --#### 4. Configure Permissions--1. Select **Permission management** → **API permissions** from the left sidebar.--2. Search and enable the following key permissions (for sending and receiving messages):- - `im:message:send`: Send messages as the app- - `im:message.p2p_msg:readonly`: Get private messages sent to the bot- - `im:message.group_at_msg:readonly`: Receive group chat @bot message events- - `im:resource:upload`: Upload images and files (for sending images/files to users)- - `contact:user.employee_id:readonly`: Get user ID information- - You can also batch-import permissions; refer to the Feishu Open Platform documentation for the permission list----#### 5. Configure Event Subscription (Receive Messages)--1. Select **Events & callbacks** from the left sidebar.--2. **Add events**:- - `im.message.receive_v1` (receive message event)- - `im.message.message_read_v1` (message read)--3. **Add callback**:- - `card.action.trigger` (card interaction callback)--4. (Optional) **Configure encryption policy**: If encryption is enabled, save the **Encrypt Key**.----#### 6. Publish the App--1. Select **Version management & release** from the left sidebar, click **Create version**.--2. Fill in the version number, update notes, and select the availability scope (typically **All members** or partial members).--3. Submit for review. If the enterprise has review exemption enabled, the version goes live immediately.--4. Sign in to the Feishu app with the account that submitted the app to see the published chat bot.----#### 7. Add Bot to a Group (Optional)--1. Open the Feishu client and enter the group where you want to add the bot.--2. Click **Group settings** → **Group bots** → **Add bot**, search for your app name and add it.----#### 8. Configure Feishu Channel--After starting the frontend service, open **Channels → Feishu**, enable it, and configure the **App ID** and **App Secret** saved in step 3.--#### 9. Enable Group Digital Avatar (Optional)--After completing the basic Feishu bot setup, you can enable the digital avatar feature so the bot automatically replies in group chats on behalf of a designated user.--> In Feishu, the digital avatar responds when someone **@mentions the bot**, **@mentions the represented user**, or **mentions the user's name** in the message text.--##### Prerequisites--- Feishu bot has been created, published, and added to the target group (see step 7)--##### Configuration Steps--1. In the JiuwenSwarm channel management page, open the Feishu channel settings and enable the **`group_digital_avatar`** toggle. Configure **`my_user_id`** and **`bot_name`**.-- --2. Set **`my_user_id`** (required): the Feishu `open_id` of the user this avatar represents. To obtain it:- - Sign in to the Feishu API Explorer, open the [Send Message API](https://open.feishu.cn/document/server-docs/im-v1/message/create)- - Set `receive_id_type` to **open_id**- - Click **Quick copy open_id**, select the target user — the copied value is `my_user_id`-- -- --3. Set **`bot_name`**: the bot's display name in the group, used for @mention detection.--4. (Optional) Enable **`enable_memory`** to let the bot read and search local memory files in group chats.--5. **Configure tool / path permissions**: the digital avatar operates autonomously in group chats and cannot prompt the user for confirmation like in DMs. You must pre-configure which tools are allowed and which paths are accessible. After enabling the avatar, open the permission settings and set each tool's permission (`allow` / `deny`). Without explicit configuration, any operation that would require confirmation (`ask`) is automatically downgraded to `deny`.-- --You can also configure via `~/.jiuwenswarm/config/config.yaml`:--``````-channels:- feishu:- app_id: "your App ID"- app_secret: "your App Secret"- enabled: true- # Group digital avatar configuration- group_digital_avatar: true- my_user_id: "ou_xxxx" # Feishu open_id of the represented user- bot_name: "bot name" # Bot display name in the group- enable_memory: false # Enable group chat memory--# Digital avatar tool permissions (scoped by channel_id + user_id)-permissions:- owner_scopes:- # channel_id: use "feishu" for single bot, "feishu_enterprise:<app_id>" for multi-bot- feishu:- "ou_xxxx": # Must match my_user_id above- defaults:- "*": "allow" # Global default: allow / deny- tools:- bash:- "*": "deny" # Deny bash by default- patterns:- "git status *": "allow"- "git log *": "allow"- write:- "*": "deny"- deny_guidance_message: "This tool is not authorized in digital avatar mode."-``````--6\. The Feishu bot needs the following additional permissions:-- - `im:message.group_msg:readonly` - Retrieve all messages in the group (sensitive permission)- - `contact:contact.base:readonly` - Retrieve basic contact information- - `contact:user.base:readonly` - Retrieve basic user information- - `im:message.p2p_msg:readonly` - Retrieve private messages sent to the bot (for receiving DM events)--##### Fields--| Field | Description |-|:------|:------------|-| `group_digital_avatar` | Enable group digital avatar. When on, the bot acts as the designated user's avatar in group chats — it filters irrelevant messages, rewrites relevant ones, and routes personal action replies (to-dos, reminders) as private messages while posting a brief confirmation in the group |-| `my_user_id` | **Required** when avatar is on: the Feishu `open_id` (e.g. `ou_xxx`) of the represented user. Avatar does not work without this |-| `bot_name` | Bot display name in the group, used for @mention detection |-| `enable_memory` | Enable group chat memory. When on, the bot can read and search local memory files in group chats |-| `owner_scopes` | Tool permissions scoped by `channel_id` + `user_id`. Supports `allow` / `deny`; `ask` is automatically downgraded to `deny` in avatar mode. Web UI configuration is recommended |--#### 10. Multiple Feishu Bots (`feishu_enterprise`)--Use `channels.feishu_enterprise` when one JiuwenSwarm instance must serve **multiple Feishu apps** (multiple bots).--Each bot is a separate channel; `channel_id` looks like `feishu_enterprise:<app_id>`.--Currently, multi-bot only supports manual editing of `~/.jiuwenswarm/config/config.yaml`:--``````-channels:- feishu_enterprise:- bot_a:- app_id: "cli_xxx"- app_secret: "xxx"- encrypt_key: ""- verification_token: ""- allow_from: []- enable_streaming: true- chat_id: ""- enabled: true- bot_b:- app_id: "cli_yyy"- app_secret: "yyy"- encrypt_key: ""- verification_token: ""- allow_from: []- enable_streaming: true- chat_id: ""- enabled: true-``````--##### Fields--| Field | Description |-|:------|:------------|-| `app_id` | Feishu App ID (required) |-| `app_secret` | Feishu App Secret (required) |-| `encrypt_key` | Event subscription encryption key (optional) |-| `verification_token` | Event subscription token (optional) |-| `allow_from` | Allowed user `open_id` list; empty list means no restriction |-| `enable_streaming` | Enable streaming output |-| `chat_id` | Fixed push target (optional) |-| `enabled` | Enable this bot |--##### vs Single `feishu`--- `feishu`: single channel, `channel_id` is always `feishu`-- `feishu_enterprise`: multiple channels, each bot uses an independent `channel_id` (`feishu_enterprise:<app_id>`)-- In multi-bot scenarios, recent session information is tracked per bot to prevent bots from overwriting each other----### DingTalk--#### 1. Prerequisites--- Your account must be an **enterprise admin** or have **developer permissions**.-- The enterprise must have **DingTalk Developer Console** enabled.--#### 2. Create an Internal App Bot--##### Step 1: Open the Developer Console--- Visit [https://open-dev.dingtalk.com](https://open-dev.dingtalk.com)-- After logging in, select **App development** → **Internal org apps** → **Create app**--+This tutorial focuses on **Web UI configuration**. Subsequent channel setup instructions are all based on web interface operations.-##### Step 2: Fill in App Information+For manual configuration, edit the `config.yaml` file (default path: `~/.jiuwenswarm/config/config.yaml`), set the corresponding channel to `enabled: true` and fill in the credentials. Changes take effect automatically upon saving.-- App name: e.g. `JiuwenSwarm`-- App type: **Bot**+### Channel Feature Differences-+Different channels have varying capabilities regarding private/group chat support, trigger methods, and permission requirements:-##### Step 3: Add Bot Capability+| Feature | Description |+|---------|-------------|+| **Private/Group Chat** | Some channels only support private chat (e.g., Xiaoyi), while others support both private and group chats (e.g., Feishu, WeCom) |+| **Trigger Methods** | Private chats typically trigger directly via conversation; group chats may require @mentioning the bot or using specific command prefixes |+| **Permission Requirements** | Different platforms have varying permission requirements for bots, such as message read permissions, group management permissions, etc. |-- After creation, open the app details page-- Click **Capabilities** → **Bot** → **Enable bot configuration**-- Fill in the bot name (e.g. `JiuwenSwarm`), bot intro (≤10 characters), etc.+See the detailed setup instructions for each channel for specific differences.---##### Step 4: Configure Message Receiving Mode--Select **Stream mode** (WebSocket long connection) — no public IP required; suitable for cloud functions or local debugging.----#### 3. Configure Permissions--On the **Permission management** page, enable the following permissions as needed:-- Send DM/group messages: `qyapi_robot_sendmsg`-- Lookup user by mobile (for DMs): `topapi_v2_user_getbymobile`-- Send interactive cards: `Card.Instance.Write`-- Streaming card updates (essential for AI scenarios): `Card.Streaming.Write`--#### 4. Publish the App & Bot--##### Step 1: Save and Publish the Bot--- On the bot configuration page, click **Save**-- Return to the app homepage, click **Version management & release** → **Publish**-- Fill in the version number, update log, visibility scope, etc.----##### Step 2: Confirm Publishing--- Click **Confirm publish**-- Status changes to **Published** and the bot is ready to use--> 💡 After publishing, search the bot name in the DingTalk client to add it to group chats or DMs.----#### 5. Configure DingTalk Channel--Copy **Client ID** and **Client Secret** from **Credentials & basic info**.--In JiuwenSwarm, open **Channels → DingTalk**, enable it, and configure **client_id** and **client_secret**, then save:------### WeCom (WeChat Work)--#### 1. Create a Bot in WeCom--1. Open the WeCom client, go to **Workbench** → **Smart bot**, click **Create bot** → **Manual creation**-- -- -- --2. On the creation page, select **API mode**-- --3. On the API configuration page, select **Long connection** as the connection method-- --4. After configuration, the page will automatically generate and display **Bot ID** and **Secret** — save these securely (needed for linking with JiuwenSwarm later)--#### 2. Link JiuwenSwarm--1. In JiuwenSwarm, open **Channels** and select **WeCom**.--2. Enter the **botId** and **secret** saved in step 1, then click save.-- -- --#### 3. Chat with the WeCom Bot--> ⚠️ **Note**: If you cannot find the bot after configuration, navigate to: Workbench → Smart bot → Details → Use → Send message.------1. In WeCom, find the newly added bot, send a test message — receiving a reply means the connection is successful.--2. On mobile WeCom, send a test message — receiving a reply means the connection is successful.------#### 4. Enable Group Digital Avatar (Optional)--After completing the basic WeCom bot setup, you can enable the digital avatar feature.--> ⚠️ **Note**: In WeCom, group messages must **@mention the bot** for the bot to receive them. Messages that do not @mention the bot will not trigger the digital avatar.--##### Prerequisites--- WeCom bot has been created and linked to JiuwenSwarm-- Bot has been added to the target group: open WeCom, enter the group, tap add member → **Group bots** → **Smart bot**, and search for your app name--##### Configuration Steps--1. In the JiuwenSwarm channel management page, open the WeCom channel settings and enable the **`group_digital_avatar`** toggle. Configure **`my_user_id`** and **`bot_name`**. Before enabling the digital avatar, you need to have a private chat with the bot once; otherwise, an error `[AiBotSDK] [WARN] Reply ack error` will be reported.-- --2. Set **`my_user_id`** (required): the WeCom account of the user this avatar represents. To obtain it:- - Open the [WeCom Admin Console](https://work.weixin.qq.com/wework_admin/login)- - Go to **Contacts** → **Organization** → **Department** → **Member details**- - The **Account** field shown on the page is the `my_user_id`-- -- --3. Set **`bot_name`** (optional): the bot's display name in the group, used for @mention detection.--4. (Optional) Enable **`enable_memory`** to let the bot read and search local memory files in group chats (memory is not written in group chats).--5. **Configure tool / path permissions**: the digital avatar operates autonomously in group chats and cannot prompt the user for confirmation like in DMs. You must pre-configure which tools are allowed and which paths are accessible. After enabling the avatar, open the permission settings and set each tool's permission (`allow` / `deny`). Without explicit configuration, any operation that would require confirmation (`ask`) is automatically downgraded to `deny`.-- --You can also configure via `~/.jiuwenswarm/config/config.yaml`:--``````-channels:- wecom:- bot_id: "your Bot ID"- secret: "your Secret"- send_file_allowed: true # Allow sending files (optional)- enabled: true- # Group digital avatar configuration- group_digital_avatar: true- my_user_id: "account" # WeCom account of the represented user- bot_name: "bot name" # Bot display name in the group (optional)- enable_memory: false # Enable group chat memory--# Digital avatar tool permissions (scoped by channel_id + user_id)-permissions:- owner_scopes:- wecom:- "account": # Must match my_user_id above- defaults:- "*": "allow" # Global default: allow / deny- tools:- bash:- "*": "deny"- patterns:- "git status *": "allow"- "git log *": "allow"- write:- "*": "deny"- deny_guidance_message: "This tool is not authorized in digital avatar mode."-``````--##### Fields--| Field | Description |-|:------|:------------|-| `group_digital_avatar` | Enable group digital avatar. When on, the bot acts as the designated user's avatar in group chats — it filters irrelevant messages, rewrites relevant ones, and routes personal action replies (to-dos, reminders) as private messages while posting a brief confirmation in the group |-| `my_user_id` | **Required** when avatar is on: the WeCom account of the represented user. Avatar does not work without this |-| `bot_name` | Optional: bot display name in the group, used for @mention detection |-| `enable_memory` | Enable group chat memory. When on, the bot can read and search local memory files in group chats; memory is not written in group chats |-| `owner_scopes` | Tool permissions scoped by `channel_id` + `user_id`. Supports `allow` / `deny`; `ask` is automatically downgraded to `deny` in avatar mode. Web UI configuration is recommended |----### Telegram--#### 1. Create a Telegram Bot--Use [@BotFather](https://t.me/BotFather) to create a bot and get a **Bot Token**.--Step 1: Search for `@BotFather` in Telegram and open the conversation.----Step 2: Send `/newbot` and follow the prompts.--BotFather will ask you to enter:-- **Bot display name** (e.g. `JiuwenSwarm Bot`)-- **Bot username** (must end with `bot`, e.g. `jiuwenswarm_bot`)----Step 3: **Save the Bot Token**--After creation, BotFather returns a token in the format `123456789:ABCDefGhIJKlmN...`. Save it securely — you'll need it for configuration.--> ⚠️ **Note**: The Bot Token is equivalent to the bot's password — do not leak it. If the token is exposed, use `/revoke` in BotFather to regenerate it.--#### 2. Bind the Channel--**Option A: Web UI (recommended)**--In JiuwenSwarm's frontend, click the **Agent** / **Channels** card, fill in the Bot Token in the Telegram channel module, enable it, and save.----**Option B: Edit `config.yaml`**--Edit `~/.jiuwenswarm/config/config.yaml`:--``````-channels:- telegram:- # Bot Token from @BotFather- bot_token: "<your Bot Token>"- # User whitelist (Telegram user_id); empty allows all users- allow_from: []- # Message parse mode: Markdown, HTML, None- parse_mode: Markdown- # Group chat mode: mention, reply, all, off- group_chat_mode: mention- enabled: true-``````--If the service is already running it will auto-reload; otherwise run `jiuwenswarm-start`.--#### 3. Configuration--| Field | Description | Default |-|:------|:------------|:--------|-| `bot_token` | Bot Token from @BotFather (**required**) | empty |-| `allow_from` | Allowed Telegram `user_id` whitelist; empty = all users | `[]` |-| `parse_mode` | Message parse mode: `Markdown`, `HTML`, or `None` (plain text) | `Markdown` |-| `group_chat_mode` | Group chat response mode (see details below) | `mention` |-| `enabled` | Enable Telegram channel | `false` |--##### Group Chat Modes--When the bot is added to a Telegram group, `group_chat_mode` controls how the bot responds to group messages:--| Mode | Description |-|:-----|:------------|-| `mention` | **Only respond to @mentions**: only processes messages when the bot is @mentioned (recommended) |-| `reply` | **Only respond to replies**: only processes messages that reply to the bot |-| `all` | **Respond to all messages**: all text messages in the group are processed |-| `off` | **Disable group chat**: no messages are responded to in the group |--#### 4. Start Chatting--**Option 1:** Search for your bot's username in Telegram and send a message to start chatting.----**Option 2:** Add the bot to a group and interact based on the `group_chat_mode` setting.----#### 5. Get `user_id` (Whitelist)--To configure the `allow_from` whitelist, you need to obtain the user's Telegram `user_id`:--1. Search for `@userinfobot` in Telegram and send any message to get your `user_id`.--2. Add the obtained `user_id` to the `allow_from` list:--``````-channels:- telegram:- bot_token: "<your Bot Token>"- allow_from:- - "123456789" # User A's user_id- - "987654321" # User B's user_id- enabled: true-``````--> 💡 **Tip**: When `allow_from` is an empty list, all users can use the bot. After setting a whitelist, only users in the list can chat with the bot.----### Discord--Discord channel integration is supported in the current version. Configure and enable the Discord Bot in **Channel Management**, or manually edit `config.yaml`.--### For step-by-step instructions (Developer Portal bot creation, intents, install link, channel management), see [Discord.md](Discord.md).--Configuration fields:-- `bot_token`-- `application_id`-- `guild_id`-- `channel_id`-- `block_dm`-- `allow_from`-- `enabled`--Configure in `~/.jiuwenswarm/config/config.yaml` as follows:--``````-channels:- discord:- bot_token: "Discord Bot Token"- application_id: "Application ID"- guild_id: "Target server Guild ID"- channel_id: "Target channel Channel ID"- block_dm: false- allow_from: []- enabled: true-``````--#### Quick Start Guide--1. Create a Bot in the Discord Developer Portal and get the `bot_token`-2. On the Bot tab, enable **Message Content Intent**-3. Invite the bot to the target server and grant read/write channel permissions-4. Fill in the configuration in JiuwenSwarm and enable `enabled: true`--#### Fields--| Field | Description | Default |-|:------|:------------|:--------|-| `bot_token` | Discord Bot Token (required) | empty |-| `application_id` | Application ID (optional, recommended) | empty |-| `guild_id` | Listen only to the specified server (optional; empty = no restriction) | empty |-| `channel_id` | Listen/reply only to the specified channel (optional; empty = reply based on message context) | empty |-| `block_dm` | When `true`, DMs are not processed | `false` |-| `allow_from` | Allowed Discord user ID list; empty list means all users are allowed | `[]` |-| `enabled` | Enable Discord channel | `false` |----### Personal WeChat--#### 1. Prerequisites--- You are an **Android** or **iOS** user-- You are a **HarmonyOS** user and don't mind using **Zhuoyitong**-- Due to current Personal WeChat limitations, scheduled tasks cannot be sent after a long period of inactivity in Personal WeChat. It is recommended to use other channels for scheduled tasks.--> 💡 **Tip**: After a user sends a message to ClawBot, the app can send up to **10** independent messages to that user (including the reply message). If the user sends another message to ClawBot, the quota resets to 10.--#### 2. Android or iOS Setup--##### Step 1: Upgrade WeChat Version--In WeChat, go to **Me** → **Settings** → **About WeChat** → **Version Update**:-- iOS: upgrade to the latest version-- Android: upgrade to the latest version----##### Step 2: Scan QR Code to Connect--- Open the latest version of JiuwenSwarm frontend, click **Channels** → **WeChat**, enable the WeChat configuration and save. A **QR code** will appear on the page.--+----- Open WeChat on your phone, tap the **+** in the top right → **Scan**, scan the QR code generated in the previous step, and follow the prompts to complete the connection.+## Channel Setup-#### 3. HarmonyOS Setup+JiuwenSwarm supports integration with multiple chat platforms, divided into the following categories based on region:-Since the HarmonyOS WeChat version does not yet support the **ClawBot** feature, **native HarmonyOS WeChat cannot currently be connected**. However, users can connect through **Zhuoyitong** by following these steps:+### China Channels-##### Step 1: Install WeChat Dual Account+| Channel | Description |+|---------|-------------|+| [Xiaoyi](ChinaChannels.md#xiaoyi) | Huawei HarmonyOS intelligent assistant, private chat only |+| [Feishu](ChinaChannels.md#feishu-lark) | Enterprise collaboration platform, supports private and group chat, with Digital Avatar feature |+| [DingTalk](ChinaChannels.md#dingtalk) | Enterprise collaboration platform, supports private and group chat |+| [WeCom](ChinaChannels.md#wecom-wechat-work) | Enterprise messaging tool, supports private and group chat, with Digital Avatar feature |+| [Personal WeChat](ChinaChannels.md#personal-wechat) | Personal messaging tool, private chat only |-- Download **WeChat Dual Account** through **Zhuoyitong** and log in to WeChat again.+For detailed configuration instructions, see: [China Channels](ChinaChannels.md)-+### International Channels-##### Step 2: Upgrade & Connect+| Channel | Description |+|---------|-------------|+| [Telegram](InternationalChannels.md#telegram) | International messaging tool, supports private and group chat |+| [Discord](InternationalChannels.md#discord) | Gaming community platform, supports private and group chat |-- Follow the same upgrade and connection steps as in **Android / iOS Setup**.+For detailed configuration instructions, see: [International Channels](InternationalChannels.md)\ No newline at end of filediff --git a/docs/en/ChinaChannels.md b/docs/en/ChinaChannels.mdnew file mode 100644index 0000000000..48d8b1a5f7--- /dev/null+++ b/docs/en/ChinaChannels.md@@ -0,0 +1,540 @@+# China Channels++JiuwenSwarm supports integration with multiple Chinese chat platforms. Below are detailed configuration instructions for each channel.++## Xiaoyi++[Demo video](../assets/videos/xiaoyi_channel.mp4)++### 1. Create a Xiaoyi Agent++Create a **JiuwenSwarm-mode** agent on the [Xiaoyi Open Platform](https://developer.huawei.com/consumer/cn/hag/abilityportal/#/) to connect to your JiuwenSwarm service.++++#### Step 1: Create a JiuwenSwarm-mode agent.++++#### Step 2: Create credentials and whitelist++Click to create new credentials and **save the AK and SK**.++++++++The Xiaoyi Open Platform provides on-device debugging capabilities. By configuring whitelist groups and adding user accounts, you can test the agent on HarmonyOS terminals. After successful addition and publishing, the agent can be used in the Xiaoyi app on the terminal.++++++++Select the new user group:++++#### Step 3: Publish the agent++Fill in the opening dialogue and click the publish button:++++#### Step 4: Enable push notifications (optional)++Click to enable the trigger, fill in the name and save, then enter the apiID in JiuwenSwarm:++++Click variable editing and enable the push_id system variable:++++> 💡 **Note**: `api_id` is the API identifier of the trigger, and `push_id` is the identifier for receiving push messages. When enabling push notifications, both must be used together — neither can be omitted.++### 2. Bind the Channel++#### Option A: Web UI++Paste the **AK**, **SK**, and **agentId** from the Xiaoyi Open Platform into JiuwenSwarm's Xiaoyi channel, enable it, and save to start chatting. If push is enabled, you can also fill in the api_id (optional):++++#### Option B: Edit config file++Edit `~/.jiuwenswarm/config/config.yaml`:++``````yaml+channels:+ xiaoyi:+ mode: xiaoyi_channel+ ak: "<ak from platform>"+ sk: "<sk from platform>"+ agent_id: "<your agent id>"+ api_id: "<trigger apiId>"+ push_id: "<trigger push_id (required when push notifications are enabled)>"+ uid: ""+ api_key: ""+ push_url: ""+ file_upload_url: ""+ phone_tools_enabled: false+ send_file_allowed: true+ enable_streaming: true+ enabled: true+``````++If the service is already running it will auto-reload; otherwise run `jiuwenswarm-start`.++### 3. Chat with the Agent++**Option 1:** Chat directly on the web with the agent application++++**Option 2:** On a HarmonyOS terminal, open the Xiaoyi app, find the published agent, and chat directly++++---++## Feishu (Lark)++### 1. Create a Feishu Custom App++1. Visit [Feishu Open Platform](https://open.feishu.cn/) and sign in.++2. In the developer console, click **Create custom app**.++3. Fill in the app name, description, and upload an icon, then click **Create**.++ ++### 2. Add Bot Capability++1. In the app configuration page, select **Add capability** from the left sidebar.++2. Under **Bot**, click **Add**.++ ++### 3. Save App Credentials++1. Open the Feishu bot admin console.++2. Copy **App ID** and **App Secret** into JiuwenSwarm's Feishu channel, enable, and save.++ ++ ++### 4. Configure Permissions++1. Select **Permission management** → **API permissions** from the left sidebar.++2. Search and enable the following key permissions (for sending and receiving messages):+ - `im:message:send`: Send messages as the app+ - `im:message.p2p_msg:readonly`: Get private messages sent to the bot+ - `im:message.group_at_msg:readonly`: Receive group chat @bot message events+ - `im:resource:upload`: Upload images and files+ - `contact:user.employee_id:readonly`: Get user ID information++++### 5. Configure Event Subscription (Receive Messages)++1. Select **Events & callbacks** from the left sidebar.++2. **Add events**:+ - `im.message.receive_v1` (receive message event)+ - `im.message.message_read_v1` (message read)++3. **Add callback**:+ - `card.action.trigger` (card interaction callback)++4. (Optional) **Configure encryption policy**: If encryption is enabled, save the **Encrypt Key**.++++### 6. Publish the App++1. Select **Version management & release** from the left sidebar, click **Create version**.++2. Fill in the version number, update notes, and select the availability scope.++3. Submit for review. If the enterprise has review exemption enabled, the version goes live immediately.++4. Sign in to the Feishu app with the account that submitted the app to see the published chat bot.++++### 7. Add Bot to a Group (Optional)++1. Open the Feishu client and enter the group where you want to add the bot.++2. Click **Group settings** → **Group bots** → **Add bot**, search for your app name and add it.++++### 8. Configure Feishu Channel++After starting the frontend service, open **Channels → Feishu**, enable it, and configure the **App ID** and **App Secret** saved in step 3.++### 9. Enable Group Digital Avatar (Optional)++After completing the basic Feishu bot setup, you can enable the digital avatar feature so the bot automatically replies in group chats on behalf of a designated user.++> In Feishu, the digital avatar responds when someone **@mentions the bot**, **@mentions the represented user**, or **mentions the user's name** in the message text.++#### Prerequisites++- Feishu bot has been created, published, and added to the target group (see step 7)++#### Configuration Steps++1. In the JiuwenSwarm channel management page, open the Feishu channel settings and enable the **`group_digital_avatar`** toggle. Configure **`my_user_id`** and **`bot_name`**.++ ++2. Set **`my_user_id`** (required): the Feishu `open_id` of the user this avatar represents. Obtain it as follows:+ - Log in to the Feishu API Debug Console, go to the [Send Message API](https://open.feishu.cn/document/server-docs/im-v1/message/create)+ - Set `receive_id_type` to **open_id**+ - Click **Quick Copy open_id**, select the target user in the popup, and the obtained open_id is the `my_user_id`++ ++ ++3. Set **`bot_name`**: the bot's display name in the group, used for @mention detection.++4. (Optional) Enable **`enable_memory`** to let the bot read and search local memory files in group chats.++5. **Configure tool / path permissions**: Pre-configure which tools are allowed and which paths are accessible.++ ++You can also configure via `~/.jiuwenswarm/config/config.yaml`:++``````yaml+channels:+ feishu:+ app_id: "your App ID"+ app_secret: "your App Secret"+ enabled: true+ group_digital_avatar: true+ my_user_id: "ou_xxxx"+ bot_name: "bot name"+ enable_memory: false++permissions:+ owner_scopes:+ feishu:+ "ou_xxxx":+ defaults:+ "*": "allow"+ tools:+ bash:+ "*": "deny"+ patterns:+ "git status *": "allow"+ "git log *": "allow"+ write:+ "*": "deny"+ deny_guidance_message: "This tool is not authorized in digital avatar mode."+``````++6\. The Feishu bot needs the following additional permissions:++ - `im:message.group_msg:readonly` - Retrieve all messages in the group+ - `contact:contact.base:readonly` - Retrieve basic contact information+ - `contact:user.base:readonly` - Retrieve basic user information+ - `im:message.p2p_msg:readonly` - Retrieve private messages sent to the bot++#### Fields++| Field | Description |+|:------|:------------|+| `group_digital_avatar` | Enable group digital avatar |+| `my_user_id` | **Required**: Feishu `open_id` of the represented user |+| `bot_name` | Bot display name in the group |+| `enable_memory` | Enable group chat memory |+| `owner_scopes` | Tool permissions scoped by `channel_id` + `user_id` |++### 10. Multiple Feishu Bots (`feishu_enterprise`)++Use `channels.feishu_enterprise` when one JiuwenSwarm instance must serve **multiple Feishu apps**.++Each bot is a separate channel; `channel_id` looks like `feishu_enterprise:<app_id>`.++Configure via `~/.jiuwenswarm/config/config.yaml`:++``````yaml+channels:+ feishu_enterprise:+ bot_a:+ app_id: "cli_xxx"+ app_secret: "xxx"+ encrypt_key: ""+ verification_token: ""+ allow_from: []+ enable_streaming: true+ chat_id: ""+ enabled: true+ bot_b:+ app_id: "cli_yyy"+ app_secret: "yyy"+ encrypt_key: ""+ verification_token: ""+ allow_from: []+ enable_streaming: true+ chat_id: ""+ enabled: true+``````++#### vs Single `feishu`++- `feishu`: single channel, `channel_id` is always `feishu`+- `feishu_enterprise`: multiple channels, each bot uses an independent `channel_id`+- In multi-bot scenarios, recent session information is tracked per bot++---++## DingTalk++### 1. Prerequisites++- Your account must be an **enterprise admin** or have **developer permissions**.+- The enterprise must have **DingTalk Developer Console** enabled.++### 2. Create an Internal App Bot++#### Step 1: Open the Developer Console++- Visit [https://open-dev.dingtalk.com](https://open-dev.dingtalk.com)+- After logging in, select **App development** → **Internal org apps** → **Create app**++++#### Step 2: Fill in App Information++- App name: e.g. `JiuwenSwarm`+- App type: **Bot**++++#### Step 3: Add Bot Capability++- After creation, open the app details page+- Click **Capabilities** → **Bot** → **Enable bot configuration**+- Fill in the bot name and intro++++#### Step 4: Configure Message Receiving Mode++Select **Stream mode** (WebSocket long connection) — no public IP required.++### 3. Configure Permissions++On the **Permission management** page, enable the following permissions as needed:+- Send DM/group messages: `qyapi_robot_sendmsg`+- Lookup user by mobile: `topapi_v2_user_getbymobile`+- Send interactive cards: `Card.Instance.Write`+- Streaming card updates: `Card.Streaming.Write`++### 4. Publish the App & Bot++#### Step 1: Save and Publish the Bot++- On the bot configuration page, click **Save**+- Return to the app homepage, click **Version management & release** → **Publish**+- Fill in the version number, update log, visibility scope, etc.++++#### Step 2: Confirm Publishing++- Click **Confirm publish**+- Status changes to **Published** and the bot is ready to use++> 💡 After publishing, search the bot name in the DingTalk client to add it to group chats or DMs.++### 5. Configure DingTalk Channel++Copy **Client ID** and **Client Secret** from **Credentials & basic info**.++In JiuwenSwarm, open **Channels → DingTalk**, enable it, and configure **client_id** and **client_secret**, then save:++++---++## WeCom (WeChat Work)++### 1. Create a Bot in WeCom++1. Open the WeCom client, go to **Workbench** → **Smart bot**, click **Create bot** → **Manual creation**++ ++ ++ ++2. On the creation page, select **API mode**++ ++3. On the API configuration page, select **Long connection** as the connection method++ ++4. After configuration, the page will automatically generate and display **Bot ID** and **Secret** — save these securely++### 2. Link JiuwenSwarm++1. In JiuwenSwarm, open **Channels** and select **WeCom**.++2. Enter the **botId** and **secret** saved in step 1, then click save.++ ++ ++### 3. Chat with the WeCom Bot++> ⚠️ **Note**: If you cannot find the bot after configuration, navigate to: Workbench → Smart bot → Details → Use → Send message.++++++1. In WeCom, find the newly added bot, send a test message — receiving a reply means the connection is successful.++2. On mobile WeCom, send a test message — receiving a reply means the connection is successful.++++++### 4. Enable Group Digital Avatar (Optional)++After completing the basic WeCom bot setup, you can enable the digital avatar feature.++> ⚠️ **Note**: In WeCom, group messages must **@mention the bot** for the bot to receive them.++#### Prerequisites++- WeCom bot has been created and linked to JiuwenSwarm+- Bot has been added to the target group++#### Configuration Steps++1. In the JiuwenSwarm channel management page, open the WeCom channel settings and enable the **`group_digital_avatar`** toggle. Before enabling the digital avatar, you need to have a private chat with the bot once; otherwise, an error `[AiBotSDK] [WARN] Reply ack error` will be reported.++ ++2. Set **`my_user_id`** (required): the WeCom account of the user this avatar represents. Obtain it as follows:+ - Open the [WeCom Admin Console](https://work.weixin.qq.com/wework_admin/login)+ - Go to **Contacts** → **Organization** → **Department** → **Member details**+ - The **Account** field shown on the page is the `my_user_id`++ ++ ++3. Set **`bot_name`** (optional): the bot's display name in the group.++4. (Optional) Enable **`enable_memory`** to let the bot read and search local memory files in group chats.++5. **Configure tool / path permissions**: Pre-configure which tools are allowed.++ ++You can also configure via `~/.jiuwenswarm/config/config.yaml`:++``````yaml+channels:+ wecom:+ bot_id: "your Bot ID"+ secret: "your Secret"+ send_file_allowed: true+ enabled: true+ group_digital_avatar: true+ my_user_id: "account"+ bot_name: "bot name"+ enable_memory: false++permissions:+ owner_scopes:+ wecom:+ "account":+ defaults:+ "*": "allow"+ tools:+ bash:+ "*": "deny"+ patterns:+ "git status *": "allow"+ "git log *": "allow"+ write:+ "*": "deny"+ deny_guidance_message: "This tool is not authorized in digital avatar mode."+``````++#### Fields++| Field | Description |+|:------|:------------|+| `group_digital_avatar` | Enable group digital avatar |+| `my_user_id` | **Required**: WeCom account of the represented user |+| `bot_name` | Optional: bot display name in the group |+| `enable_memory` | Enable group chat memory |+| `owner_scopes` | Tool permissions scoped by `channel_id` + `user_id` |++---++## Personal WeChat++### 1. Prerequisites++- You are an **Android** or **iOS** user+- You are a **HarmonyOS** user and don't mind using **Zhuoyitong**+- Due to current Personal WeChat limitations, scheduled tasks cannot be sent after a long period of inactivity++> 💡 **Tip**: After a user sends a message to ClawBot, the app can send up to **10** independent messages.++### 2. Android or iOS Setup++#### Step 1: Upgrade WeChat Version++In WeChat, go to **Me** → **Settings** → **About WeChat** → **Version Update**:+- iOS: upgrade to the latest version+- Android: upgrade to the latest version++++#### Step 2: Scan QR Code to Connect++- Open the latest version of JiuwenSwarm frontend, click **Channels** → **WeChat**, enable the WeChat configuration and save. A **QR code** will appear.++++- Open WeChat on your phone, tap the **+** → **Scan**, scan the QR code to complete the connection.++### 3. HarmonyOS Setup++Since the HarmonyOS WeChat version does not yet support the **ClawBot** feature, you can connect through **Zhuoyitong**:++#### Step 1: Install WeChat Dual Account++- Download **WeChat Dual Account** through **Zhuoyitong** and log in to WeChat again.++++#### Step 2: Upgrade & Connect++- Follow the same upgrade and connection steps as in **Android / iOS Setup**.\ No newline at end of filediff --git a/docs/en/InternationalChannels.md b/docs/en/InternationalChannels.mdnew file mode 100644index 0000000000..21ecdfee48--- /dev/null+++ b/docs/en/InternationalChannels.md@@ -0,0 +1,153 @@+# International Channels++JiuwenSwarm supports integration with multiple international chat platforms. Below are detailed configuration instructions for each channel.++## Telegram++### 1. Create a Telegram Bot++Use [@BotFather](https://t.me/BotFather) to create a bot and get a **Bot Token**.++**Step 1:** Search for `@BotFather` in Telegram and open the conversation.++++**Step 2:** Send `/newbot` and follow the prompts.++BotFather will ask you to enter:+- **Bot display name** (e.g. `JiuwenSwarm Bot`)+- **Bot username** (must end with `bot`, e.g. `jiuwenswarm_bot`)++++**Step 3:** **Save the Bot Token**++After creation, BotFather returns a token in the format `123456789:ABCDefGhIJKlmN...`. Save it securely — you'll need it for configuration.++> ⚠️ **Note**: The Bot Token is equivalent to the bot's password — do not leak it. If the token is exposed, use `/revoke` in BotFather to regenerate it.++### 2. Bind the Channel++#### Option A: Web UI (recommended)++In JiuwenSwarm's frontend, click the **Agent** / **Channels** card, fill in the Bot Token in the Telegram channel module, enable it, and save.++++#### Option B: Edit `config.yaml`++Edit `~/.jiuwenswarm/config/config.yaml`:++``````yaml+channels:+ telegram:+ bot_token: "<your Bot Token>"+ allow_from: []+ parse_mode: Markdown+ group_chat_mode: mention+ enabled: true+``````++If the service is already running it will auto-reload; otherwise run `jiuwenswarm-start`.++### 3. Configuration++| Field | Description | Default |+|:------|:------------|:--------|+| `bot_token` | Bot Token from @BotFather (**required**) | empty |+| `allow_from` | Allowed Telegram `user_id` whitelist; empty = all users | `[]` |+| `parse_mode` | Message parse mode: `Markdown`, `HTML`, or `None` | `Markdown` |+| `group_chat_mode` | Group chat response mode | `mention` |+| `enabled` | Enable Telegram channel | `false` |++#### Group Chat Modes++When the bot is added to a Telegram group, `group_chat_mode` controls how the bot responds:++| Mode | Description |+|:-----|:------------|+| `mention` | **Only respond to @mentions** (recommended) |+| `reply` | **Only respond to replies** |+| `all` | **Respond to all messages** |+| `off` | **Disable group chat** |++### 4. Start Chatting++**Option 1:** Search for your bot's username in Telegram and send a message to start chatting.++++**Option 2:** Add the bot to a group and interact based on the `group_chat_mode` setting.++++### 5. Get `user_id` (Whitelist)++To configure the `allow_from` whitelist, you need to obtain the user's Telegram `user_id`:++1. Search for `@userinfobot` in Telegram and send any message to get your `user_id`.++2. Add the obtained `user_id` to the `allow_from` list:++``````yaml+channels:+ telegram:+ bot_token: "<your Bot Token>"+ allow_from:+ - "123456789"+ - "987654321"+ enabled: true+``````++> 💡 **Tip**: When `allow_from` is an empty list, all users can use the bot. After setting a whitelist, only users in the list can chat with the bot.++---++## Discord++Discord channel integration is supported in the current version. Configure and enable the Discord Bot in **Channel Management**, or manually edit `config.yaml`.++For step-by-step instructions (Developer Portal bot creation, intents, install link, channel management), see [Discord.md](Discord.md).++### Configuration fields++- `bot_token`+- `application_id`+- `guild_id`+- `channel_id`+- `block_dm`+- `allow_from`+- `enabled`++Configure in `~/.jiuwenswarm/config/config.yaml` as follows:++``````yaml+channels:+ discord:+ bot_token: "Discord Bot Token"+ application_id: "Application ID"+ guild_id: "Target server Guild ID"+ channel_id: "Target channel Channel ID"+ block_dm: false+ allow_from: []+ enabled: true+``````++### Quick Start Guide++1. Create a Bot in the Discord Developer Portal and get the `bot_token`+2. On the Bot tab, enable **Message Content Intent**+3. Invite the bot to the target server and grant read/write channel permissions+4. Fill in the configuration in JiuwenSwarm and enable `enabled: true`++### Fields++| Field | Description | Default |+|:------|:------------|:--------|+| `bot_token` | Discord Bot Token (required) | empty |+| `application_id` | Application ID (optional, recommended) | empty |+| `guild_id` | Listen only to the specified server | empty |+| `channel_id` | Listen/reply only to the specified channel | empty |+| `block_dm` | When `true`, DMs are not processed | `false` |+| `allow_from` | Allowed Discord user ID list | `[]` |+| `enabled` | Enable Discord channel | `false` |\ No newline at end of filediff --git "a/docs/zh/\345\233\275\345\206\205\351\242\221\351\201\223.md" "b/docs/zh/\345\233\275\345\206\205\351\242\221\351\201\223.md"new file mode 100644index 0000000000..d399d7353a--- /dev/null+++ "b/docs/zh/\345\233\275\345\206\205\351\242\221\351\201\223.md"@@ -0,0 +1,553 @@+# 国内频道++JiuwenSwarm 支持接入多个国内聊天平台,以下是各频道的详细配置说明。++## 小艺++[演示视频](../assets/videos/xiaoyi_channel.mp4)++### 1. 创建小艺智能体++通过在 [小艺开放平台 ](https://developer.huawei.com/consumer/cn/hag/abilityportal/#/)创建 JiuwenSwarm 模式的智能体,即可与 JiuwenSwarm 服务无缝接入。++++#### 第一步:创建 JiuwenSwarm 模式的智能体++++#### 第二步:创建凭证及添加白名单++点击新建凭证,并**保存 ak 与 sk 信息**。++++++++小艺开放平台为开发者提供真机调试能力,通过配置白名单分组,添加用户账号,可以在鸿蒙终端与小艺智能体对话。添加成功并上架成功后,可在终端小艺应用中使用该智能体。++++++++勾选新建的用户组:++++#### 第三步:上架智能体++填写开场白对话,点击上架按钮:++++#### 第四步:启用 push 通知(可选)++点击开启触发器,填写名称后保存,将 apiID 填写至 jiuwenswarm 中:++++点击变量编辑,开通系统变量中的 push_id:++++> 💡 **说明**:`api_id` 是触发器的 API 标识,`push_id` 是用于接收推送消息的标识。启用 push 通知时,两者需配合使用,缺一不可。++### 2. 绑定频道++#### 方式一:网页配置++将小艺开放平台获取到的 **ak、sk、agentId** 信息,填写至 JiuwenSwarm 的小艺频道,开启使用,点击保存即可开启对话。如开启了 push 可以填入 api_id(选填):++++#### 方式二:修改配置文件++编辑 `~/.jiuwenswarm/config/config.yaml`:++``````yaml+channels:+ xiaoyi:+ mode: xiaoyi_channel+ ak: "小艺平台凭证 ak"+ sk: "小艺平台凭证 sk"+ agent_id: "创建的agent ID"+ api_id: "创建的触发器apiId"+ push_id: "触发器的 push_id(与 api_id 配合使用,启用 push 通知时必填)"+ uid: ""+ api_key: ""+ push_url: ""+ file_upload_url: ""+ phone_tools_enabled: false+ send_file_allowed: true+ enable_streaming: true+ enabled: true+``````++保存后若服务已运行会自动重载,未运行可以执行 `jiuwenswarm-start` 启动服务。++### 3. 智能体对话++**方式 1:** 直接在网页与智能体应用对话++++**方式 2:** 在鸿蒙终端小艺应用,找到已上架的应用,直接对话++++---++## 飞书++### 1. 创建飞书自建应用++1. 访问 [飞书开放平台](https://open.feishu.cn/) 并登录。++2. 进入**开发者后台**,点击**创建企业自建应用**。++3. 填写应用名称、描述,并上传图标,点击**创建**。++ ++### 2. 添加机器人能力++1. 在应用配置页面,左侧选择**添加应用能力**。++2. 点击**机器人**下的**添加**按钮。++ ++### 3. 记录机器人应用凭证++1. 进入飞书机器人管理后台++2. 记录 App ID 与 App Secret 配置到 JiuwenSwarm 飞书频道,点击 enabled 并保存生效++ ++ ++### 4. 配置权限++1. 左侧选择**权限管理** -> **API 权限**。++2. 搜索并开通以下关键权限(用于收发消息):+ - `im:message:send`:以应用的身份发送消息+ - `im:message.p2p_msg:readonly`:获取用户发给机器人的单聊消息+ - `im:message.group_at_msg:readonly`:接收群聊中 @ 机器人消息事件+ - `im:resource:upload`:上传图片和文件(用于发送图片/文件给用户)+ - `contact:user.employee_id:readonly`:获取用户 ID 信息++++### 5. 配置事件订阅(接收消息)++1. 左侧选择**事件与回调**++2. **添加事件**:+ - `im.message.receive_v1`(接收消息事件)+ - `im.message.message_read_v1`(消息已读)++3. **添加回调**:+ - `card.action.trigger`(卡片回传交互)++4. (可选)**配置加密策略**:如果启用了加密,需要保存 `Encrypt Key`++++### 6. 发布应用++1. 左侧选择**版本管理与发布**,点击**创建版本**++2. 填写版本号、更新说明,选择可用范围(通常选择**全体成员**或部分成员)++3. 提交审核。如果企业开启了免审,版本会立即生效++4. 飞书 APP 中登录提交应用的账号即可看到发布的聊天机器人++++### 7. 在群聊中添加机器人(可选)++1. 打开飞书客户端,进入需要添加机器人的群组++2. 点击群设置 -> **群机器人** -> **添加机器人**,搜索你创建的应用名称并添加++++### 8. 配置飞书 Channel++启动前端服务后,在「频道-飞书」中打开 Enable 开关并配置第三步记录的 App ID 与 App Secret。++### 9. 开启群聊数字分身(可选)++在完成飞书机器人的基本配置后,可进一步开启数字分身功能,让机器人在群聊中作为指定用户的分身自动回复。++> 飞书中数字分身支持以下触发方式:**@机器人**、**@用户名**(即数字分身对应的用户)、或在消息中**提及用户姓名**,均会触发数字分身回复。++#### 前提条件++- 已完成飞书机器人创建、发布,并已将机器人添加到目标群聊(参考步骤 7)++#### 配置步骤++1. 在 JiuwenSwarm 频道管理页面,进入飞书频道配置,启用 **`group_digital_avatar`** 开关,并配置 **`my_user_id`** 和 **`bot_name`**。++ ++2. 配置 **`my_user_id`**(必填):填入数字分身对应用户的飞书 open_id。获取方式如下:+ - 登录飞书 API 调试台,进入[发送消息接口](https://open.feishu.cn/document/server-docs/im-v1/message/create)+ - 将 `receive_id_type` 选择为 **open_id**+ - 点击**快速复制 open_id**,在弹窗内选择目标用户,获取的 open_id 即为 `my_user_id`++ ++ ++3. 配置 **`bot_name`**:填写机器人在群聊中的显示名称,用于 @ 提及识别++4. (可选)启用 **`enable_memory`** 开关,开启后飞书群聊中可读取及搜索本地记忆文件++5. 配置**工具/路径权限**:数字分身在群聊中自主运行,无法像私聊那样弹窗让用户确认操作,因此需要预先配置允许使用的工具和可访问的路径。在频道管理页面开启数字分身后,进入权限配置界面,按需设置各工具的权限(`allow` 允许 / `deny` 拒绝)。未配置权限时,需要确认的操作(`ask`)会被自动降级为拒绝(`deny`)++ ++也可以通过编辑 `~/.jiuwenswarm/config/config.yaml` 来配置:++``````yaml+channels:+ feishu:+ app_id: "你的 App ID"+ app_secret: "你的 App Secret"+ enabled: true+ group_digital_avatar: true+ my_user_id: "ou_xxxx"+ bot_name: "机器人名称"+ enable_memory: false++permissions:+ owner_scopes:+ feishu:+ "ou_xxxx":+ defaults:+ "*": "allow"+ tools:+ bash:+ "*": "deny"+ patterns:+ "git status *": "allow"+ "git log *": "allow"+ write:+ "*": "deny"+ deny_guidance_message: "该工具未被授权在数字分身模式下使用。"+``````++6\. 飞书机器人需要新增以下权限:++ - `im:message.group_msg:readonly` - 获取群组中所有消息(敏感权限)+ - `contact:contact.base:readonly` - 获取通讯录基本信息+ - `contact:user.base:readonly` - 获取用户基本信息+ - `im:message.p2p_msg:readonly` - 获取用户发给机器人的单聊消息++#### 配置项说明++| 配置项 | 说明 |+|:------|:-----|+| `group_digital_avatar` | 是否启用群聊数字分身功能 |+| `my_user_id` | 开启数字分身时**必填**:数字分身对应用户的飞书 open_id |+| `bot_name` | 机器人在群聊中的名称,用于 @ 提及识别 |+| `enable_memory` | 是否启用群聊记忆功能 |+| `owner_scopes` | 数字分身工具权限配置,按 `channel_id` + `user_id` 维度控制各工具的权限 |++### 10. 飞书多 Bot(`feishu_enterprise`)++当一个团队需要在同一套 JiuwenSwarm 服务中接入多个飞书应用(多个 Bot)时,可使用 `channels.feishu_enterprise`。++每个 bot 会以独立 channel 运行,channel_id 格式为:`feishu_enterprise:<app_id>`。++当前多 bot 仅支持手动编辑 `~/.jiuwenswarm/config/config.yaml`:++``````yaml+channels:+ feishu_enterprise:+ bot_a:+ app_id: "cli_xxx"+ app_secret: "xxx"+ encrypt_key: ""+ verification_token: ""+ allow_from: []+ enable_streaming: true+ chat_id: ""+ enabled: true+ bot_b:+ app_id: "cli_yyy"+ app_secret: "yyy"+ encrypt_key: ""+ verification_token: ""+ allow_from: []+ enable_streaming: true+ chat_id: ""+ enabled: true+``````++#### 字段说明++| 配置项 | 说明 |+|:------|:-----|+| `app_id` | 飞书应用 App ID(必填) |+| `app_secret` | 飞书应用 App Secret(必填) |+| `encrypt_key` | 事件订阅加密 Key(可选) |+| `verification_token` | 事件订阅 Token(可选) |+| `allow_from` | 允许的用户 open_id 列表,空列表表示不限制 |+| `enable_streaming` | 是否启用流式下发 |+| `chat_id` | 固定推送目标(可选) |+| `enabled` | 是否启用该 bot |++#### 与单 Bot `feishu` 的区别++- `feishu`:单通道,channel_id 固定为 `feishu`+- `feishu_enterprise`:多通道,每个 bot 使用独立 channel_id(`feishu_enterprise:<app_id>`)+- 多 Bot 场景下,会按 bot 维度分别记录最近会话信息,避免 bot 之间互相覆盖++---++## 钉钉++### 1. 前提条件++- 你必须是**企业管理员**或**拥有开发者权限的成员**的帐号+- 企业已开通**钉钉开发者后台**++### 2. 创建企业内部应用机器人++#### 步骤 1:进入钉钉开发者后台++- 访问 [https://open-dev.dingtalk.com](https://open-dev.dingtalk.com)+- 登录后选择 **应用开发 → 企业内部开发 → 创建应用**++++#### 步骤 2:填写应用信息++- 应用名称:如 `JiuwenSwarm`+- 应用类型:**机器人**++++#### 步骤 3:添加机器人能力++- 创建成功后,进入应用详情页+- 点击 **应用能力 → 机器人 → 开启机器人配置**+- 填写机器人名称(如 `JiuwenSwarm`)、机器人简介(≤10 字)等信息++++#### 步骤 4:配置消息接收模式++选择 **Stream 模式**,使用 WebSocket 长连接,无需公网 IP,适合云函数/本地调试。++### 3. 配置权限++在 **权限管理** 页面,开启以下权限(根据需求):+- 发送单聊/群聊消息:`qyapi_robot_sendmsg`+- 根据手机号查 userId(用于单聊):`topapi_v2_user_getbymobile`+- 发送互动卡片:`Card.Instance.Write`+- 流式更新卡片(AI 场景必备):`Card.Streaming.Write`++### 4. 发布应用 & 机器人++#### 步骤 1:保存并发布机器人++- 在机器人配置页点击 **保存**+- 返回应用主页,点击 **版本管理与发布 → 发布**+- 填写版本号、更新日志、可见范围等信息++++#### 步骤 2:确认发布++- 点击 **确认发布**+- 状态变为 **已发布** 即可使用++> 💡 发布后可在钉钉客户端搜索机器人名称添加到群聊或私聊++### 5. 配置钉钉 Channel++从**凭证与基础信息**获取应用凭证 **Client ID** 和 **Client Secret** 。++**JiuwenSwarm**服务页面,在"频道-钉钉"中打开 Enabled 开关,并配置 client_id 与 client_secret 并保存:++++---++## 企业微信++### 1. 下载并安装企业微信客户端++1. 打开企业微信客户端,进入**工作台->智能机器人**,点击**创建机器人->手动创建**++ ++ ++ ++2. 进入创建页面后,选择**API 模式创建**++ ++3. 在 API 配置页面,选择**连接方式为「使用长连接」**++ ++4. 配置完成后,页面将自动生成并展示 **Bot ID** 和 **Secret** ,妥善保存该信息(后续关联 JiuwenSwarm 需使用)++### 2. 关联 JiuwenSwarm++1. 进入 JiuwenSwarm 页面,选择"频道",在频道页面选择 "企业微信"。++2. 输入步骤一保存的 botId 以及 secret。然后点击保存即可。++ ++ ++### 3. 与企业微信机器人对话++> ⚠️ **注意**:如配置完成后未能找到机器人,可在以下路径中找到:工作台 -> 智能机器人 -> 详情 -> 去使用 -> 发消息。++++++1. 在企业微信中,找到刚添加的机器人,发送验证消息,收到回复消息后,表示对接成功++2. 在手机端企业微信中,发送验证消息,收到回复消息后,表示对接成功++++++### 4. 开启群聊数字分身(可选)++在完成企业微信机器人的基本配置后,可进一步开启数字分身功能。++> ⚠️ **注意**:企业微信中,群聊消息必须 **@机器人** 才能被 bot 接收到。未 @ 机器人的消息不会触发数字分身回复。++#### 前提条件++- 已完成企业微信机器人创建并关联 JiuwenSwarm+- 已将机器人添加到目标群聊:打开企业微信,进入群组,点击添加成员 -> **群机器人** -> **智能机器人**,搜索你创建的应用名称并添加++#### 配置步骤++1. 在 JiuwenSwarm 频道管理页面,进入企业微信频道配置,启用 **`group_digital_avatar`** 开关,并配置 **`my_user_id`** 和 **`bot_name`**。启用数字分身前需要与机器人私聊一次,否则会报错 `[AiBotSDK] [WARN] Reply ack error`++ ++2. 配置 **`my_user_id`**(必填):填入数字分身对应用户的企业微信账号。获取方式如下:+ - 打开[企业微信管理后台](https://work.weixin.qq.com/wework_admin/login)+ - 进入 **通讯录 -> 组织架构 -> 所在部门 -> 成员详情**+ - 页面中显示的**账号**即为 `my_user_id`++ ++ ++3. 配置 **`bot_name`**(可选):填写机器人在群聊中的显示名称,用于 @ 提及识别++4. (可选)启用 **`enable_memory`** 开关,开启后企业微信群聊中可读取及搜索本地记忆文件(群聊中不写入记忆)++5. 配置**工具/路径权限**:数字分身在群聊中自主运行,无法像私聊那样弹窗让用户确认操作,因此需要预先配置允许使用的工具和可访问的路径。在频道管理页面开启数字分身后,进入权限配置界面,按需设置各工具的权限(`allow` 允许 / `deny` 拒绝)。未配置权限时,需要确认的操作(`ask`)会被自动降级为拒绝(`deny`)++ ++也可以通过编辑 `~/.jiuwenswarm/config/config.yaml` 来配置:++``````yaml+channels:+ wecom:+ bot_id: "你的 Bot ID"+ secret: "你的 Secret"+ send_file_allowed: true+ enabled: true+ group_digital_avatar: true+ my_user_id: "用户账号"+ bot_name: "机器人名称"+ enable_memory: false++permissions:+ owner_scopes:+ wecom:+ "用户账号":+ defaults:+ "*": "allow"+ tools:+ bash:+ "*": "deny"+ patterns:+ "git status *": "allow"+ "git log *": "allow"+ write:+ "*": "deny"+ deny_guidance_message: "该工具未被授权在数字分身模式下使用。"+``````++#### 配置项说明++| 配置项 | 说明 |+|:------|:-----|+| `group_digital_avatar` | 是否启用群聊数字分身功能 |+| `my_user_id` | 开启数字分身时**必填**:数字分身对应用户的企业微信账号 |+| `bot_name` | 可选:机器人在群聊中的名称,用于 @ 提及识别 |+| `enable_memory` | 是否启用群聊记忆功能 |+| `owner_scopes` | 数字分身工具权限配置,按 `channel_id` + `user_id` 维度控制各工具的权限 |++---++## 个人微信++### 1. 前提条件++- 你是**安卓**或 **iOS** 用户+- 你是**鸿蒙**用户,且不介意使用**卓易通**+- 由于当前个人微信限制,长时间未在个人微信中对话,定时任务无法发出,建议采用其他通道设置定时任务++> 💡 **提示**:当用户向 ClawBot 发送一条消息后,应用最多可以向该用户发送 **10 条**独立消息(包括回复的消息)。若用户再次向 ClawBot 发送消息,配额将重置为 10。++### 2. 安卓或 iOS 接入++#### 步骤 1:微信版本升级++在微信中依次进入「我」->「设置」->「关于微信」->「版本更新」:+- iOS 请升级到最新版本+- 安卓请升级到最新版本++++#### 步骤 2:微信扫码接入++- 打开最新版本的 JiuwenSwarm 前端,点击「频道」->「微信」,启用微信配置功能并点击保存。页面会出现**二维码**++++- 打开手机微信,通过右上角「+」->「扫一扫」,扫描上一步骤生成的二维码,继续连接即可完成接入++### 3. 鸿蒙接入++由于鸿蒙微信版本还未支持 **ClawBot** 功能,所以**鸿蒙原生微信当前还不能接入**,但用户可以通过**卓易通**完成接入,步骤如下:++#### 步骤 1:安装微分身双开++- 通过「卓易通」下载「微分身双开」,重新登录微信++++#### 步骤 2:升级 & 接入++- 其余步骤与**安卓或 iOS 接入**方法完全一致。\ No newline at end of filediff --git "a/docs/zh/\345\233\275\345\244\226\351\242\221\351\201\223.md" "b/docs/zh/\345\233\275\345\244\226\351\242\221\351\201\223.md"new file mode 100644index 0000000000..fc6c4e14bf--- /dev/null+++ "b/docs/zh/\345\233\275\345\244\226\351\242\221\351\201\223.md"@@ -0,0 +1,153 @@+# 国外频道++JiuwenSwarm 支持接入多个国外聊天平台,以下是各频道的详细配置说明。++## Telegram++### 1. 创建 Telegram Bot++通过 Telegram 内置的 [@BotFather](https://t.me/BotFather) 创建机器人并获取 Bot Token。++**第一步:** 在 Telegram 中搜索 `@BotFather` 并打开对话++++**第二步:** 发送 `/newbot` 命令,按提示输入机器人名称和用户名++BotFather 会依次要求你输入:+- **机器人显示名称**(如 `JiuwenSwarm Bot`)+- **机器人用户名**(必须以 `bot` 结尾,如 `jiuwenswarm_bot`)++++**第三步:** 保存 Bot Token++创建成功后,BotFather 会返回一个格式如 `123456789:ABCDefGhIJKlmN...` 的 Token,请妥善保存,后续配置需要使用。++> ⚠️ **注意**:Bot Token 等同于机器人的密码,请勿泄露。如果 Token 泄露,可在 BotFather 中使用 `/revoke` 重新生成。++### 2. 绑定频道++#### 方式一:网页配置(推荐)++在 JiuwenSwarm 前端页面,点击 **`智能体` / `频道`** 卡片,在 Telegram 频道模块中填入 Bot Token,开启使用,点击保存即可。++++#### 方式二:修改 `config.yaml`++编辑 `~/.jiuwenswarm/config/config.yaml`:++``````yaml+channels:+ telegram:+ bot_token: "你的Bot Token"+ allow_from: []+ parse_mode: Markdown+ group_chat_mode: mention+ enabled: true+``````++保存后若服务已运行会自动重载,未运行可以执行 `jiuwenswarm-start` 启动服务。++### 3. 配置说明++| 配置项 | 说明 | 默认值 |+|:------|:-----|:------|+| `bot_token` | 从 @BotFather 获取的 Bot Token,**必填** | 空 |+| `allow_from` | 允许使用的 Telegram user_id 白名单列表,为空则允许所有用户 | `[]` |+| `parse_mode` | 消息解析模式:`Markdown`、`HTML` 或 `None`(纯文本) | `Markdown` |+| `group_chat_mode` | 群聊响应模式(见下方详细说明) | `mention` |+| `enabled` | 是否启用 Telegram 频道 | `false` |++### 群聊模式说明++当机器人被添加到 Telegram 群组时,`group_chat_mode` 控制机器人如何响应群内消息:++| 模式 | 说明 |+|:-----|:-----|+| `mention` | **仅响应 @提及**:只有在群内 @机器人 时才会处理消息(推荐) |+| `reply` | **仅响应回复**:只有回复机器人消息时才会处理 |+| `all` | **响应所有消息**:群内所有文本消息都会被处理 |+| `off` | **禁用群聊**:在群组中不响应任何消息 |++### 4. 开始对话++**方式 1:** 在 Telegram 中搜索你创建的机器人用户名,发送 `你好` 即可开始对话++++**方式 2:** 将机器人添加到群组中,根据 `group_chat_mode` 配置与机器人交互++++### 5. 获取 user_id(配置白名单)++如需配置 `allow_from` 白名单,需要先获取用户的 Telegram user_id。可以通过以下方式获取:++1. 在 Telegram 中搜索 `@userinfobot`,发送任意消息即可获取你的 user_id++2. 将获取到的 user_id 填入 `allow_from` 列表中++``````yaml+channels:+ telegram:+ bot_token: "你的Bot Token"+ allow_from:+ - "123456789"+ - "987654321"+ enabled: true+``````++> 💡 **提示**:`allow_from` 为空列表时,所有用户均可使用机器人。设置白名单后,只有列表中的用户才能与机器人对话。++---++## Discord++当前版本已经支持 Discord 频道接入。在「频道管理」中配置并启用 Discord Bot,也可以手动编辑 `config.yaml`。++分步图文(开发者后台创建 Bot、Intent、安装链接、频道管理)见 [Discord.md](Discord.md)。++### 配置项++- `bot_token`+- `application_id`+- `guild_id`+- `channel_id`+- `block_dm`+- `allow_from`+- `enabled`++可在 `~/.jiuwenswarm/config/config.yaml` 中按如下方式配置:++``````yaml+channels:+ discord:+ bot_token: "Discord Bot Token"+ application_id: "Application ID"+ guild_id: "目标服务器 Guild ID"+ channel_id: "目标频道 Channel ID"+ block_dm: false+ allow_from: []+ enabled: true+``````++### 简略使用说明++1. 在 Discord Developer Portal 创建 Bot,获取 `bot_token`+2. 在 Bot 页签开启 **Message Content Intent**+3. 将机器人邀请进目标服务器并赋予读写频道权限+4. 在 JiuwenSwarm 里填入配置并启用 `enabled: true`++### 字段说明++| 配置项 | 说明 | 默认值 |+|:------|:-----|:------|+| `bot_token` | Discord Bot Token(必填) | 空 |+| `application_id` | 应用 ID(可选,建议填写) | 空 |+| `guild_id` | 仅监听指定服务器(可选,留空表示不限制) | 空 |+| `channel_id` | 仅监听/回复指定频道(可选,留空按消息上下文回复) | 空 |+| `block_dm` | 为 `true` 时不处理私信(DM) | `false` |+| `allow_from` | 允许访问的 Discord 用户 ID 列表,空列表表示允许所有 | `[]` |+| `enabled` | 是否启用 Discord 频道 | `false` |\ No newline at end of filediff --git "a/docs/zh/\351\242\221\351\201\223.md" "b/docs/zh/\351\242\221\351\201\223.md"index 7872c78487..63e4e6c423 100644--- "a/docs/zh/\351\242\221\351\201\223.md"+++ "b/docs/zh/\351\242\221\351\201\223.md"@@ -13,9 +13,18 @@| **身份识别** | 为每个平台的用户建立唯一标识,维护独立的对话上下文 || **安全隔离** | 不同频道的消息流相互隔离,支持白名单、权限控制等 |+### 频道、网页对话与智能体的关系++三者构成了 JiuwenSwarm 的完整对话体系,关系如下:++- **频道(Channel)**:消息接入层,负责接收来自不同平台的消息并统一格式。除了飞书、小艺等外部频道,**网页对话(Web UI)本身也是一个内置频道**。+- **智能体(Agent)**:消息处理引擎,所有频道接入的消息最终都由智能体进行理解、推理和响应。+- **网页对话**:内置的 Web 频道,提供可视化界面供用户直接与智能体交互。++### 简介-JiuwenSwarm 的**频道**,是您与不同聊天平台对话的**渠道**。JiuwenSwarm 已经实现了**鸿蒙小艺、飞书**等 channel 的无缝接入,并持续拓展至更多元渠道。可以直接在通过 **飞书**、**鸿蒙生态终端的小艺 app** 应用直接与 JiuwenSwarm 对话。+JiuwenSwarm 的**频道**,是您与不同聊天平台对话的**渠道**。JiuwenSwarm 已经实现了**鸿蒙小艺、飞书**等 channel 的无缝接入,并持续拓展至更多元渠道。可以直接通过 **飞书**、**鸿蒙生态终端的小艺 app** 与 JiuwenSwarm 对话。### 数字分身@@ -25,734 +34,45 @@ JiuwenSwarm 在**飞书**和**企业微信**频道中支持**群聊数字分身*### 配置方式-配置频道有两种方式:--- **网页配置**(推荐)— 在 JiuwenSwarm 前端页面,点击 `智能体` / `频道`卡片,在频道管理模块,填写相关配置。--- **手动编辑 `config.yaml`** — 默认在 `~/.jiuwenswarm/config/config.yaml` (由首次 `jiuwenswarm-start` 启动时自动生成),将需要的频道设 `enabled: true` 并填好鉴权信息;保存后自动重载,无需重启。-------## 频道接入--### 小艺--[演示视频](../assets/videos/xiaoyi_channel.mp4)--#### 1. 创建小艺智能体--通过在 [小艺开放平台 ](https://developer.huawei.com/consumer/cn/hag/abilityportal/#/)创建 JiuwenSwarm 模式的智能体,即可与 JiuwenSwarm 服务无缝接入。----### 第一步:创建 JiuwenSwarm 模式的智能体----### 第二步:创建凭证及添加白名单--点击新建凭证,并**保存 ak 与 sk 信息**。--------小艺开放平台为开发者提供真机调试能力,通过配置白名单分组,添加用户账号,可以在鸿蒙终端与小艺智能体对话。添加成功并上架成功后,可在终端小艺应用中使用该智能体。--------勾选新建的用户组:----### 第三步:上架智能体--填写开场白对话,点击上架按钮:----### 第四步:启用 push 通知(可选)--点击开启触发器,填写名称后保存,将 apiID 填写至 jiuwenswarm 中:----点击变量编辑,开通系统变量中的 push_id:----> 💡 **说明**:`api_id` 是触发器的 API 标识,`push_id` 是用于接收推送消息的标识。启用 push 通知时,两者需配合使用,缺一不可。--#### 2. 绑定频道--### 方式一:网页配置--将小艺开放平台获取到的 **ak、sk、agentId** 信息,填写至 JiuwenSwarm 的小艺频道,开启使用,点击保存即可开启对话。如开启了 push 可以填入 api_id(选填):----### 方式二:修改配置文件--编辑 `~/.jiuwenswarm/config/config.yaml`:--``````yaml-channels:- xiaoyi:- # 华为小艺 A2A 配置- mode: xiaoyi_channel- ak: "小艺平台凭证 ak"- sk: "小艺平台凭证 sk"- agent_id: "创建的agent ID"- api_id: "创建的触发器apiId"- push_id: "触发器的 push_id(与 api_id 配合使用,启用 push 通知时必填)"- uid: "" # 用户标识(可选)- api_key: "" # API 密钥(可选)- push_url: "" # 推送 URL(可选)- file_upload_url: "" # 文件上传 URL(可选)- phone_tools_enabled: false # 是否启用电话工具(可选)- send_file_allowed: true # 是否允许发送文件(可选)- enable_streaming: true- enabled: true-``````--保存后若服务已运行会自动重载,未运行可以执行 `jiuwenswarm-start` 启动服务。----#### 3. 智能体对话--**方式 1:** 直接在网页与智能体应用对话----**方式 2:** 在鸿蒙终端小艺应用,找到已上架的应用,直接对话------### 飞书--#### 1. 创建飞书自建应用--1. 访问 [飞书开放平台](https://open.feishu.cn/) 并登录。--2. 进入**开发者后台**,点击**创建企业自建应用**。--3. 填写应用名称、描述,并上传图标,点击**创建**。-- --#### 2. 添加机器人能力--1. 在应用配置页面,左侧选择**添加应用能力**。--2. 点击**机器人**下的**添加**按钮。-- --#### 3. 记录机器人应用凭证--1. 进入飞书机器人管理后台--2. 记录 App ID 与 App Secret 配置到 JiuwenSwarm 飞书频道,点击 enabled 并保存生效-- -- --#### 4. 配置权限--1. 左侧选择**权限管理** -> **API 权限**。--2. 搜索并开通以下关键权限(用于收发消息):- - `im:message:send`:以应用的身份发送消息- - `im:message.p2p_msg:readonly`:获取用户发给机器人的单聊消息- - `im:message.group_at_msg:readonly`:接收群聊中 @ 机器人消息事件- - `im:resource:upload`:上传图片和文件(用于发送图片/文件给用户)- - `contact:user.employee_id:readonly`:获取用户 ID 信息- - 也可以批量导入权限,参考飞书开放平台文档中的权限列表----#### 5. 配置事件订阅(接收消息)--1. 左侧选择**事件与回调**--2. **添加事件**:- - `im.message.receive_v1`(接收消息事件)- - `im.message.message_read_v1`(消息已读)--3. **添加回调**:- - `card.action.trigger`(卡片回传交互)--4. (可选)**配置加密策略**:如果启用了加密,需要保存 `Encrypt Key`----#### 6. 发布应用--1. 左侧选择**版本管理与发布**,点击**创建版本**--2. 填写版本号、更新说明,选择可用范围(通常选择**全体成员**或部分成员)--3. 提交审核。如果企业开启了免审,版本会立即生效--4. 飞书 APP 中登录提交应用的账号即可看到发布的聊天机器人----#### 7. 在群聊中添加机器人(可选)--1. 打开飞书客户端,进入需要添加机器人的群组--2. 点击群设置 -> **群机器人** -> **添加机器人**,搜索你创建的应用名称并添加----#### 8. 配置飞书 Channel--启动前端服务后,在「频道-飞书」中打开 Enable 开关并配置第三步记录的 App ID 与 App Secret。--#### 9. 开启群聊数字分身(可选)--在完成飞书机器人的基本配置后,可进一步开启数字分身功能,让机器人在群聊中作为指定用户的分身自动回复。--> 飞书中数字分身支持以下触发方式:**@机器人**、**@用户名**(即数字分身对应的用户)、或在消息中**提及用户姓名**,均会触发数字分身回复。--### 前提条件--- 已完成飞书机器人创建、发布,并已将机器人添加到目标群聊(参考步骤 7)--### 配置步骤--1. 在 JiuwenSwarm 频道管理页面,进入飞书频道配置,启用 **`group_digital_avatar`** 开关,并配置 **`my_user_id`** 和 **`bot_name`**。-- --2. 配置 **`my_user_id`**(必填):填入数字分身对应用户的飞书 open_id。获取方式如下:- - 登录飞书 API 调试台,进入[发送消息接口](https://open.feishu.cn/document/server-docs/im-v1/message/create)- - 将 `receive_id_type` 选择为 **open_id**- - 点击**快速复制 open_id**,在弹窗内选择目标用户,获取的 open_id 即为 `my_user_id`-- -- --3. 配置 **`bot_name`**:填写机器人在群聊中的显示名称,用于 @ 提及识别--4. (可选)启用 **`enable_memory`** 开关,开启后飞书群聊中可读取及搜索本地记忆文件--5. 配置**工具/路径权限**:数字分身在群聊中自主运行,无法像私聊那样弹窗让用户确认操作,因此需要预先配置允许使用的工具和可访问的路径。在频道管理页面开启数字分身后,进入权限配置界面,按需设置各工具的权限(`allow` 允许 / `deny` 拒绝)。未配置权限时,需要确认的操作(`ask`)会被自动降级为拒绝(`deny`)-- --也可以通过编辑 `~/.jiuwenswarm/config/config.yaml` 来配置:--``````yaml-channels:- feishu:- app_id: "你的 App ID"- app_secret: "你的 App Secret"- enabled: true- # 群聊数字分身配置- group_digital_avatar: true- my_user_id: "ou_xxxx" # 数字分身对应用户的飞书 open_id- bot_name: "机器人名称" # 机器人在群聊中的名称- enable_memory: false # 是否启用群聊记忆--# 数字分身工具权限配置(按 channel_id + user_id 维度)-permissions:- owner_scopes:- # channel_id:单 bot 场景使用 "feishu",多 bot 场景使用 "feishu_enterprise:<app_id>"- feishu:- "ou_xxxx": # 与上方 my_user_id 一致- defaults:- "*": "allow" # 全局默认:allow / deny- tools:- bash:- "*": "deny" # bash 默认拒绝- patterns:- "git status *": "allow"- "git log *": "allow"- write:- "*": "deny"- deny_guidance_message: "该工具未被授权在数字分身模式下使用。"-``````--6\. 飞书机器人需要新增以下权限:-- - `im:message.group_msg:readonly` - 获取群组中所有消息(敏感权限)- - `contact:contact.base:readonly` - 获取通讯录基本信息- - `contact:user.base:readonly` - 获取用户基本信息- - `im:message.p2p_msg:readonly` - 获取用户发给机器人的单聊消息(用于接收单聊消息事件)--### 配置项说明--| 配置项 | 说明 |-|:------|:-----|-| `group_digital_avatar` | 是否启用群聊数字分身功能。开启后机器人将作为指定用户的数字分身在群聊中活动,智能判断群聊消息是否与该用户相关,自动过滤无关消息、改写相关消息,并对待办/提醒等个人行动类回复自动私发给目标用户,同时在群内补一条简短确认 |-| `my_user_id` | 开启数字分身时**必填**:数字分身对应用户的飞书 open_id(如 `ou_xxx`),未配置则数字分身功能不生效 |-| `bot_name` | 机器人在群聊中的名称,用于 @ 提及识别 |-| `enable_memory` | 是否启用群聊记忆功能。开启后 JiuwenSwarm 在群聊中可读取及搜索本地记忆文件 |-| `owner_scopes` | 数字分身工具权限配置,按 `channel_id` + `user_id` 维度控制各工具的权限。支持 `allow`(允许)、`deny`(拒绝),`ask`(需确认)在数字分身模式下会自动降级为 `deny`。推荐通过网页端配置 |--#### 10. 飞书多 Bot(`feishu_enterprise`)--当一个团队需要在同一套 JiuwenSwarm 服务中接入多个飞书应用(多个 Bot)时,可使用 `channels.feishu_enterprise`。--每个 bot 会以独立 channel 运行,channel_id 格式为:`feishu_enterprise:<app_id>`。--当前多 bot 仅支持手动编辑 `~/.jiuwenswarm/config/config.yaml`:--``````yaml-channels:- feishu_enterprise:- bot_a:- app_id: "cli_xxx"- app_secret: "xxx"- encrypt_key: ""- verification_token: ""- allow_from: []- enable_streaming: true- chat_id: ""- enabled: true- bot_b:- app_id: "cli_yyy"- app_secret: "yyy"- encrypt_key: ""- verification_token: ""- allow_from: []- enable_streaming: true- chat_id: ""- enabled: true-``````--### 字段说明--| 配置项 | 说明 |-|:------|:-----|-| `app_id` | 飞书应用 App ID(必填) |-| `app_secret` | 飞书应用 App Secret(必填) |-| `encrypt_key` | 事件订阅加密 Key(可选) |-| `verification_token` | 事件订阅 Token(可选) |-| `allow_from` | 允许的用户 open_id 列表,空列表表示不限制 |-| `enable_streaming` | 是否启用流式下发 |-| `chat_id` | 固定推送目标(可选) |-| `enabled` | 是否启用该 bot |--### 与单 Bot `feishu` 的区别--- `feishu`:单通道,channel_id 固定为 `feishu`-- `feishu_enterprise`:多通道,每个 bot 使用独立 channel_id(`feishu_enterprise:<app_id>`)-- 多 Bot 场景下,会按 bot 维度分别记录最近会话信息,避免 bot 之间互相覆盖----### 钉钉--#### 1. 前提条件--- 你必须是**企业管理员**或**拥有开发者权限的成员**的帐号-- 企业已开通**钉钉开发者后台**--#### 2. 创建企业内部应用机器人--### 步骤 1:进入钉钉开发者后台--- 访问 [https://open-dev.dingtalk.com](https://open-dev.dingtalk.com)-- 登录后选择 **应用开发 → 企业内部开发 → 创建应用**----### 步骤 2:填写应用信息--- 应用名称:如 `JiuwenSwarm`-- 应用类型:**机器人**+本教程以**网页端配置**为主,后续各频道的接入说明均基于网页操作演示。-+如需手动配置,可编辑 `config.yaml` 文件(默认路径:`~/.jiuwenswarm/config/config.yaml`),将对应频道设为 `enabled: true` 并填写鉴权信息,保存后自动重载。-### 步骤 3:添加机器人能力+### 频道特性差异-- 创建成功后,进入应用详情页-- 点击 **应用能力 → 机器人 → 开启机器人配置**-- 填写机器人名称(如 `JiuwenSwarm`)、机器人简介(≤10 字)等信息+不同频道在私聊/群聊支持、触发方式、权限要求等方面存在差异:---### 步骤 4:配置消息接收模式--选择 **Stream 模式**,使用 WebSocket 长连接,无需公网 IP,适合云函数/本地调试。----#### 3. 配置权限--在 **权限管理** 页面,开启以下权限(根据需求):-- 送单聊/群聊消息:`qyapi_robot_sendmsg`-- 根据手机号查 userId(用于单聊):`topapi_v2_user_getbymobile`-- 发送互动卡片:`Card.Instance.Write`-- 流式更新卡片(AI 场景必备):`Card.Streaming.Write`--#### 4. 发布应用 & 机器人--### 步骤 1:保存并发布机器人--- 在机器人配置页点击 **保存**-- 返回应用主页,点击 **版本管理与发布 → 发布**-- 填写版本号、更新日志、可见范围等信息----### 步骤 2:确认发布--- 点击 **确认发布**-- 状态变为 **已发布** 即可使用--> 💡 发布后可在钉钉客户端搜索机器人名称添加到群聊或私聊----#### 5. 配置钉钉 Channel--从**凭证与基础信息**获取应用凭证 **Client ID** 和 **Client Secret** 。--**JiuwenSwarm**服务页面,在"频道-钉钉"中打开 Enabled 开关,并配置 client_id 与 client_secret 并保存:------### 企业微信--#### 1. 下载并安装企业微信客户端--1. 打开企业微信客户端,进入**工作台->智能机器人**,点击**创建机器人->手动创建**-- -- -- --2. 进入创建页面后,选择**API 模式创建**-- --3. 在 API 配置页面,选择**连接方式为「使用长连接」**-- --4. 配置完成后,页面将自动生成并展示 **Bot ID** 和 **Secret** ,妥善保存该信息(后续关联 JiuwenSwarm 需使用)--#### 2. 关联 JiuwenSwarm--1. 进入 JiuwenSwarm 页面,选择"频道",在频道页面选择 "企业微信"。--2. 输入步骤一保存的 botId 以及 secret。然后点击保存即可。-- -- --#### 3. 与企业微信机器人对话--> ⚠️ **注意**:如配置完成后未能找到机器人,可在以下路径中找到:工作台 -> 智能机器人 -> 详情 -> 去使用 -> 发消息。------1. 在企业微信中,找到刚添加的机器人,发送验证消息,收到回复消息后,表示对接成功--2. 在手机端企业微信中,发送验证消息,收到回复消息后,表示对接成功------#### 4. 开启群聊数字分身(可选)--在完成企业微信机器人的基本配置后,可进一步开启数字分身功能。--> ⚠️ **注意**:企业微信中,群聊消息必须 **@机器人** 才能被 bot 接收到。未 @ 机器人的消息不会触发数字分身回复。--### 前提条件--- 已完成企业微信机器人创建并关联 JiuwenSwarm-- 已将机器人添加到目标群聊:打开企业微信,进入群组,点击添加成员 -> **群机器人** -> **智能机器人**,搜索你创建的应用名称并添加--### 配置步骤--1. 在 JiuwenSwarm 频道管理页面,进入企业微信频道配置,启用 **`group_digital_avatar`** 开关,并配置 **`my_user_id`** 和 **`bot_name`**。启用数字分身前需要与机器人私聊一次,否则会报错 `[AiBotSDK] [WARN] Reply ack error`-- --2. 配置 **`my_user_id`**(必填):填入数字分身对应用户的企业微信账号。获取方式如下:- - 打开[企业微信管理后台](https://work.weixin.qq.com/wework_admin/login)- - 进入 **通讯录 -> 组织架构 -> 所在部门 -> 成员详情**- - 页面中显示的**账号**即为 `my_user_id`-- -- --3. 配置 **`bot_name`**(可选):填写机器人在群聊中的显示名称,用于 @ 提及识别--4. (可选)启用 **`enable_memory`** 开关,开启后企业微信群聊中可读取及搜索本地记忆文件(群聊中不写入记忆)--5. 配置**工具/路径权限**:数字分身在群聊中自主运行,无法像私聊那样弹窗让用户确认操作,因此需要预先配置允许使用的工具和可访问的路径。在频道管理页面开启数字分身后,进入权限配置界面,按需设置各工具的权限(`allow` 允许 / `deny` 拒绝)。未配置权限时,需要确认的操作(`ask`)会被自动降级为拒绝(`deny`)-- --也可以通过编辑 `~/.jiuwenswarm/config/config.yaml` 来配置:--``````yaml-channels:- wecom:- bot_id: "你的 Bot ID"- secret: "你的 Secret"- send_file_allowed: true # 是否允许发送文件(可选)- enabled: true- # 群聊数字分身配置- group_digital_avatar: true- my_user_id: "用户账号" # 数字分身对应用户的企业微信账号- bot_name: "机器人名称" # 机器人在群聊中的名称(可选)- enable_memory: false # 是否启用群聊记忆--# 数字分身工具权限配置(按 channel_id + user_id 维度)-permissions:- owner_scopes:- wecom:- "用户账号": # 与上方 my_user_id 一致- defaults:- "*": "allow" # 全局默认:allow / deny- tools:- bash:- "*": "deny"- patterns:- "git status *": "allow"- "git log *": "allow"- write:- "*": "deny"- deny_guidance_message: "该工具未被授权在数字分身模式下使用。"-``````--### 配置项说明--| 配置项 | 说明 |-|:------|:-----|-| `group_digital_avatar` | 是否启用群聊数字分身功能。开启后机器人将作为指定用户的数字分身在群聊中活动,智能判断群聊消息是否与该用户相关,自动过滤无关消息、改写相关消息,并对待办/提醒等个人行动类回复自动私发给目标用户,同时在群内补一条简短确认 |-| `my_user_id` | 开启数字分身时**必填**:数字分身对应用户的企业微信账号,未配置则数字分身功能不生效 |-| `bot_name` | 可选:机器人在群聊中的名称,用于 @ 提及识别 |-| `enable_memory` | 是否启用群聊记忆功能。开启后 JiuwenSwarm 在群聊中可读取及搜索本地记忆文件,群聊中不写入记忆 |-| `owner_scopes` | 数字分身工具权限配置,按 `channel_id` + `user_id` 维度控制各工具的权限。支持 `allow`(允许)、`deny`(拒绝),`ask`(需确认)在数字分身模式下会自动降级为 `deny`。推荐通过网页端配置 |----### Telegram--#### 1. 创建 Telegram Bot--通过 Telegram 内置的 [@BotFather](https://t.me/BotFather) 创建机器人并获取 Bot Token。--**第一步:** 在 Telegram 中搜索 `@BotFather` 并打开对话----**第二步:** 发送 `/newbot` 命令,按提示输入机器人名称和用户名--BotFather 会依次要求你输入:-- **机器人显示名称**(如 `JiuwenSwarm Bot`)-- **机器人用户名**(必须以 `bot` 结尾,如 `jiuwenswarm_bot`)----### 第三步:保存 Bot Token--创建成功后,BotFather 会返回一个格式如 `123456789:ABCDefGhIJKlmN...` 的 Token,请妥善保存,后续配置需要使用。--> ⚠️ **注意**:Bot Token 等同于机器人的密码,请勿泄露。如果 Token 泄露,可在 BotFather 中使用 `/revoke` 重新生成。--#### 2. 绑定频道--### 方式一:网页配置(推荐)--在 JiuwenSwarm 前端页面,点击 **`智能体` / `频道`** 卡片,在 Telegram 频道模块中填入 Bot Token,开启使用,点击保存即可。----### 方式二:修改 `config.yaml`--编辑 `~/.jiuwenswarm/config/config.yaml`:--``````yaml-channels:- telegram:- # 从 @BotFather 获取的 Bot Token- bot_token: "你的Bot Token"- # 用户白名单(Telegram user_id),为空则允许所有用户- allow_from: []- # 消息解析模式: Markdown, HTML, None- parse_mode: Markdown- # 群聊模式: mention, reply, all, off- group_chat_mode: mention- enabled: true-``````--保存后若服务已运行会自动重载,未运行可以执行 `jiuwenswarm-start` 启动服务。--#### 3. 配置说明--| 配置项 | 说明 | 默认值 |-|:------|:-----|:------|-| `bot_token` | 从 @BotFather 获取的 Bot Token,**必填** | 空 |-| `allow_from` | 允许使用的 Telegram user_id 白名单列表,为空则允许所有用户 | `[]` |-| `parse_mode` | 消息解析模式:`Markdown`、`HTML` 或 `None`(纯文本) | `Markdown` |-| `group_chat_mode` | 群聊响应模式(见下方详细说明) | `mention` |-| `enabled` | 是否启用 Telegram 频道 | `false` |--### 群聊模式说明--当机器人被添加到 Telegram 群组时,`group_chat_mode` 控制机器人如何响应群内消息:--| 模式 | 说明 |-|:-----|:-----|-| `mention` | **仅响应 @提及**:只有在群内 @机器人 时才会处理消息(推荐) |-| `reply` | **仅响应回复**:只有回复机器人消息时才会处理 |-| `all` | **响应所有消息**:群内所有文本消息都会被处理 |-| `off` | **禁用群聊**:在群组中不响应任何消息 |--#### 4. 开始对话--**方式 1:** 在 Telegram 中搜索你创建的机器人用户名,发送 `你好` 即可开始对话----**方式 2:** 将机器人添加到群组中,根据 `group_chat_mode` 配置与机器人交互----#### 5. 获取 user_id(配置白名单)--如需配置 `allow_from` 白名单,需要先获取用户的 Telegram user_id。可以通过以下方式获取:--1. 在 Telegram 中搜索 `@userinfobot`,发送任意消息即可获取你的 user_id--2. 将获取到的 user_id 填入 `allow_from` 列表中--``````yaml-channels:- telegram:- bot_token: "你的Bot Token"- allow_from:- - "123456789" # 用户A的 user_id- - "987654321" # 用户B的 user_id- enabled: true-``````--> 💡 **提示**:`allow_from` 为空列表时,所有用户均可使用机器人。设置白名单后,只有列表中的用户才能与机器人对话。----### Discord--当前版本已经支持 Discord 频道接入。在「频道管理」中配置并启用 Discord Bot,也可以手动编辑 `config.yaml`。--### 分步图文(开发者后台创建 Bot、Intent、安装链接、频道管理)见 [Discord.md](Discord.md)。--配置项:-- `bot_token`-- `application_id`-- `guild_id`-- `channel_id`-- `block_dm`-- `allow_from`-- `enabled`--可在 `~/.jiuwenswarm/config/config.yaml` 中按如下方式配置:--``````yaml-channels:- discord:- bot_token: "Discord Bot Token"- application_id: "Application ID"- guild_id: "目标服务器 Guild ID"- channel_id: "目标频道 Channel ID"- block_dm: false- allow_from: []- enabled: true-``````--#### 简略使用说明--1. 在 Discord Developer Portal 创建 Bot,获取 `bot_token`-2. 在 Bot 页签开启 **Message Content Intent**-3. 将机器人邀请进目标服务器并赋予读写频道权限-4. 在 JiuwenSwarm 里填入配置并启用 `enabled: true`--#### 字段说明--| 配置项 | 说明 | 默认值 |-|:------|:-----|:------|-| `bot_token` | Discord Bot Token(必填) | 空 |-| `application_id` | 应用 ID(可选,建议填写) | 空 |-| `guild_id` | 仅监听指定服务器(可选,留空表示不限制) | 空 |-| `channel_id` | 仅监听/回复指定频道(可选,留空按消息上下文回复) | 空 |-| `block_dm` | 为 `true` 时不处理私信(DM) | `false` |-| `allow_from` | 允许访问的 Discord 用户 ID 列表,空列表表示允许所有 | `[]` |-| `enabled` | 是否启用 Discord 频道 | `false` |----### 个人微信--#### 1. 前提条件--- 你是**安卓**或 **iOS** 用户-- 你是**鸿蒙**用户,且不介意使用**卓易通**-- 由于当前个人微信限制,长时间未在个人微信中对话,定时任务无法发出,建议采用其他通道设置定时任务--> 💡 **提示**:当用户向 ClawBot 发送一条消息后,应用最多可以向该用户发送 **10 条**独立消息(包括回复的消息)。若用户再次向 ClawBot 发送消息,配额将重置为 10。--#### 2. 安卓或 iOS 接入--### 步骤 1:微信版本升级--在微信中依次进入「我」->「设置」->「关于微信」->「版本更新」:-- iOS 请升级到最新版本-- 安卓请升级到最新版本------### 步骤 2:微信扫码接入+| 特性 | 说明 |+|------|------|+| **私聊/群聊** | 部分频道仅支持私聊(如小艺),部分同时支持私聊和群聊(如飞书、企业微信) |+| **触发方式** | 私聊中通常直接对话即可触发;群聊中可能需要 @机器人或使用特定指令前缀 |+| **权限要求** | 不同平台对机器人权限的要求不同,如消息读取权限、群管理权限等 |-- 打开最新版本的 JiuwenSwarm 前端,点击「频道」->「微信」,启用微信配置功能并点击保存。页面会出现**二维码**+具体差异请参考各频道的详细接入说明。-+----- 打开手机微信,通过右上角「+」->「扫一扫」,扫描上一步骤生成的二维码,继续连接即可完成接入+## 频道接入-+JiuwenSwarm 支持多种聊天平台频道接入,根据地域分为以下两类:- #### 3. 鸿蒙接入--由于鸿蒙微信版本还未支持 **ClawBot** 功能,所以**鸿蒙原生微信当前还不能接入**,但用户可以通过**卓易通**完成接入,步骤如下:+### 国内频道-### 步骤 1:安装微分身双开+| 频道 | 说明 |+|------|------|+| [小艺](国内频道.md#小艺) | 华为鸿蒙生态智能助理,仅支持私聊 |+| [飞书](国内频道.md#飞书) | 企业协作平台,支持私聊和群聊,含数字分身功能 |+| [钉钉](国内频道.md#钉钉) | 企业协作平台,支持私聊和群聊 |+| [企业微信](国内频道.md#企业微信) | 企业即时通讯工具,支持私聊和群聊,含数字分身功能 |+| [个人微信](国内频道.md#个人微信) | 个人即时通讯工具,支持私聊 |-- 通过「卓易通」下载「微分身双开」,重新登录微信+详细配置说明请参考:[国内频道](国内频道.md)-+### 国外频道-### 步骤 2:升级 & 接入+| 频道 | 说明 |+|------|------|+| [Telegram](国外频道.md#telegram) | 国外即时通讯工具,支持私聊和群聊 |+| [Discord](国外频道.md#discord) | 游戏社区平台,支持私聊和群聊 |-- 其余步骤与**安卓或 iOS 接入**方法完全一致。+详细配置说明请参考:[国外频道](国外频道.md)\ No newline at end of file