Auto-Publish to WeChat in 5 Minutes (With Bug Fix Guide)
Today I'm sharing how to tell your AI one sentence and have an article automatically appear in your WeChat Official Account drafts. Complete setup flow + every pitfall encountered.
1. Configure WeChat Official Account API (5 Minutes)
Step 1: Get AppID and AppSecret
Log in to mp.weixin.qq.com → Settings & Development → Basic Configuration
- AppID: Displayed on the page, just copy it
- AppSecret: Click "Reset" to generate a new one (shown only once, save it!)
Step 2: Configure IP Whitelist
On the same page, find IP Whitelist and add your server's outbound IP. Without it, you'll get error 40164.
Don't know your outbound IP? Run in terminal:
curl ifconfig.me
If using a proxy, add the proxy's outbound IP, not your local IP.
Step 3: Tell Your AI
Give the AppID and AppSecret to your AI assistant. Configuration complete.
2. AI Publishing Workflow
Just say: "Write an article about xxx and push it to my WeChat drafts."
The AI automatically handles 4 steps:
- Get access_token — Exchange AppID + AppSecret for a temporary token (valid 2 hours)
- Upload images to WeChat media library — WeChat only accepts images from mmbiz.qpic.cn
- Generate article HTML — WeChat articles are essentially HTML rendering
- Push to drafts — Call the draft/add API
Your job: Open drafts → Preview → Publish.
3. The Biggest Pitfall: Chinese Character Encoding
After the first "successful" push, opening the draft revealed all Chinese characters turned into \u4eca\u5929 escape codes.
Root cause: Python requests defaults to ensure_ascii=True when sending JSON, converting all Chinese to \uXXXX. WeChat's API doesn't auto-decode — it stores the raw escaped text as-is.
Wrong (causes garbled text):
# Chinese becomes \uXXXX
requests.post(url, json=data)
Correct (fixes encoding):
# Manual serialization, preserving Chinese characters
requests.post(
url,
data=json.dumps(data, ensure_ascii=False).encode("utf-8"),
headers={"Content-Type": "application/json"}
)
Two key parameters:
ensure_ascii=False: Preserve Chinese characters as-is.encode("utf-8"): Send as UTF-8 bytes
4. Other Pitfalls
| Issue | Cause | Fix |
|---|---|---|
| Title too long (error 45003) | WeChat title limit ~64 bytes (~20 Chinese chars) | Shorten title |
| Images not showing | WeChat filters all non-WeChat domain images | Upload via uploadimg first |
| HTML rendering issues | WeChat's h2/ul/li/code rendering is unstable | Use p + inline styles only |
| IP whitelist not working | Accessing WeChat API via proxy | Add proxy's outbound IP |
5. Before vs After
| Before | After | |
|---|---|---|
| Writing | 1 hour | AI-generated |
| Formatting | 30 minutes | Auto HTML |
| Images | 20 minutes | Auto upload |
| Review | 10 minutes | 5 minutes |
| Total | 2 hours | 10 minutes |
90% time savings.
6. Setup Steps
npm install -g openclaw && openclaw onboard
- Register at aigocode.com for an API Key
- Connect Telegram bot
- Tell the AI your WeChat AppID and AppSecret
- Say one sentence, article goes to drafts automatically
Related Posts
Related Tutorial Chapters

Follow WeChat: 彭少
Stay updated with OpenClaw tips, AI coding techniques, and productivity tools. Follow for the latest content.

