๐คฏ LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
---
title: Connect LobeHub to WeCom
description: >-
Learn how to create a WeCom AI bot in API mode and connect it to your LobeHub
agent over its long connection, so colleagues can chat with your AI assistant
in direct chats and by @-mentioning it in internal group chats.
tags:
- WeCom
- Message Channels
- Bot Setup
- Integration
---
# 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
<Steps>
### Open the admin console
Go to the [WeCom admin console](https://work.weixin.qq.com/wework_admin/frame) 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.
</Steps>
## Step 2: Configure it in LobeHub
<Steps>
### 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.
</Steps>
## 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](/docs/usage/channels/overview#direct-message-policy). 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.