WeChat (微信)
Connect your GolemBot assistant to personal WeChat using the iLink Bot API. No public IP required. No SDK dependency.
Zero dependencies
Unlike other channels, the WeChat adapter uses only the built-in fetch API to communicate with the iLink Bot service. No npm packages to install.
Prerequisites
- A personal WeChat account (the bot will operate as this account)
- The
golembotCLI installed
Get Your Token
Run the built-in login command to authenticate via QR code:
golembot weixin-login- A QR code will appear in your terminal
- Open WeChat on your phone → Scan
- Confirm the login
- The script prints your bearer token — copy it
Token security
This token grants access to send and receive messages as your WeChat account. Store it securely and never commit it to version control.
Configuration
# golem.yaml
channels:
weixin:
token: ${WEIXIN_BOT_TOKEN}
# baseUrl: https://ilinkai.weixin.qq.com # optional, default# .env or shell
export WEIXIN_BOT_TOKEN="your-token-from-qr-login"How It Works
- Transport: HTTP long-polling against Tencent's iLink Bot API (
ilinkai.weixin.qq.com) - Connection: The adapter polls
POST /ilink/bot/getupdatesin a loop; each poll blocks for up to 35 seconds waiting for new messages - Reconnection: Automatic retry with exponential backoff (1s → 2s → 4s → ... → 30s cap). On HTTP 401 (token expired), polling stops with a clear error
- Messages: Supports text, image (CDN download + AES decrypt), voice (with transcription), file, and video message types
- Images: Photos are downloaded from Tencent's CDN and decrypted with AES-128-ECB, then passed to the agent for visual analysis
- Reply: Sends messages via
POST /ilink/bot/sendmessagewith the requiredcontext_tokenfrom each inbound message - Proactive send: Supported for users who have previously messaged the bot (their
context_tokenis cached) - Chat type: Currently
dmonly (direct messages)
Start
golembot gateway --verboseYou should see:
[weixin] adapter started, polling...
Channels (1 connected)
● WeChatSend a message to the bot's WeChat account from another WeChat user — you'll see the response arrive in WeChat.
Scheduled Tasks
WeChat supports scheduled tasks. Since WeChat only has DMs, you can omit chatId — the task result will be sent to all users who have previously messaged the bot:
scheduledTasks:
- name: daily-report
cron: "0 9 * * *"
prompt: "Generate a daily status report"
target:
channel: weixinUser must message first
The bot can only send to users whose context_token is cached from a previous message. If the bot has restarted and no one has messaged yet, scheduled tasks will have no recipients.
Limitations
- No typing indicator — the iLink API does not support "typing..." status
- No group chat — currently DM only
- No history fetch — the iLink API does not provide message history
- Proactive send requires prior contact — the bot can only send to users who have previously messaged it (context_token is cached in memory and lost on restart)
- Token expiry — the bearer token may expire after some time; re-run
golembot weixin-loginto obtain a new one - Message length — WeChat limits messages to 2,000 characters; longer responses are automatically split by GolemBot
Notes
- The iLink Bot API is a Tencent service — it is not part of the official WeChat Open Platform
- No npm SDK is needed; the adapter uses native
fetch() - The
context_tokenis automatically managed per sender — you don't need to handle it manually - Images are downloaded from Tencent's CDN and decrypted locally with AES-128-ECB — no image data passes through GolemBot's servers