tests Initial project commit 16 hours ago
LICENSE Initial project commit 16 hours ago
README.md Initial project commit 16 hours ago
crypto.js Initial project commit 16 hours ago
dynamic-agent.js Initial project commit 16 hours ago
image-processor.js Initial project commit 16 hours ago
index.js Initial project commit 16 hours ago
logger.js Initial project commit 16 hours ago
openclaw.plugin.json Initial project commit 16 hours ago
package.json Initial project commit 16 hours ago
stream-manager.js Initial project commit 16 hours ago
utils.js Initial project commit 16 hours ago
webhook.js Initial project commit 16 hours ago
wecom-api.js Initial project commit 16 hours ago
wecom-message-processor.js Initial project commit 16 hours ago
README.md

OpenClaw WeCom Plugin (Bone Version - Multi-App Support)

This is a basic, locally developed OpenClaw plugin for Enterprise WeChat (WeCom). It supports concurrent integration with multiple WeCom applications, including both Intelligent Robot and Self-Built Apps. It handles core message parsing, basic AI integration, and appropriate responses (streaming JSON or passive XML).

Key Features

  • Concurrent Multi-App Support: Integrate multiple WeCom Intelligent Bots and Self-Built Apps simultaneously.
  • Dual Mode Per-App: Each configured application can operate as either an Intelligent Bot (JSON streaming) or a Self-Built App (XML passive replies).
  • Message Parsing: Decrypts and parses incoming messages in both JSON (AI Bot) and XML (Self-Built App) formats, dynamically detected per application.
  • Basic AI Integration: Routes parsed messages to OpenClaw's AI core for processing.
  • Flexible Replies: Generates streaming JSON responses for AI Bots or passive XML replies for Self-Built Apps.
  • Security: Utilizes WeCom's message encryption/decryption, dynamically validates the CorpID from inbound messages for Self-Built Apps, for secure communication.
  • Unique Webhook Paths: Each application can be configured with its own dedicated webhook URL for clear separation.

Prerequisites

  • OpenClaw installed (version 2026.1.30+)
  • Enterprise WeChat admin access to configure Intelligent Robot or Self-Built applications.
  • A public-facing server address accessible from Enterprise WeChat (HTTP/HTTPS) for webhooks, with unique paths for each application.

Installation

To install this plugin locally:

  1. Copy the plugin directory to your OpenClaw extensions folder:

     cp -r /mnt/codeserver/project/WeComCompanyPlugin ~/.openclaw/extensions/
  2. Enable the plugin and configure applications in openclaw.json:

    Add or modify the channels.wecom section in your OpenClaw configuration file (~/.openclaw/openclaw.json). You will define an array of applications, where each object configures a distinct WeCom integration.

     {
       "plugins": {
         "entries": {
           "WeComCompanyPlugin": {  // This key MUST match your plugin folder name
             "enabled": true
           }
           // ... other plugins if any
         }
       },
       "channels": {
         "wecom": {
           "enabled": true,
           "applications": [
             {
               "id": "my_ai_bot", // Unique ID for your AI Bot application
               "enabled": true,
               "token": "YOUR_AI_BOT_TOKEN",
               "encodingAesKey": "YOUR_AI_BOT_ENCODING_AES_KEY",
               "isSelfBuiltApp": false, // Set to false for AI Bot
               "webhookPath": "/webhooks/wecom/ai_bot" // Unique URL path for this bot
             },
             {
               "id": "my_self_built_app", // Unique ID for your Self-Built App application
               "enabled": true,
               "token": "YOUR_SELF_BUILT_TOKEN",
               "encodingAesKey": "YOUR_SELF_BUILT_ENCODING_AES_KEY",
               "isSelfBuiltApp": true, // Set to true for Self-Built App
               "webhookPath": "/webhooks/wecom/self_built" // Unique URL path for this app
             }
           ]
         }
       }
     }

    Replace placeholder values with your actual WeCom application details. Ensure webhookPath is unique for each application. If webhookPath is omitted, it defaults to /webhooks/wecom/<application_id>.

  3. Restart OpenClaw for the changes to take effect.

     openclaw gateway restart

