WeCom OpenClaw Integration
๐ค Connect your AI agent to WeCom (ไผไธๅพฎไฟก)
Send messages via WeCom โ AI processes โ Control your computer remotely
Created by LiuJinQi (11haonb) @ Beijing Institute of Technology
๐ Docs โข
Quick Start โข
Features โข
Browser Control โข
ไธญๆๆๆกฃ
---
## ๐ What is this?
This plugin connects [OpenClaw](https://github.com/openclaw/openclaw) AI agent to **WeCom (ไผไธๅพฎไฟก/WeChat Work)**.
| ๐ฌ |
Chat with AI Send messages via WeCom, get AI-powered responses |
| ๐ฅ๏ธ |
Remote Browser Control Control your PC's browser from your phone |
| ๐ |
Rich Media Send/receive images, voice, video, files |
| ๐ง |
Tool Calling AI can execute tasks with 100+ built-in tools |
---
## โก Quick Start
### 1๏ธโฃ Get WeCom Credentials
| Field | Where to Find |
|:------|:--------------|
| **Corp ID** | WeCom Admin โ My Enterprise โ Enterprise ID |
| **Agent ID** | App Management โ Your App โ Agent ID |
| **Secret** | App Management โ Your App โ Secret |
| **Token** | Your App โ Receive Messages โ Generate |
| **AES Key** | Your App โ Receive Messages โ Generate |
### 2๏ธโฃ Configure OpenClaw
Create `~/.openclaw/openclaw.json`:
```json
{
"env": {
"WECOM_CORP_ID": "ww1234567890abcdef",
"WECOM_CORP_SECRET": "your-app-secret",
"WECOM_AGENT_ID": "1000001",
"WECOM_CALLBACK_TOKEN": "your-token",
"WECOM_CALLBACK_AES_KEY": "your-43-character-aes-key"
},
"plugins": {
"entries": {
"wecom": { "enabled": true }
}
}
}
```
### 3๏ธโฃ Start Gateway
```bash
cd /path/to/openclaw
pnpm build && node dist/entry.js gateway
```
### 4๏ธโฃ Set Callback URL
In WeCom Admin โ Your App โ Receive Messages:
```
URL: http://YOUR_SERVER:18789/wecom/callback
```
### 5๏ธโฃ Test It! ๐
Open WeCom app โ Find your app โ Send "Hello"!
---
## โจ Features
| Category |
Feature |
Status |
| ๐จ Messaging |
Text messages |
โ
|
| Image messages |
โ
|
| Voice messages |
โ
|
| Video messages |
โ
|
| File messages |
โ
|
| Message cards |
โ
|
| ๐ฅ Group Chat |
Group messages |
โ
|
| @mention detection |
โ
|
| Access control |
โ
|
| ๐ฅ๏ธ Browser |
Remote control |
โ
|
| Screenshot capture |
โ
|
| โ๏ธ Advanced |
Multi-account |
โ
|
| Event handling |
โ
|
| Mini programs |
โ
|
---
## ๐ฅ๏ธ Remote Browser Control
**Control your computer's browser from your phone!**
```
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ ๐ฑ Phone โ โ ๐ฅ๏ธ Server โ โ ๐ป Your PC โ
โ WeCom โ โโโโถ โ OpenClaw โ โโโโถ โ Browser โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
```
### Setup
1. Configure Server
Add to `~/.openclaw/openclaw.json`:
```json
{
"browser": { "enabled": true },
"gateway": {
"nodes": {
"browser": { "mode": "auto" }
}
}
}
```
2. Install and Run Node Host on Your PC
```bash
# Install OpenClaw
npm install -g openclaw
# Connect to your server
openclaw node run --host YOUR_SERVER_IP --port 18789
```
3. Send Commands via WeCom
| Command | Action |
|:--------|:-------|
| `ๆๅผๆต่งๅจ่ฎฟ้ฎๆทๅฎ` | Open browser, go to taobao.com |
| `ๆ็ดข iPhone 16` | Search on current page |
| `ๆชๅพ` | Take screenshot |
| `็นๅป็ฌฌไธไธชๅๅ` | Click first product |
๐ **[Full Browser Control Guide โ](./docs/BROWSER_CONTROL.md)**
---
## โ๏ธ Configuration
### Environment Variables
| Variable | Required | Description |
|:---------|:--------:|:------------|
| `WECOM_CORP_ID` | โ
| Enterprise ID |
| `WECOM_CORP_SECRET` | โ
| App secret |
| `WECOM_AGENT_ID` | โ
| App agent ID |
| `WECOM_CALLBACK_TOKEN` | โ
| Callback token |
| `WECOM_CALLBACK_AES_KEY` | โ
| 43-char AES key |
| `WECOM_BOT_NAME` | | Bot name for @mention |
| `WECOM_WELCOME_MESSAGE` | | Auto-reply for new users |
### Full Example
Click to expand
```json
{
"env": {
"OPENROUTER_API_KEY": "sk-or-xxx",
"WECOM_CORP_ID": "ww1234567890",
"WECOM_CORP_SECRET": "your-secret",
"WECOM_AGENT_ID": "1000001",
"WECOM_CALLBACK_TOKEN": "your-token",
"WECOM_CALLBACK_AES_KEY": "your-43-char-key",
"WECOM_BOT_NAME": "AIๅฉๆ",
"WECOM_WELCOME_MESSAGE": "ไฝ ๅฅฝ๏ผๆๆฏAIๅฉๆ๏ผๆไปไนๅฏไปฅๅธฎไฝ ็๏ผ"
},
"agents": {
"defaults": {
"model": {
"primary": "openrouter/qwen/qwen3-max"
}
}
},
"browser": {
"enabled": true
},
"gateway": {
"mode": "local",
"bind": "lan",
"nodes": {
"browser": { "mode": "auto" }
}
},
"plugins": {
"entries": {
"wecom": { "enabled": true }
}
}
}
```
---
## ๐ฅ Group Chat
| Mode | Behavior |
|:-----|:---------|
| **Private Chat** | Bot responds to all messages |
| **Group Chat** | Bot only responds when @mentioned |
Configure @mention names:
```bash
WECOM_BOT_NAME=ๅฐๅฉๆ
WECOM_BOT_ALIASES=AI,ๆบๅจไบบ,ๅฉๆ
```
---
## ๐ API Reference
WeComApiClient
```typescript
import { WeComApiClient } from "wecom-openclaw-integration";
const client = new WeComApiClient({
corpId: "your-corp-id",
corpSecret: "your-secret",
agentId: 1000001,
});
// Send text
await client.sendText("userid", "Hello!");
// Send image
await client.sendImageFromUrl("userid", "https://example.com/image.jpg");
// Send file
await client.sendFileFile("userid", "/path/to/file.pdf");
// Send card
await client.sendTextCard("userid", {
title: "Card Title",
description: "Description",
url: "https://example.com",
});
```
Event Handling
```typescript
import { onEvent, setWelcomeMessage } from "wecom-openclaw-integration";
// Welcome new users
setWelcomeMessage("Welcome! How can I help?");
// Handle events
onEvent("subscribe", async (event, config) => {
console.log(`New user: ${event.fromUserName}`);
});
onEvent("click", async (event, config) => {
// Handle menu clicks
});
```
Mini Programs
```typescript
import { createMiniProgramClient } from "wecom-openclaw-integration";
const mpClient = createMiniProgramClient(client);
await mpClient.sendSimpleMiniProgramCard("userid", {
appid: "wx123456",
pagepath: "/pages/index",
title: "Open Mini Program",
});
```
---
## ๐ค Recommended Models
| Region | Model | Notes |
|:-------|:------|:------|
| ๐จ๐ณ China | `openrouter/qwen/qwen3-max` | โญ Recommended, no proxy |
| ๐จ๐ณ China | `openrouter/deepseek/deepseek-chat` | Fast, cheap |
| ๐ Global | `openrouter/anthropic/claude-sonnet-4` | Best quality |
| ๐ Global | `openrouter/openai/gpt-4o` | Good balance |
**Using proxy:**
```bash
HTTPS_PROXY=http://127.0.0.1:7890 node dist/entry.js gateway
```
---
## ๐ Project Structure
```
wecom-openclaw-integration/
โโโ ๐ index.ts # Plugin entry point
โโโ ๐ src/
โ โโโ api.ts # WeCom API client
โ โโโ crypto.ts # AES encryption
โ โโโ parser.ts # XML parser
โ โโโ monitor.ts # Webhook handler
โ โโโ channel.ts # Channel definition
โ โโโ types.ts # TypeScript types
โ โโโ group-policy.ts # Group chat rules
โ โโโ mention.ts # @mention detection
โ โโโ multi-account.ts # Multi-account support
โ โโโ events.ts # Event handlers
โ โโโ miniprogram.ts # Mini program support
โโโ ๐ docs/
โ โโโ QUICKSTART_CN.md # ไธญๆๅฟซ้ๅ
ฅ้จ
โ โโโ BROWSER_CONTROL.md # Browser control guide
โโโ ๐ test/ # Test files
โโโ ๐ CHANGELOG.md # Version history
โโโ ๐ README.md # This file
```
---
## ๐ Documentation
| Document | Description |
|:---------|:------------|
| [Quick Start (English)](./docs/QUICKSTART_EN.md) | 5-minute setup guide |
| [Quick Start (ไธญๆ)](./docs/QUICKSTART_CN.md) | 5 ๅ้ๅฟซ้ๅ
ฅ้จ |
| [Remote Control (English)](./docs/REMOTE_CONTROL_EN.md) | Control Windows PC remotely |
| [Remote Control (ไธญๆ)](./docs/REMOTE_CONTROL_CN.md) | ่ฟ็จๆงๅถ Windows ็ต่ |
| [Changelog](./CHANGELOG.md) | Version history |
---
## ๐ Troubleshooting
Callback URL verification failed
- โ
Check Token and AES Key match exactly
- โ
Ensure server is accessible from internet
- โ
Check firewall allows port 18789
Messages not received
- โ
Verify callback URL in WeCom admin
- โ
Check logs: `tail -f /tmp/gateway.log`
- โ
Ensure plugin is enabled
Browser control not working
- โ
Verify Node Host is connected
- โ
Check `browser.enabled: true`
- โ
Check `gateway.nodes.browser.mode: "auto"`
---
## ๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
---
## โจ Contributors
---
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
---
## ๐ Links
OpenClaw โข
WeCom Developer Docs
---
Made with โค๏ธ by liujinqi @ Beijing Institute of Technology