Skip to main content
Claw101
Back to Blog
2026-02-17
Share:TwitterTelegram

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:

  1. Get access_token — Exchange AppID + AppSecret for a temporary token (valid 2 hours)
  2. Upload images to WeChat media library — WeChat only accepts images from mmbiz.qpic.cn
  3. Generate article HTML — WeChat articles are essentially HTML rendering
  4. 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

IssueCauseFix
Title too long (error 45003)WeChat title limit ~64 bytes (~20 Chinese chars)Shorten title
Images not showingWeChat filters all non-WeChat domain imagesUpload via uploadimg first
HTML rendering issuesWeChat's h2/ul/li/code rendering is unstableUse p + inline styles only
IP whitelist not workingAccessing WeChat API via proxyAdd proxy's outbound IP

5. Before vs After

BeforeAfter
Writing1 hourAI-generated
Formatting30 minutesAuto HTML
Images20 minutesAuto upload
Review10 minutes5 minutes
Total2 hours10 minutes

90% time savings.

6. Setup Steps

npm install -g openclaw && openclaw onboard
  1. Register at aigocode.com for an API Key
  2. Connect Telegram bot
  3. Tell the AI your WeChat AppID and AppSecret
  4. Say one sentence, article goes to drafts automatically
Share:TwitterTelegram
WeChat QR

Follow WeChat: 彭少

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