Playground
Try the WeChat Bot SDK directly in your browser. The example below runs in a real Node.js environment powered by StackBlitz WebContainers.
TIP
This is a live editor — you can modify the code and see changes in real time. The terminal on the right shows the bot output.
Echo Bot Example
More Examples
examples/basic— Minimal echo bot with QR loginexamples/commands— Command-based bot (/help,/ping,/echo,/id)examples/media— Media bot withsendFile()andsendImage()
What's Happening
- The code calls
bot.login()to get a QR code URL - You scan the QR with WeChat to authenticate
- Once confirmed, the bot starts long-polling for messages
- Any text message you send gets echoed back with "Echo: " prefix
Try It Yourself
Things you can try in the editor:
- Change the echo prefix from
"Echo: "to something else - Add image detection (check
MessageItemType.IMAGE) - Add a command system (e.g.
/help,/ping)
Run Locally
Prefer running locally? Just:
bash
git clone https://github.com/YunYouJun/weixin-ts
cd weixin-ts
pnpm install
pnpm example