@xpert-ai/plugin-wecom provides two integration types:
Default recommendation: use WeCom long connection (
wecom_long). Use WeCom short connection (wecom) only when you already have a stable public callback URL or need to stay compatible with a short-connection deployment. A WeCom bot usually selects only one receiving mode in the WeCom console.
1. Short-connection setup
Short connection receives messages through WeCom callbacks. WeCom sends URL verification and message push requests to Xpert AI Callback URL.Prepare WeCom configuration
- Log in to WeCom Admin Console.
- Open the target app or API-mode bot configuration page.
- Enable message receiving or API callback.
- Record or generate:
- Token
- EncodingAESKey
- Confirm Xpert AI API has a public HTTPS address reachable from WeCom.
Create short-connection integration in Xpert AI
Go to Settings -> System Integrations and create a WeCom short connection integration.
After saving or testing, Xpert AI returns a callback URL:
msg_signature, timestamp, nonce, and echostr with the integration Token and EncodingAESKey.
Short-connection route check
To only confirm route reachability, visit:success, meaning the Xpert API route and integration ID can be read. Official URL verification still depends on WeCom signature parameters.
2. Long-connection setup
Long connection uses WeCom smart bot API mode. Xpert AI connects outbound to WeCom WebSocket, so no public Callback URL is required. WeCom long-connection endpoint:Prepare a WeCom bot
- Log in to the WeCom admin console.
- Go to Security and Management -> Management Tools -> Smart Bot.
- Create a bot in API mode and select Long Connection.
- Record:
- Bot ID
- Secret
- Confirm the Xpert AI server can access
wss://openws.work.weixin.qq.com.
Create long-connection integration in Xpert AI
Go to Settings -> System Integrations and create a WeCom long connection integration.
After saving a long-connection integration, the plugin tries to synchronize connection state. The long connection keeps running only when the integration is enabled, config is valid, and it is bound to a published WeCom Trigger. When unbound, the system stops the connection and marks it as
xpert_unbound.
3. Bind a Digital Expert
Saving an integration does not make the bot usable by itself. You also need to:- Open the target Digital Expert workflow.
- Add WeCom Trigger.
- Select the WeCom integration you created.
- Configure session timeout and message aggregation.
- Publish the Digital Expert workflow.
4. Status and session management
The WeCom integration detail page provides extension tabs:- Status: shown for long-connection integrations, including connection mode, status, Bot ID, owner instance, recent connected/disconnected/callback/heartbeat times, recent error, reconnect count, and stop reason.
- Sessions: shown for both modes, including conversation type, conversation ID, sender ID, Digital Expert ID, conversation ID, and update time.
/new.
5. Message and reply capabilities
Short-connection mode mainly relies onresponse_url from WeCom callbacks. Long-connection mode mainly relies on req_id and WebSocket command replies.
Long-connection mode supports a richer bot experience:
- Send a “thinking” message after receiving a user message.
- Prefer long-connection streaming replies for long answers.
- Update template cards.
- Send welcome cards when users enter direct chat.
- Send reset-session cards when a conversation fails or needs reset.
- Download image callback resources and pass them to the Digital Expert as visible file inputs.
FAQ
WeCom says the integration is not bound to a trigger
The WeCom message has reached Xpert AI, but nointegrationId -> xpertId binding was found. Confirm:
- The target Digital Expert has added WeCom Trigger.
- The trigger is enabled.
- The selected integration is the one actually used by the current bot.
- The Digital Expert workflow has been published.
Short-connection URL verification failed
Check:API_BASE_URLis a public HTTPS address reachable from WeCom.- The reverse proxy forwards
/api/wecom/webhook/<integrationId>. - The WeCom console Token matches the integration
Callback Token. - EncodingAESKey is exactly 43 characters and matches.
Long connection cannot be established
Check:- WeCom console selects API-mode long connection.
- You did not use short-connection Token/EncodingAESKey by mistake.
- Bot ID and Secret come from the same bot.
- The server can access
wss://openws.work.weixin.qq.com. - The integration is bound to a published WeCom Trigger.
Session context is unexpected
Ask users to send/new to start a new session, or reset a session from the integration detail page. If users often send several short messages in a row, increase summaryWindowSeconds in WeCom Trigger.