Configuration Options

Under channels.wecom.applications (an array of objects):

Option Type Required Description
id string Yes A unique identifier for this WeCom application within your OpenClaw configuration.
enabled boolean No Set to true to enable this specific WeCom application. Default: true.
token string Yes The WeCom bot Token obtained from the application's admin console.
encodingAesKey string Yes The WeCom message encryption key (43 characters) from the application's admin console.
isSelfBuiltApp boolean No Crucial: Set to true if this application is a Self-Built App (uses XML, passive replies). Set to false for an Intelligent Bot (uses JSON, streaming replies). Default: false.
webhookPath string No The unique URL path where this application's messages will be received by OpenClaw. If not specified, it defaults to /webhooks/wecom/<application_id>.

Enterprise WeChat Configuration

Follow these steps in the Enterprise WeChat Admin Console for each application you configure:

For Intelligent Robot (AI Bot) Integrations

  1. Log in to the Admin Console.
  2. Navigate to "Application Management" > "Applications" > "Create Application" > Select "Intelligent Robot".
  3. Configure "Receive Messages":
    • URL: Use the webhookPath configured for this AI Bot in openclaw.json (e.g., https://your-domain.com/webhooks/wecom/ai_bot). Ensure this URL is publicly accessible.
    • Token: Match the token specified for this AI Bot in openclaw.json.
    • EncodingAESKey: Match the encodingAesKey specified for this AI Bot in openclaw.json.
  4. Save and enable message receiving.

For Self-Built App Integrations

  1. Log in to the Admin Console.
  2. Navigate to "Application Management" > "Applications" > Select your existing Self-Built App or create a new one.
  3. Configure "Receive Messages":
    • URL: Use the webhookPath configured for this Self-Built App in openclaw.json (e.g., https://your-domain.com/webhooks/wecom/self_built). Ensure this URL is publicly accessible.
    • Token: Match the token specified for this Self-Built App in openclaw.json.
    • EncodingAESKey: Match the encodingAesKey specified for this Self-Built App in openclaw.json.
  4. Save and enable message receiving.

Important: For Self-Built Apps, ensure isSelfBuiltApp is set to true in your openclaw.json configuration for that specific application.

FAQ

Q: How does inbound message decryption and parsing work for multiple applications (AI Bot JSON and Self-Built App XML)?

A: The plugin dynamically identifies the target application based on the incoming webhook URL. For each request, it:

  1. Uses the token, encodingAesKey, and optionally corpId associated with the identified application.
  2. Automatically detects if the incoming message body is JSON (for AI Bots) or XML (for Self-Built Apps).
  3. Extracts and decrypts the message content from the respective format.
  4. For Self-Built Apps, it extracts the CorpID from the decrypted inbound message and uses it for constructing secure passive replies.
  5. Parses the decrypted content (JSON or XML) into a normalized message object for consistent processing by the AI.

Q: How does outbound image sending work?

A: The plugin automatically handles images generated by OpenClaw (such as browser screenshots):

  • For AI Bot (streaming JSON): Local images (from ~/.openclaw/media/) are automatically encoded to base64 and sent via WeCom's msg_item API. Images appear when the AI completes its response.
  • For Self-Built App (passive XML): Direct passive XML replies do not support sending images from local paths. If the AI generates an image, its local path will be converted into a text description within the passive XML text reply.

Project Structure

WeComCompanyPlugin/
├── index.js              # Plugin entry point (main plugin logic and HTTP handler, multi-app routing)
├── wecom-message-processor.js # Core logic for message processing and dispatching
├── webhook.js            # WeCom HTTP communication handler, message/event parser (JSON/XML), and reply builder
├── crypto.js             # WeCom encryption algorithms (message + media)
├── logger.js             # Logging module
├── stream-manager.js     # Streaming response manager (for AI Bot mode)
├── utils.js              # Utility functions (TTL cache, deduplication)
├── package.json          # npm package config
└── openclaw.plugin.json  # OpenClaw plugin manifest