2.0 KiB
2.0 KiB
Build a WeChat AI Agent with nanobot
This guide connects nanobot to WeChat through the weixin channel. The channel
uses HTTP long polling with QR-code login through the supported upstream API.
What this guide builds
- the
weixinchannel enabled in nanobot - a QR-code login session
- one allowed WeChat sender
- a running gateway for message delivery
Prerequisites
- A working local nanobot reply:
nanobot agent -m "Hello!"
- A WeChat account that can complete QR-code login.
- The sender ID from logs for
allowFrom, or a temporary private test setup.
Install nanobot
python -m pip install nanobot-ai
nanobot onboard --wizard
Enable the WeChat channel
Install the optional channel dependency:
nanobot plugins enable weixin
Merge this snippet into ~/.nanobot/config.json:
{
"channels": {
"weixin": {
"enabled": true,
"allowFrom": ["YOUR_WECHAT_USER_ID"]
}
}
}
Log in:
nanobot channels login weixin
Use --force if you need to discard saved login state and authenticate again.
Run nanobot gateway
nanobot channels status
nanobot gateway
Test a message
Send a private WeChat message from the allowed account and watch gateway logs for the sender ID and reply.
Security notes
- Keep
allowFromnarrow after you identify the sender ID. - Treat saved login state as sensitive account access.
- Avoid connecting personal accounts to untrusted workspaces or broad tool permissions.
Troubleshooting
- If login fails, rerun
nanobot channels login weixin --force. - If messages arrive but are ignored, update
allowFromwith the sender ID shown in logs. - If polling disconnects, restart the gateway and check network reachability to the upstream service.