Operations 9 min read

How OpenClaw Automates Markdown Formatting and One‑Click Publishing to WeChat Public Accounts

The article explains how OpenClaw streamlines the tedious 30‑45‑minute manual process of formatting, uploading images, and styling WeChat articles by converting Markdown to styled HTML, automatically uploading assets, and creating or updating drafts with a single command.

ShiZhen AI
ShiZhen AI
ShiZhen AI
How OpenClaw Automates Markdown Formatting and One‑Click Publishing to WeChat Public Accounts

Many content creators spend 30–45 minutes on manual formatting, image uploading, and style adjustments for each WeChat public‑account article. OpenClaw provides an AI‑driven workflow that automates the entire publishing step, turning a finished Markdown file into a ready‑to‑publish draft.

Overall Architecture: Two Layers

The system is split into two components. article‑writer gathers information from sources such as X/Twitter, generates screenshots, selects AI‑created images, and writes the article in Markdown, storing all assets in a local directory. wechat‑article‑publisher reads the output, uploads images, renders HTML with inline styles, and creates the WeChat draft.

One‑Line Publishing Command

Running the following command triggers the whole process:

python3 scripts/publish.py --article-dir ~/Documents/openclawworkspace/articles/2026-03-07/主题/

After execution the formatted article appears in the WeChat draft box, ready for the author’s final review.

Image Handling: Fully Automatic Upload

WeChat does not accept external image URLs, so every image must be uploaded to its CDN. The script scans the article directory, uploads each image via the upload-img API, receives a CDN URL, and replaces the original Markdown link. Uploaded images are cached in meta.json under the wechat_image_map field, preventing duplicate uploads on subsequent runs. The cover image uses the permanent‑material interface add_material, which returns a media_id required for draft creation.

图片上传缓存机制示意
图片上传缓存机制示意

Rendering Engine: Markdown → Inline‑Styled HTML

WeChat only accepts HTML with inline styles and no CSS classes. The renderer automatically converts standard Markdown into fully styled HTML and interprets custom “hidden tags” written as HTML comments (e.g., <!-- wechat head -->) to generate special blocks such as blue‑bordered introductions, bold highlights, rounded‑corner cards, code snippets, and summary sections. The engine also injects a header (star marker, cover image, author) and a footer (closing note and QR code) without requiring the author to edit the Markdown.

隐藏标签渲染效果对比
隐藏标签渲染效果对比

Draft Management: First Creation and Automatic Updates

On the first run the script creates a new draft, stores the returned media_id in meta.json, and sends a preview notification. Subsequent runs detect the existing media_id and call the update‑draft API, avoiding duplicate drafts. Three operating modes are supported:

First publish : creates a new draft and records media_id.

Modify update : detects media_id and updates the existing draft.

Force new : using the --force-new flag ignores the cache and creates a fresh draft.

草稿管理流程
草稿管理流程

Separate Flow for Graphic Notes

WeChat treats long articles and graphic‑note posts as distinct content types, each requiring a different API. Attempting to publish a graphic note with the article‑type API results in malformed formatting. The script therefore routes graphic notes through the permanent‑material interface, while regular articles use upload-img for their images.

图文和文章的发布接口区别
图文和文章的发布接口区别

What Still Requires Manual Intervention

The automation covers formatting, image upload, HTML rendering, and draft creation. The author must still review the draft in the WeChat backend, confirm that the content is correct, and click the final “Publish” button.

Write the article and trigger the publish script.

The script pushes the article to the draft box and sends a preview notification.

Manually review the draft in the WeChat console.

Click “Publish” when satisfied.

Current Deployment

The whole system runs on an Ubuntu server and is scheduled by OpenClaw. After the AI finishes writing, the script automatically pushes the article to the draft box, leaving only the final human approval step.

发布流程示意图
发布流程示意图

Readers who already use OpenClaw for AI‑assisted content creation are invited to share experiences in the comments.

PythonAutomationWeChatMarkdownContent PublishingOpenClaw
ShiZhen AI
Written by

ShiZhen AI

Tech blogger with over 10 years of experience at leading tech firms, AI efficiency and delivery expert focusing on AI productivity. Covers tech gadgets, AI-driven efficiency, and leisure— AI leisure community. 🛰 szzdzhp001

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.