mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
91 lines
3.1 KiB
Plaintext
91 lines
3.1 KiB
Plaintext
---
|
|
title: WeCom Bot
|
|
description: Connect CowAgent to WeCom AI Bot (WebSocket long connection)
|
|
---
|
|
|
|
> Connect CowAgent via WeCom AI Bot, supporting both internal direct messages and group chats. No public IP required — uses a WebSocket long connection, with Markdown rendering and streaming output.
|
|
|
|
<Note>
|
|
WeCom Bot and WeCom App are two different integration methods. WeCom Bot uses a WebSocket long connection and requires no public IP or domain, making setup much simpler.
|
|
</Note>
|
|
|
|
## 1. Connection methods
|
|
|
|
### Option A: One-click QR scan (recommended)
|
|
|
|
No need to create the bot ahead of time. Start CowAgent and open the Web console (local URL: http://127.0.0.1:9899/), go to the **Channels** tab, click **Connect Channel**, choose **WeCom Bot**, switch to **QR scan** mode, and scan the QR code with **WeCom** — bot creation and connection complete automatically.
|
|
|
|
<img src="https://cdn.link-ai.tech/doc/20260401121213.png" width="800"/>
|
|
|
|
<Note>
|
|
After a successful scan, you can further configure the bot (name, avatar, visibility scope, etc.) in **WeCom Workbench → AI Bot**.
|
|
</Note>
|
|
|
|
### Option B: Manual creation
|
|
|
|
Create the AI Bot in WeCom and obtain the Bot ID and Secret, then connect via the Web console or config file.
|
|
|
|
**Step 1: Create the AI Bot**
|
|
|
|
1. Open the WeCom client, go to **Workbench**, and click **AI Bot**:
|
|
|
|
<img src="https://cdn.link-ai.tech/doc/20260316180959.png" width="800"/>
|
|
|
|
2. Click **Create Bot → Manual Creation**:
|
|
|
|
<img src="https://cdn.link-ai.tech/doc/20260316181118.png" width="800"/>
|
|
|
|
3. Scroll to the bottom of the right panel and select **API Mode**:
|
|
|
|
<img src="https://cdn.link-ai.tech/doc/20260316181215.png" width="800"/>
|
|
|
|
4. Set the bot name, avatar, and visibility scope. Choose **Long Connection** mode, save the **Bot ID** and **Secret**, then click Save.
|
|
|
|
**Step 2: Connect to CowAgent**
|
|
|
|
<Tabs>
|
|
<Tab title="Web Console">
|
|
Open the Web console, go to the **Channels** tab, click **Connect Channel**, choose **WeCom Bot**, switch to **Manual** mode, enter the Bot ID and Secret, and click Connect.
|
|
|
|
<img src="https://cdn.link-ai.tech/doc/20260316181711.png" width="800"/>
|
|
</Tab>
|
|
<Tab title="Config File">
|
|
Add the following to `config.json`, then start CowAgent:
|
|
|
|
```json
|
|
{
|
|
"channel_type": "wecom_bot",
|
|
"wecom_bot_id": "YOUR_BOT_ID",
|
|
"wecom_bot_secret": "YOUR_SECRET"
|
|
}
|
|
```
|
|
|
|
| Parameter | Description |
|
|
| --- | --- |
|
|
| `wecom_bot_id` | Bot ID of the AI Bot |
|
|
| `wecom_bot_secret` | Secret of the AI Bot |
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
The log line `[WecomBot] Subscribe success` confirms the connection is established.
|
|
|
|
## 2. Supported features
|
|
|
|
| Feature | Status |
|
|
| --- | --- |
|
|
| Direct chat | ✅ |
|
|
| Group chat (@bot) | ✅ |
|
|
| Text messages | ✅ Send / Receive |
|
|
| Image messages | ✅ Send / Receive |
|
|
| File messages | ✅ Send / Receive |
|
|
| Streaming replies | ✅ |
|
|
| Scheduled push messages | ✅ |
|
|
|
|
## 3. Usage
|
|
|
|
Search for the bot's name inside WeCom to start a direct chat.
|
|
|
|
To use the bot in an internal group chat, add it to the group and @-mention it.
|
|
|
|
<img src="https://cdn.link-ai.tech/doc/20260316182902.png" width="800"/>
|