English | Simplified Chinese
A WeChat / IM agent project based on Wechaty.
It can route IM messages received from WeChat QR-code login, Lark IM events, Telegram Bot API polling, or WhatsApp Cloud API webhooks to ChatGPT, DeepSeek, Ollama, Claude, Pi, and other services. It can also use wx-cli (the wx binary) to access local WeChat chats, contacts, group members, favorites, and Moments cache, then run statistics or AI analysis for a group chat or a specific friend.
If you want to use Pi as the project agent and WeChat, Lark, Telegram, or WhatsApp as the external communication channel, start with Pi Agent + IM Guide.
AutoClaw · An AI agent that works for you, one click to connect WhatsApp / Telegram / Discord
| Feature | Command entry | Status |
|---|---|---|
| WeChat QR-code IM | wb agent --im wechat --agent pi / wb start --serve pi |
Available. Logs in by QR code and replies to allowlisted messages |
| Pi as project agent | wb agent --im wechat/lark/telegram/whatsapp --agent pi |
Available. Single-turn non-interactive replies by default |
| Local WeChat chats / contacts / group members | wb wx sessions, wb wx history, wb wx members |
Integrated through wx-cli 0.6.x (wx binary) |
| Local Moments cache | wb wx sns-feed, wb wx sns-search |
Integrated through wx-cli 0.6.x (wx binary) |
| Group / friend analysis | wb analyze --room "Group name", wb analyze --friend "Friend alias" |
Supports local statistics and AI deep analysis |
| Local WeChat database analysis (no QR-code login) | wb analyze --source wx, or append wx to a chat command |
Statistics / AI analysis over the local WeChat database through wx-cli |
| Lark IM | wb lark login, wb lark messages, wb lark send, wb lark agent |
Supports login, read, search, send, and event-driven auto-replies |
| Telegram IM | wb telegram agent, wb telegram send |
Supports Bot API long-polling receive and send |
| WhatsApp IM | wb whatsapp agent, wb whatsapp send |
Supports WhatsApp Cloud API webhook receive and send |
| Multi-model replies | --serve ChatGPT/deepseek/ollama/pi/... |
Reuses the existing provider mechanism |
npm i
cp .env.example .env
npm linkConfigure at least the following values in .env:
BOT_NAME='@Your WeChat nickname'
ALIAS_WHITELIST='Friend alias allowed for private chat'
ROOM_WHITELIST='Group name allowed for access'
PI_BIN='pi'
PI_AGENT_ARGS='--print --no-session'
WECHAT_STORE_MESSAGES='true'Start the agent:
wb agent --im wechat --agent piWhen a QR code appears in the terminal, scan it with WeChat. The message pipeline is:
WeChat QR-code login -> Wechaty receives message -> local JSONL capture -> Pi agent reply -> WeChat IM sends reply
Trigger rules:
- Private chats: the sender alias or nickname must be in
ALIAS_WHITELIST. - Group chats: the group name must be in
ROOM_WHITELIST, and the message must mention@BOT_NAME. - Non-text messages are not automatically sent to the reply pipeline.
If you only want to query local WeChat data (sessions, chat history, group members, Moments cache) without QR-code login, use wx-cli directly. No model configuration is needed:
npm install -g @jackwener/wx-cli # or build wx 0.6.x from source and put it on PATH
sudo wx init # first time only, in a local GUI terminal
wb wx sessions
wb analyze --room "Group name" --stats-only --source wxSee "4. Local WeChat Data and Moments" and the FAQ below for installation, the full command list, and common errors.
Note: WeChat Web protocols carry account risk, including warnings or bans. Use this only with accounts and scenarios where you explicitly accept the risk. Keep allowlists and usage scope narrow.
PRs for more AI services, better integrations, and stronger implementations are welcome.
WeChat has recently become very strict about this type of usage. The default protocol can trigger WeChat warnings or account bans. Use it carefully. The author of the padlocal protocol is no longer maintaining it, so switch to a more stable protocol yourself if needed.
If you only use wb wx ... to access local WeChat data, or only use wb lark ... to operate Lark IM, you do not need to configure an LLM.
If you want automatic WeChat replies or wb analyze deep analysis, choose a --serve service. Current options include ChatGPT, doubao, deepseek, Kimi, Xunfei, deepseek-free, 302AI, dify, ollama, tongyi, claude, and pi.
-
pi
Pi is suitable as the project agent and can communicate through WeChat, Lark, Telegram, or WhatsApp IM:
PI_BIN='pi' PI_NPM_PACKAGE='@earendil-works/pi-coding-agent' PI_AGENT_ARGS='--print --no-session'
If your machine does not have a global
picommand, leavePI_BINempty. The project will start Pi throughnpx --yes @earendil-works/pi-coding-agent. -
deepseek
Get your
api keyfrom the DeepSeek platform, then put it in.env:DEEPSEEK_FREE_TOKEN='your key'
-
ChatGPT
Get your
api keyfrom OpenAI API keys.This is a paid service. If requests fail, make sure your terminal proxy works and your OpenAI account has billing available.
# Copy .env.example to .env cp .env.example .env # Fill in .env OPENAI_API_KEY='your key'
-
Doubao
Doubao Seed 1.6 supports image input and deep thinking. After registering and logging in to Volcano Engine, select a Doubao model, choose API access, and get an API key.
# Copy .env.example to .env cp .env.example .env # Fill in .env DOUBAO_API_KEY='your key' # Test whether the API works node src/doubao/__test__.js
-
Tongyi Qianwen
Tongyi Qianwen is an AI service from Alibaba Cloud. After getting your API key, fill in
.env:# Copy .env.example to .env cp .env.example .env # Fill in .env # Tongyi URL, including the URI path TONGYI_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1" # Tongyi API key TONGYI_API_KEY = '' # Tongyi model TONGYI_MODEL='qwen-plus'
-
Xunfei
Apply for a key from Xunfei. Be careful not to mix up the several Xunfei configuration keys. For service errors, see issues/170 and issues/180.
-
Kimi
Get a key from Kimi API keys. Kimi is currently integrated at a basic level. PRs for file upload and other improvements are welcome.
-
dify
Create an app at dify, get your API key, and fill in
.env. Self-hosted Dify deployments are also supported.# Copy .env.example to .env cp .env.example .env # Fill in .env DIFY_API_KEY='your key' # For self-hosted Dify, update the following value in .env # DIFY_URL='https://[your self-hosted URL]'
-
ollama
Ollama is a local AI service. Its API is close to OpenAI's API, but configuration differs from cloud services.
# Copy .env.example to .env cp .env.example .env # Fill in .env OLLAMA_URL='http://127.0.0.1:11434/api/chat' OLLAMA_MODEL='qwen2.5:7b' OLLAMA_SYSTEM_MESSAGE='You are a personal assistant.'
-
302.AI
302.AI is an AI aggregation platform. Add an API from 302.AI APIs, then configure the API key in
.env:_302AI_API_KEY = 'xxxx' _302AI_MODEL= 'gpt-4o-mini'
You can choose the model yourself. Users should evaluate platform cost, payment flow, and service quality before using it.
-
claude
Register on the Anthropic Console, get an API key, then configure:
# Copy .env.example to .env if it does not already exist cp .env.example .env # Edit .env and add Claude settings CLAUDE_API_VERSION = '2023-06-01' CLAUDE_API_KEY = 'your API key' CLAUDE_MODEL = 'claude-3-5-sonnet-latest' # System prompt CLAUDE_SYSTEM = ''
-
Other
In theory, APIs compatible with OpenAI's format can be used by configuring the corresponding API key, model, and proxy URL in
.env.
Make sure your development environment has nodejs installed. The required version is Node.js >= v18.0. Older versions can fail at runtime. An LTS version is recommended.
For users in mainland China, switching to the Taobao npm mirror before installing dependencies may help:
npm config set registry https://registry.npmmirror.comFor flexible registry switching, you can use prm-cli.
npm i
# Optional: register wb as a local command
npm linkIf you do not want to run npm link, replace every wb ... command below with:
npm run start -- ...cp .env.example .envMinimum usable configuration:
BOT_NAME='@Your WeChat nickname'
ALIAS_WHITELIST='Friend alias 1,Friend nickname 2'
ROOM_WHITELIST='Group name 1,Group name 2'
AUTO_REPLY_PREFIX=''
WECHAT_DATA_DIR='.data/wechat'
WECHAT_STORE_MESSAGES='true'
PI_BIN='pi'
PI_AGENT_ARGS='--print --no-session'No model configuration is needed if you only use wb wx ... or wb analyze --source wx. Optional wx-cli variables: WX_CLI_BINARY / WX_BIN (binary path when wx is not on PATH; may include arguments), WX_CLI_NPM_PACKAGE (default @jackwener/wx-cli), WX_CLI_TIMEOUT_MS (structured-call timeout, default 180000). See .env.example for details.
Pi agent mode:
wb agent --im wechat --agent piEquivalent commands:
wb start --serve pi
npm run agent
npm run start -- start --serve piTraditional model reply mode:
wb start --serve ollama
wb start --serve ChatGPT
wb start --serve deepseekAfter startup, a QR code appears in the terminal. Scan it to log in to WeChat. After login, received WeChat messages are appended to:
.data/wechat/messages.jsonl
wb wx ... passes through to wx-cli (binary name wx, 0.6.x required). wx-cli is a standalone Rust binary whose background daemon decrypts the local SQLCipher databases of WeChat 4.x on the fly. Queries do not need QR-code login, and WeChat does not have to keep running.
Install (either way):
npm install -g @jackwener/wx-cli # npm package (the public registry version may lag behind)
# or build from source
cargo build --release && mkdir -p ~/.local/bin && cp target/release/wx ~/.local/bin/wxExtract the database keys once in a local GUI terminal (no need to disable SIP):
sudo wx init
wx doctor # key / shard health check
# If doctor reports missing shard keys, or meta.unknown_shards is not empty:
sudo wx key extract --hook-seconds 90 # open the relevant chats in WeChat while it waitswb wx resolves the binary in this order: WX_CLI_BINARY / WX_BIN → wx on PATH → npx --yes @jackwener/wx-cli (last resort, prints a warning). Common commands (YAML by default, --json returns a { ..., meta } wrapper):
wb wx sessions # recent sessions
wb wx history "Alice" -n 200 # chat history
wb wx search "keyword" --in "Work Group" # full-database search
wb wx unread --filter private,group # unread from real people
wb wx new-messages # messages since the last check
wb wx contacts # contacts
wb wx members "AI Group" # group members
wb wx stats "AI Group" # chat statistics
wb wx favorites # favorites
wb wx sns-feed # Moments timeline
wb wx sns-search "keyword" # Moments full-text search
wb wx sns-notifications # Moments like / comment notifications
wb wx biz-articles --unread # official account articles
wb wx attachments "Alice" # list image attachments, get an attachment_id
wb wx extract <attachment_id> -o photo.jpg # decrypt and export an image
wb wx timeline # cross-chat timeline
wb wx watch # watch new messages live
wb wx export "Alice" --format markdown -o chat.md
wb wx daemon status # daemon status
wb wx help # full command listArguments starting with - must be passed after --, for example wb wx -- --version. The meta block describes data freshness: when status is possibly_stale / possibly_stale_unknown_shards, or unknown_shards is not empty, some shards have no key and results may be incomplete; run sudo wx key extract --hook-seconds 90 as suggested.
Command-line analysis:
# Local statistics only, without calling AI (reads the JSONL captured by wb by default)
wb analyze --room "Group name" --stats-only
wb analyze --friend "Friend alias" --stats-only
# Call a selected service for deep analysis
wb analyze --room "Group name" --serve pi
wb analyze --friend "Friend alias" --serve ollama
# --source wx: read the local WeChat database through wx-cli instead (no QR-code login needed);
# without --room/--friend it uses the cross-chat `wx timeline`
wb analyze --room "Group name" --stats-only --source wx
wb analyze --friend "Friend alias" --serve pi --source wx
wb analyze --stats-only --source wxBuilt-in commands in WeChat chats only work for allowlisted contacts or allowlisted groups by default:
/stats group GroupName
/analyze friend FriendAlias
/stats group GroupName wx
/analyze friend FriendAlias wx
/stats only computes statistics and does not call AI. /analyze sends recent message samples to the current serve service or agent. By default they read the local JSONL captured by wb; append wx to read the local WeChat database through wx-cli instead (requires sudo wx init on this machine). For private chats, prefer a local model or local Pi configuration.
Lark IM is integrated through lark-cli:
# Generate a device-flow authorization link / QR-code info
wb lark login --no-wait
# Check authorization status
wb lark status
# Read / search / send messages
wb lark messages --chat-id oc_xxx
wb lark search --query "keyword"
wb lark send --chat-id oc_xxx --text "hello"To let Pi or another provider reply to Lark messages through the event stream, configure:
LARK_AGENT_IDENTITY='bot'
LARK_AGENT_EVENT_KEY='im.message.receive_v1'
LARK_AGENT_CHAT_TYPES='p2p,group'
LARK_AGENT_MESSAGE_TYPES='text,post'
LARK_AGENT_CHAT_WHITELIST=''
LARK_AGENT_USER_WHITELIST=''
LARK_AGENT_REPLY_PREFIX=''
LARK_AGENT_GROUP_MENTION_NAME=''
LARK_AGENT_GROUP_AUTO_REPLY='false'Then start:
wb agent --im lark --agent pi
# or
wb lark agent --agent piThe Lark event path uses lark-cli event consume im.message.receive_v1 --as bot. Private chats are replied to by default unless you set a chat or user allowlist. Group chats require LARK_AGENT_CHAT_WHITELIST and one of these triggers: LARK_AGENT_REPLY_PREFIX, LARK_AGENT_GROUP_MENTION_NAME, or LARK_AGENT_GROUP_AUTO_REPLY=true.
Before using event replies, make sure the Lark app has enabled the im.message.receive_v1 event in the developer console and has the required IM scopes.
Telegram uses the official Bot API with long polling:
TELEGRAM_BOT_TOKEN='123456:bot-token'
TELEGRAM_AGENT_CHAT_TYPES='private,group,supergroup'
TELEGRAM_AGENT_CHAT_WHITELIST=''
TELEGRAM_AGENT_USER_WHITELIST=''
TELEGRAM_AGENT_REPLY_PREFIX=''
TELEGRAM_AGENT_GROUP_MENTION_NAME='@your_bot'
TELEGRAM_AGENT_GROUP_AUTO_REPLY='false'Start:
wb agent --im telegram --agent pi
# or
wb telegram agent --agent piPrivate chats are replied to by default unless you set a chat or user allowlist. Group and supergroup chats require a chat allowlist and one of these triggers: reply prefix, bot mention name, or TELEGRAM_AGENT_GROUP_AUTO_REPLY=true.
You can send a test message with:
wb telegram send --chat-id 123456 --text "hello"WhatsApp uses the official Cloud API. Incoming messages are received through a webhook, so the local server must be reachable from Meta through a public HTTPS URL.
WHATSAPP_ACCESS_TOKEN='your access token'
WHATSAPP_PHONE_NUMBER_ID='your phone_number_id'
WHATSAPP_VERIFY_TOKEN='your webhook verify token'
WHATSAPP_GRAPH_API_VERSION='v23.0'
WHATSAPP_WEBHOOK_PORT='3000'
WHATSAPP_WEBHOOK_PATH='/webhook/whatsapp'
WHATSAPP_AGENT_REPLY_PREFIX=''Start the webhook server:
wb agent --im whatsapp --agent pi
# or
wb whatsapp agent --agent piConfigure the webhook callback URL in Meta as:
https://your-public-domain.example/webhook/whatsapp
Use the same WHATSAPP_VERIFY_TOKEN value in Meta's webhook verification form. WhatsApp replies only support inbound text messages by default.
You can send a test message with:
wb whatsapp send --to 15551234567 --text "hello"wb pi -- --help
wb pi -- --print "Analyze the current project structure"
wb opencli -- --help # OpenCLI turns websites into CLIs; it is no longer used for local WeChat data
wb wx help # local WeChat data goes through wx-cli (see section 4)
wb wx -- --versionnpm run test:analysis
npm run test:wx-cli
node ./cli.js --help
node ./cli.js wx help
node ./cli.js pi -- --helpIf you use cloud services such as OpenAI, Claude, or Kimi, make sure the corresponding API key, balance, and network proxy are available.
Many users assume the bot should automatically send and receive every message after startup. It does not. To avoid replying to every incoming message, the project intentionally has trigger restrictions.
Customize the following values:
BOT_NAME: the WeChat nickname of the bot account, in a format similar to@Cola.ALIAS_WHITELIST: friend aliases or nicknames allowed for auto-reply.ROOM_WHITELIST: group chat names allowed for auto-reply.AUTO_REPLY_PREFIX: optional. Auto-reply is triggered only when the message matches this prefix.PI_AGENT_ARGS: arguments used when Pi runs as the IM agent. The default is--print --no-session.WX_CLI_BINARY: optional. Path to the wx-cliwxbinary when it is not on PATH (WX_BINworks too). By default the project looks forwxon PATH, then falls back tonpx @jackwener/wx-cli.- For deeper business logic, see
src/wechaty/sendMessage.jsandsrc/platforms/wechat/commandRouter.js.
Edit these values in .env. Example:
# Allowlist configuration
# Define the bot name. This avoids replying to too many group messages.
# Keep the @ prefix and append the WeChat nickname of the bot account.
BOT_NAME=@Cola
# Contact allowlist
ALIAS_WHITELIST=WeChatName1,Alias2
# Group chat allowlist
ROOM_WHITELIST=Group1,Group2
# Auto-reply prefix matching. For text messages, auto-reply is triggered only
# when the specified prefix matches. Empty or unset values disable this setting.
# Matching rule: group messages remove ${BOT_NAME} and trim before prefix matching;
# private messages are trimmed directly before prefix matching.
AUTO_REPLY_PREFIX=''
# Pi agent
PI_BIN='pi'
PI_AGENT_ARGS='--print --no-session'Auto-reply is no longer limited to chatgpt. Use --serve to choose different services, such as pi, ollama, deepseek, claude, or ChatGPT.
Recent WeChat review is strict. Many users have reported plugin warnings. Because the project uses a free Web protocol by default, WeChat can detect it easily. Consider using a pad protocol or buying an enterprise protocol yourself to reduce account-ban risk.
Reference change: https://github.com/wangrongding/wechat-bot/pull/263/files
Pad protocol channel shared by Wechaty, purchase carefully: http://pad-local.com
The underlying wechaty dependency itself is not actively maintained. Community feedback says the pad protocol can currently work, but frequent login/logout can still trigger warnings. Avoid buying a very long subscription at once.
The following are the author's WeChat and group QR codes. Please describe your purpose clearly when adding the author.
![]() |
|---|
First check the following:
-
Pull the latest code and reinstall dependencies. If necessary, delete the lock file and
node_modules. -
It is usually better not to set an npm mirror while installing dependencies.
-
If Puppeteer installation fails, set the environment variable:
# Mac export PUPPETEER_SKIP_DOWNLOAD='true' # Windows SET PUPPETEER_SKIP_DOWNLOAD='true'
-
If you use a cloud model, make sure the terminal network can access the corresponding model service. Enable a global proxy or configure a terminal proxy manually.
# Set proxy export https_proxy=http://127.0.0.1:your_proxy_port;export http_proxy=http://127.0.0.1:your_proxy_port;export all_proxy=socks5://127.0.0.1:your_proxy_port # Then run a service test, or first check whether the CLI works node ./cli.js --help
-
If you use OpenAI / Claude / Kimi or another cloud model, confirm that the API key, account balance, model name, and proxy settings are correct.
-
Configure
.env, especiallyBOT_NAME, allowlists, and parameters required by the current--serveservice. -
Run
npm run test:analysisandnpm run test:wx-clito verify the local analysis module and the wx-cli adapter. Runnode ./cli.js --helpto verify the CLI. -
wb wx ...fails withwx-daemon 启动超时(daemon start timeout) or a missingall_keys.json: the WeChat database keys have not been extracted on this machine yet. Runsudo wx initin a local GUI terminal, thenwx doctor; if shard keys are missing, runsudo wx key extract --hook-seconds 90(open the relevant chats in WeChat while it waits). Disabling SIP is not required. -
wb wxprints "PATH 中未找到 wx,回退到 npx" (wx not found on PATH, falling back to npx) or fails withwx: command not found: install wx-cli 0.6.x (npm install -g @jackwener/wx-cli, or build from source and add it to PATH), or pointWX_CLI_BINARYat the binary. The public npm version may lag behind, so building from source is preferred. -
Run
wb agent --im wechat --agent piorwb start --serve <service>to start WeChat QR-code login. -
Run
wb agent --im lark --agent piorwb lark agent --agent pito start Lark event-based replies.
You can also refer to this issue.
- How to use it? After customization, when someone mentions you in an allowlisted group, or an allowlisted private contact sends you a message, auto-reply is triggered.
- Runtime error? Check whether the Node version meets the requirement. If not, upgrade Node. Check whether dependencies are fully installed. Users in mainland China can switch npm mirrors and reinstall dependencies. prm-cli can switch registries quickly.
- How to adjust conversation mode? Prefer switching services with
--serve. For custom business logic, see sendMessage.js, commandRouter.js, and the corresponding provider implementation.
docker build . -t wechat-bot
docker run -d --rm --name wechat-bot -v $(pwd)/.env:/app/.env wechat-bot- If Node repeatedly times out during
docker build, download a Node.js image to your local image registry first, then changenode:19inDockerfileto your local Node.js image version.
This project became No. 1 on GitHub Trending on 2023-02-13.
MIT.

