WeCom Integration
Connect a WeCom smart-bot to Mopheus. Chat with agents directly in WeCom, receive ticket updates back in WeCom chats.
The WeCom integration connects a WeCom smart-bot (aibot) to Mopheus via a WebSocket long-connection. Once configured, agents respond to WeCom messages in real time, and ticket status changes and comments are pushed back to the originating WeCom chat.
Connection Method Comparison
| Comparison | Group Bot | Self-built App | Smart Bot (URL Callback) | Smart Bot (WebSocket Long Connection) |
|---|---|---|---|---|
| Direct messages | Not supported | Supported | Supported | Supported |
| Group chats | Receives messages in groups the group bot has joined | Can create group chats and send messages to groups created by the app | Supports @-mention interaction in groups | Supports @-mention interaction in groups |
| Multiple groups | After the same bot joins multiple groups, it can send messages to those groups | The group must be created by the app | Can join groups for interaction | Can join groups for interaction |
| Public endpoint | No public callback URL is needed to receive group messages | A publicly reachable callback URL is required to receive messages; API calls also require a trusted IP | Requires a publicly reachable callback URL | No public callback URL is required; the deployment must be able to connect to WeCom's WebSocket service |
| Reply window | Suitable for group message delivery; does not provide direct-message interaction | Follows the app messaging API rules | response_url is valid for one hour and can be used once | Not subject to the one-hour URL callback response_url limit |
| Mopheus support | Group bot configuration and multi-group broadcast are not supported | Binding is supported; currently direct messages only | Not supported | QR-code or manual binding is supported |
The group-bot, multi-group, and smart-bot capabilities above describe WeCom. Mopheus support is listed in the final row. The one-hour URL callback limit is the validity period of response_url; it does not mean the bot must keep replying for one hour.
Setup
1. Smart Bot Setup
Connect by QR Code (Recommended)
- In Mopheus, open an agent or team detail page → Integrations → Connect WeCom Bot.
- Select Connect by QR Code, scan the displayed QR code in WeCom, then finish creation and authorization in WeCom.
- Once the scan succeeds, Mopheus receives the Bot ID and Secret server-side and stores them encrypted for the selected agent or team. Credentials are never returned to the browser.
The installation entry requires the current member to have the channel:bind permission. Installing a bot for another agent or a team also follows the workspace ownership rule.
Enter Credentials Manually
- Go to the WeCom Admin Console → Application Management → Smart Bot.
- Create a new smart bot. Note the Bot ID and Secret shown once at creation.
- In Mopheus, open an agent or team detail page → Integrations → Connect WeCom Bot, then select Enter Credentials Manually.
- Fill in the Bot ID and Secret. Optionally set a custom WebSocket URL (defaults to
wss://openws.work.weixin.qq.com).
2. Self-built App (Callback Mode)
- In the WeCom Admin Console, open Application Management and create an app. Open its details and note the AgentId and Secret.
- In Mopheus, open an agent or team detail page → Integrations → Connect WeCom Bot, then select Self-built App. Find the Corp ID at the bottom of My Enterprise in the WeCom Admin Console, then enter the Corp ID, Agent ID, and app Secret. Mopheus securely generates the callback Token and EncodingAESKey and stores them encrypted.
- After creating the integration, copy the displayed callback URL, Token, and EncodingAESKey. Return to the app details in WeCom, open Receive Messages, select Set API Receive, enter the copied values, and save. The callback URL is generated from the deployment's
APP_URLand the fixed path/wecom/callback/{installationId}; Next.js forwards requests to the Go API, so the public Web domain must be reachable andNEXT_PUBLIC_API_URLmust point to the backend. - WeCom API Base URL defaults to
https://qyapi.weixin.qq.com. Set the API base URL for a private deployment when needed. Mopheus obtains an access token withGET /cgi-bin/gettoken?corpid=<CorpID>&corpsecret=<Secret>, then sends messages withPOST /cgi-bin/message/send?access_token=<access_token>.
Self-built app outbound messages use WeCom's Markdown message type. Content retains the existing 20 KB overall channel limit; within that limit, content over 2048 bytes is split into multiple messages at UTF-8-safe boundaries, preferring line breaks. WeCom renders only a subset of Markdown syntax.
Inbound image, file, and video callbacks download their MediaId through the configured API base URL and attach the stored file to the channel message. Outbound sends to the same member are paced at least four seconds apart (900/hour maximum); WeCom 45009 rate-limit responses are retried by the outbound queue. The account-wide daily allowance depends on the enterprise's member-cap tier (cap × 200) and is not currently known to Mopheus, so configure the app's allowed send scope conservatively in WeCom.
This mode reads the member UserID from callback XML FromUserName and reuses Mopheus's existing WeCom identity binding and channel engine. The app Secret, callback Token, and EncodingAESKey are encrypted at rest.
3. Configure Mopheus
In Admin → System Config, set:
| Setting | Value |
|---|---|
Enable WeCom (wecom_enabled) | true |
WeCom Secret Key (wecom_secret_key) | A base64-encoded 32-byte AES key for encrypting stored bot secrets — generate via the Generate button in System Config |
After bot credentials are configured, do not edit the WeCom secret key through the generic config editor. Generate in System Config rotates the key and re-encrypts every existing WeCom binding in one transaction.
Before verifying the integration, configure the bot's visibility or available members and departments in the WeCom Admin Console. Connecting the bot does not automatically authorize every WeCom user. A sender outside the bot's available range may be rejected by WeCom before Mopheus receives the message.
4. Verify
Send any message to the bot in WeCom. On the first message, each WeCom sender receives a one-time Mopheus account binding link. Sign in and confirm the binding, then send the message again. The message is routed to the assigned agent, and the agent's reply is pushed back to the WeCom chat automatically.
The binding is per WeCom sender and per bot installation. The person who connected the bot must also complete this step when they first use the bot; WeCom does not provide Mopheus with the installer's WeCom user identity during installation.
WeCom bot availability and Mopheus account binding are separate requirements: each sender must be within the bot's available range and must complete the one-time Mopheus binding flow.
The integration section identifies the Mopheus workspace member who installed each bot binding.
How It Works
Inbound: WeCom → Mopheus
WeCom user sends message to smart-bot
│
▼
aibot_msg_callback over WebSocket
│
▼
Mopheus channel engine receives and routes message
│
▼
Session created → agent task enqueued
│
▼
Agent runs, produces reply
│
▼
Patcher sends reply back to WeCom chat via aibot_send_msgOutbound: Mopheus → WeCom
The Patcher component handles all outbound traffic via the shared WebSocket connection.
| Event | WeCom message sent |
|---|---|
| Agent reply ready | Markdown reply with agent name header |
| Agent task failed | Error card with failure detail |
| Ticket status changed | Status update with ticket reference |
| Comment added to ticket | Markdown preview with ticket reference and truncated body |
| Inbox notification | Markdown card sent to the user's 1:1 DM with the bot |
All outbound messages are sent as msgtype: markdown. Plain text renders correctly through the markdown path. Messages are rune-safe truncated to 4000 bytes.
Multi-Replica Constraint
The WeCom bot allows a single live WebSocket subscriber per bot. Mopheus enforces single-replica via the channel supervisor lease. If you scale Mopheus horizontally, set up Redis Streams relay (separate feature) before enabling the WeCom integration.
Message History
The smart-bot long connection receives only real-time events delivered to the bot. This integration does not pull ordinary group-chat history. WeCom conversation-content archiving is a separate compliance capability and is not part of smart-bot connection setup.
Troubleshooting
| Symptom | Check |
|---|---|
| Bot does not respond | Verify Enable WeCom (wecom_enabled) is true and the assigned agent is bound to an enabled, online runtime. A configured fallback runtime can also resume queued work. |
| "invalid bot_id or secret" in logs | The Bot ID or Secret entered during installation is incorrect — reconnect with correct credentials |
| No outbound notifications | Confirm the bot's WebSocket connection is active (check server logs for "wecom: subscribe ok") |
| No agent reply | Confirm the assigned agent is bound to an enabled, online runtime. A configured fallback runtime can also resume queued work. |
Feishu (Lark) Integration
Connect your Feishu workspace to Mopheus. Chat with agents directly in Feishu, receive ticket status and comment notifications back in Feishu chats.
DingTalk Integration
Connect a DingTalk Stream robot to Mopheus so people can work with agents and receive ticket updates in DingTalk.