← Back to PRs

#14009: feat(wecom): add wecom(企业微信) channel extension

by xl370869-art open 2026-02-11 09:27 View on GitHub →
docs agents stale
## Summary This PR adds a new channel extension for WeCom (企业微信), enabling OpenClaw to connect with Tencent's enterprise communication platform. The plugin features a unique **Bot + Agent dual-mode architecture** — Bot handles real-time streaming conversations while Agent provides enterprise-grade capabilities like file delivery, proactive push, and scheduled broadcasts. The two modes work in tandem with intelligent fallback. Co-built with Tencent Cloud contributors. ## Motivation WeCom (企业微信) is Tencent's enterprise communication and collaboration platform, widely adopted across Chinese businesses and organizations. This integration expands OpenClaw's reach to enterprise users who rely on WeCom for daily communication and collaboration. ## Why dual-mode instead of single-mode Traditional WeCom integrations force a choice between a "chat-only Bot" and a "push-only Agent app". This plugin runs both in parallel: - **Bot channel (智能体)**: Real-time streaming responses (typing effect), group chat @reply - **Agent channel (自建应用)**: File delivery, proactive push to users/departments/tags, scheduled broadcasts via Cronjob When Bot hits its limits (e.g. non-image file sending, 6-minute stream timeout), the plugin seamlessly falls back to Agent — no message lost. ## Features - Bot + Agent dual-mode parallel architecture with "Bot-first, Agent-fallback" strategy - Native streaming responses (typing effect) via Bot channel - Full multi-modal support: receive text, image, voice, video, file; send text, image, Markdown, file - 6-minute timeout relay: auto-switch from Bot stream to Agent DM for long-running tasks - Group chat file fallback: Bot notifies in group, Agent delivers file via DM - Agent proactive messaging: push to users, departments (Party), tags (Tag) - Cronjob integration for scheduled broadcasts (`openclaw cron`) - AccessToken auto-management with caching, pre-refresh, and retry - XML encryption/decryption for secure callback handling - Interactive onboarding flow for bot configuration - Egress proxy support (`egressProxyUrl`) for dynamic IP / NAT environments - Allowlist-based DM security with configurable policy (open/disabled/allowlist) - Dynamic Agent routing: per-user/group isolated Agent instances - OpenClaw command support (/new, /compact, /models, etc.) - Media upload/download pipeline (default 25MB limit, configurable) ## Changes - `extensions/wecom/`: Complete WeCom channel implementation (~80 files, ~6,000+ lines) - `src/channel.ts`: Core channel plugin with capabilities declaration, outbound messaging - `src/monitor.ts`: Bot stream listener with state management, timeout relay, message dedup - `src/agent/`: Agent API client (OAuth2 auth, message send/reply, media upload/download) and handler - `src/crypto/`: WeCom XML encryption/decryption (AES, signature verification) - `src/onboarding.ts`: Interactive configuration wizard - `src/dynamic-agent.ts`: Per-user/group dynamic Agent routing - `src/media.ts`, `src/outbound.ts`, `src/target.ts`, `src/accounts.ts`: Supporting modules - `src/shared/`: XML parser, command auth utilities - Tests: `*.test.ts` files with unit and integration tests - `docs/channels/wecom.md`: Documentation with step-by-step setup guide (Bot + Agent + dual-mode) - `docs/images/wecom-*`: 18 screenshots for configuration walkthrough ## Testing - [x] Tested locally on real OpenClaw instance - [x] Ran `pnpm build && pnpm check && pnpm test` - [x] Verified Bot streaming responses with real WeCom bot - [x] Verified Agent message sending (text, image, file) with real WeCom app - [x] Verified dual-mode fallback: file delivery via Agent when Bot cannot handle - [x] Verified 6-minute timeout relay from Bot to Agent - [x] Verified egress proxy configuration for dynamic IP environments - [x] Verified Cronjob scheduled push to departments and tags ## AI Assistance Disclosure Parts of this code were developed with AI assistance. The code has been: - Fully tested with real WeCom bot and agent instances - Reviewed and understood completely - Iteratively refined based on real-world usage feedback We are committed to long-term maintenance of this extension and would be happy to address any feedback or requested changes. ## Related - Issue: #14008 - Maintainer: YanHaidao (VX: YanHaidao) - Co-built with Tencent Cloud contributors <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a new `extensions/wecom` channel plugin implementing a dual-mode WeCom integration (Bot webhooks for streaming/passive replies + Agent app for proactive messaging/media delivery), along with docs in both English and zh-CN. Main implementation is centered around `extensions/wecom/src/monitor.ts` (webhook handling, stream state, debounce/dedupe, and Bot→Agent fallback) and `extensions/wecom/src/outbound.ts` (Agent-based outbound adapter). <h3>Confidence Score: 3/5</h3> - Reasonably close, but needs fixes before merge - The core feature addition is substantial and appears coherent, but there is at least one build-breaking dependency issue (`axios` import without a declared dependency) and a large amount of direct `console.*` logging that should be aligned with the runtime logger before merging. - extensions/wecom/src/monitor.ts, extensions/wecom/src/outbound.ts, extensions/wecom/src/agent/api-client.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs