WeCom Logo    WeChat Logo

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

Documentation

License Node Version TypeScript WeCom

๐Ÿ“š 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

zhzy0077 WeiluMo BIT-SZZ

--- ## ๐Ÿ“„ 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