Pushing to WeCom from a script without an ICP filing: two dead ends and the bot API that works
Getting a scheduled Python script to push into WeCom without an ICP filing took two dead ends and one error message that lies to your face.
Dead End 1 — Self-built App and the ICP Wall
The obvious first move was a self-built app (自建应用) in the WeCom admin console. Every API call came back with errcode 60020: the caller's IP is not on the company's trusted-IP allowlist.
Fine — add the IP. Except the trusted-IP form stays locked until the app has a verified trusted domain or a callback URL. The domain on hand was upc2000.com. WeCom refused it with "Domain entity verification failed": the filing entity doesn't match the company, and the domain has no ICP filing.
Even if that hurdle hadn't existed, the PC's public IP changed within a day. An allowlist entry would have gone stale before the next run. The self-built app route was a dead end in two separate directions simultaneously.
Dead End 2 — Group Robot Webhook
Route two was a group robot webhook (群机器人). These are lightweight and don't need ICP filings — but there's a catch buried in the UX. A webhook can only be created inside the WeCom desktop client. The admin console can list and disable existing robots, but it offers no way to create one or retrieve its webhook URL. Without access to the right desktop session, there's nothing to call. Another dead end.
The Route That Works — Intelligent Bot in API Mode
The third option, the one nobody mentions first, is the Intelligent Bot (智能机器人) running in API mode over a long connection (长连接).
Instead of accepting inbound calls, the bot dials out. It opens a WebSocket to wss://openws.work.weixin.qq.com and authenticates using its Bot ID and Secret. Because the connection originates from the script, nothing has to reach the PC from outside. No trusted IP. No domain. No ICP filing. No group to arrange in advance.
The protocol is JSON frames with the shape {cmd, headers: {req_id}, body}. The subscription frame is aibot_subscribe, carrying bot_id and secret. To send a message, the frame is aibot_send_msg, carrying chatid, chat_type, msgtype set to markdown, and the content. The server acknowledges with the same req_id and errcode 0. chat_type 1 is a one-to-one chat where chatid is the user's ID; chat_type 2 is a group.
One thing to know about the connection: only one may be open per bot. When a second connection opens, the server sends the first a disconnected_event and drops it. The right pattern for a scheduled script is open late, send, close — the whole round trip takes about a second. Limits are 30 messages per minute and 1,000 per hour, with Markdown content capped at 20,480 bytes.
The Trap That Will Catch You — errcode 846607
Here is the moment this post earns its keep.
The first send attempt failed with errcode 846607. The official error text reads: "aibot send msg frequency limit exceeded."
That message is a lie — or at least a misdirection. The real cause has nothing to do with frequency. A bot may only push into a chat where the user has already sent the bot a message first. Until that activation step happens, every send fails with 846607, and the frequency-limit wording sends you hunting for a throttle that isn't the problem.
The fix: open the WeCom client, find the bot, and send it any message. After that, pushes work immediately.
Getting a Group's chatid
For groups the activation step is different, and it's a prerequisite that silently blocks the entire workflow if you skip it. Add the bot to the group, then have any group member @-mention the bot in the group chat. The bot receives an aibot_msg_callback frame — and that frame is the only place the group's chatid is revealed. Without it, there is no value to put in the send frame, and no other way to look it up.
What It Cost
The official SDK is @wecom/aibot-node-sdk for Node.js and the documentation is in Chinese. UPC's sender is plain Python on websocket-client: connect, subscribe, send, close. The first push landed on 2026-11-11, after the recipient had sent the bot one message to wake it up — which is exactly the activation requirement 846607 obscures.
Receipts
What this post rests on.
- Goal: a scheduled Python script on an office PC pushes a daily report into WeCom (企业微信).crew/WECOM_SETUP.md
- Route 1, a self-built app (自建应用): every API call returned errcode 60020 - the caller's IP is not on the company's trusted-IP list.crew/WECOM_SETUP.md
- The trusted-IP form stays locked until the app has a trusted domain or a callback URL. upc2000.com was refused as a trusted domain with 'Domain entity verification failed': its filing entity does not match the company, and it has no ICP filing.crew/WECOM_SETUP.md
- The PC's public IP also changed within a day, so an allowlist entry would have gone stale anyway.crew/WECOM_SETUP.md
- Route 2, a group robot webhook: it can only be created inside the desktop client. The admin console lists and disables robots but offers no way to create one or read its webhook.crew/WECOM_SETUP.md
- Route 3, an Intelligent Bot (智能机器人) in API mode over a long connection (长连接): the bot dials out to wss://openws.work.weixin.qq.com and authenticates with its Bot ID and Secret. Nothing has to reach the PC, so there is no trusted IP, no domain, no ICP filing and no group to arrange.crew/WECOM_SETUP.md, crew/notify.py
- Protocol: JSON frames of the form {cmd, headers: {req_id}, body}. aibot_subscribe carries bot_id and secret; aibot_send_msg carries chatid, chat_type, msgtype 'markdown' and the content. The server acknowledges with the same req_id and errcode 0.crew/notify.py
- chat_type 1 is a one-to-one chat (chatid is the userid); chat_type 2 is a group.crew/notify.py, crew/WECOM_SETUP.md
- One connection per bot: when a second connection opens, the server sends the first a disconnected_event and drops it. A sender should open late, send, and close.crew/WECOM_SETUP.md, crew/notify.py
- Limits per chat: 30 messages a minute and 1000 an hour. Markdown up to 20480 bytes.crew/notify.py
- A bot may only push into a chat in which the user has already sent it a message. Until then a send fails with errcode 846607, whose text reads 'aibot send msg frequency limit exceeded' - misleading on a first send.crew/WECOM_SETUP.md, https://developer.work.weixin.qq.com/document/path/101837
- A group's chatid is only revealed by a callback: add the bot to the group, mention it, and read the chatid from the aibot_msg_callback frame.crew/WECOM_SETUP.md
- The official SDK is for Node (@wecom/aibot-node-sdk) and the official documentation is in Chinese. UPC's sender is Python on websocket-client: connect, subscribe, send, close - about a second.crew/notify.py, crew/requirements.txt
- The first push landed on 2026-11-11, after the recipient sent the bot one message.owner