Connect LobeHub to WeCom
Once a WeCom (企业微信) AI bot is connected to your LobeHub agent, colleagues can talk to the AI assistant in a WeCom direct chat, or @-mention the bot in an internal group chat.
LobeHub uses the AI bot's API mode with a long connection: LobeHub connects out to WeCom, so no public IP, callback URL, or ICP-filed domain is needed.
Availability: a WeCom bot can only reply over its own long connection, so whoever holds that connection must also send the replies. On LobeHub Cloud this is handled for you. When self-hosting, WeCom works on a single long-running LobeHub server process (for example a single-instance Docker deployment); serverless deployments (such as Vercel) do not show WeCom, and multi-replica deployments make the replicas knock the same bot offline in turn, so they are not supported either.
Prerequisites
- A WeCom organization, and either an admin account or an admin who can grant you permission to create long-connection bots
- An unverified organization can have at most 100 members; WeCom's docs do not say whether an unverified organization can create AI bots
Step 1: Create an AI bot
Open the admin console
Go to the WeCom admin console and sign in.
Get permission to create long-connection bots
Admins can skip this. By default only admins can create AI bots that use a long connection; other members need an admin to grant them access under Smart Zone → AI Bots → Permissions → API Mode Management, and to add them to Bot Creation Permission on the same page if the organization restricts it (it is open to all members by default).
Create a bot in API mode
Go to Smart Zone → AI Bots and click Create (members can also use Workbench → AI Bots in the WeCom app), then choose to create it in API mode.
Choose long connection and set the visible range
On the API settings page, set the connection method to Use long connection, then set the bot's visible range: only members in it can find and use the bot. Leave the rest as is.
Copy the BotID and Secret
The page generates the BotID and Secret. Copy both and keep the Secret somewhere safe before you save the bot settings.
Important: a bot can have only one long connection at a time. Connecting the same bot anywhere else (another deployment, a local dev environment, another tool) disconnects it from LobeHub.
Step 2: Configure it in LobeHub
Open channel settings
In LobeHub, open your agent's settings, select the Channels tab, and click WeCom.
Enter the credentials
- BotID — the BotID from Step 1
- Secret — the long-connection Secret from Step 1
Save and connect
Click Save Configuration. LobeHub opens the long connection with the BotID and Secret; once the status shows connected, the bot is ready.
Step 3: Test it
- Direct chat: members in the visible range find the bot under AI Bots in WeCom Contacts and send it a message. The bot shows a reply-in-progress bubble first, then fills in the answer.
- Group chat: in an internal group chat, open the top-right corner → Add members → AI Bots to add the bot, then @-mention it. External, interconnected, and upstream/downstream groups do not support bots.
Access policies
As with other channels, the DM policy, group policy, and allowed user IDs decide which messages the bot accepts; see the channel overview. User and group IDs are the userid and chatid from WeCom messages. When the bot's creator is not a super admin, userid is an encrypted open_userid.
Configuration reference
| Field | Required | Description |
|---|---|---|
| BotID | Yes | BotID of the AI bot (API mode) |
| Secret | Yes | The bot's long-connection Secret |
| Character limit | No | Maximum characters per reply; 6000 by default and at most |
| DM policy / Group policy | No | Who may DM the bot and which groups it answers in |
Limitations
- Text only in groups — when the bot is @-mentioned in a group, WeCom only delivers text, mixed, and quoted messages.
- No topics or threads — each group is one conversation.
- No editing, recalling, or reactions — the bot's messages cannot be changed.
- No attachments in replies yet — this version replies with text.
- Reply window — a message can be answered within 24 hours; a streamed reply must finish within 10 minutes, after which the result is pushed as a new message.
Troubleshooting
- Status failed: taken over by another connection — the same BotID opened a long connection elsewhere. Stop the other one, then save or reconnect in LobeHub.
- Invalid credentials when saving — check that the BotID and Secret belong to the same bot and that the bot is in API mode.