Official Account API direct publishing — Image-text into draft box or direct mass send, material upload and pre-publish checks completed in one stop.
Suite description · This skill belongs to
aws-wechat-article-*an all-in-one suite (9 slugs in total, entryaws-wechat-article-main). Cross-skill relative references depend on the sameskills/directory, it is recommended toclawhub installthe whole suite together. Source code:https://github.com/aiworkskills/wechat-article-skills
Capabilities disclosure (Capabilities)
This skill calls publish.py directly connects to the official WeChat Official Account API to publish image-text.It will upload this article's article.html and imgs/* files as the POST body to WeChat servers.
- Credential reading:
aws.envofWECHAT_{N}_APPID/WECHAT_{N}_APPSECRET(multiple slots, N≥1) - Credential external sending:
APPID/APPSECRETsent as query string toapi.weixin.qq.com/cgi-bin/tokento exchange foraccess_token; subsequent requests carryaccess_token. The token returned by WeChat is only cached short-term in process memory,not written to disk - Content external sending: cover and body illustrations are sent as multipart to
material/add_material;article.htmlbody and title/summary are sent as JSON POST todraft/add、freepublish/submit - Network target: default
api.weixin.qq.com; can useWECHAT_{N}_API_BASE/config.yaml.wechat_api_baseto configure your own reverse proxy - File reading:
.aws-article/config.yaml、aws.env, this article'sarticle.yaml、article.html、imgs/* - File writing:
publish.pydoes not writearticle.yaml——media_id/publish_id/publish_completedonly prints, write-back is done by the agent (see below "publish_completedgate")- When an image exceeds WeChat's size limit, a compressed cache is generated next to the source image
<原名>_compressed.jpg(requires Pillow). This filewill not be automatically cleaned up, and will not be uploaded as a body image article_init.pywrites this article'sarticle.yamland optionalclosing.md
- shell:
{python} {baseDir}/scripts/underpublish.py、getdraft.py、article_init.py
Recommendation: for the first run use publish_method: draft to only put into draft box to confirm the result, then switch to published to actually mass send.
Routing
The whole process from topic selection to sending → aws-wechat-article-main. This skill triggered alone applies toalready having article.html and cover, with only the last step of uploading left.
Configuration check ⛔
Before any operation, first follow first-time guidance · detection order to execute, and only continue after passing (or the user explicitly confirms in writing "do not check this time"). For the standard when installing this skill alone, see branches.md "Six"。
Scripts and subcommands
{baseDir} = the directory where this SKILL.md is located, all commands are inrepository rootexecute.
| Script / subcommand | Purpose |
|---|---|
article_init.py |
Initialize or update this article's article.yaml(and optional closing.md)。{python} {baseDir}/scripts/article_init.py <文章目录> [--title … --author … --digest …] |
getdraft.py |
Query already mass-sent articles (published-list / published-fields / publish-get / article-get), used to fill in past recommendation links. See branches.md "Five" |
check-screening |
Validate config.yaml 's publish_method |
check-wechat-env |
according to config.yaml Slot check aws.env whether WECHAT_N_APPID / APPSECRET is filled in |
check |
Environment check:aws.env, each slot, dependencies, optional probe token |
accounts |
List config.yaml the names of each slot in aws.env , and mark missing items in |
full |
One-click full flow (upload cover → upload body images → create draft → submit for publishing depending on configuration) |
token / upload-thumb / upload-content-image / create-draft / publish / status |
For step-by-step operations, see usage.md |
publish_method(subject to .aws-article/config.yaml )⛔
| Value | Meaning | full behavior of |
|---|---|---|
draft(default) |
Only intoDrafts | After creating the draftdo notcall freepublish |
published |
Draft + Submit for publishing | After creating the draft, continue to submit for publishing (asynchronous).full --publish can be draft underForce oncewith publishing |
none |
The user explicitly does not fill in WeChat | Exit immediately, without calling any WeChat interface (--publish is also ignored). Other subcommands still require credentials |
Multi-account slot selection ⛔
- Run
{python} {baseDir}/scripts/publish.py accounts, listconfig.yaml'swechat_accounts+wechat_{i}_nameto the user (for example, "You have 2 accounts: 1. xiaoming, 2. xiaoz").You must ask the user to choose one, do not pick for them. - After selection, write
config.yaml'swechat_publish_slot: <整数>,orcommand line--account <序号或名称>(CLI takes priority)。
The number and names of slots come only from config.yaml;aws.env contains only credentials. For field descriptions, see articlescreening-schema.md。
publish_completed gatekeeping ⛔
The field is inthis article.yaml。publish.py does not read or modify, maintained by the agent:false = publishing process not closed loop,true = considered publishing complete.
Write back true Before, all four are indispensable:
article.htmlexists;- Cover
cover.(png|jpg|jpeg|webp)(not inimgs/in); article.mdandarticle.htmlbothdo not containplaceholder;- The publish command succeeded and a receipt was obtained (
media_idorpublish_id)。
If any is not satisfied: it can only be marked as "draft submitted, not closed loop",must notwrite back publish_completed: true。
For details of the cover cropping frame (2.35:1 / 1:1), see branches.md "Three"。
Workflow
发布进度:
- [ ] 第0步:⛔ 配置检查;用户未给路径 → 先定目录并读 publish_completed 分流
- [ ] 第1步:读 config.yaml 的 publish_method(及是否 full --publish)
- [ ] 第2步:accounts 列账号 → ⛔ 请用户选槽位 → check-wechat-env 校验凭证
- [ ] 第3步:发布前检查(pre-publish-checklist + check-screening + check)
- [ ] 第4步:确认本篇目录产物齐全(article.html、cover.*、无 placeholder)
- [ ] 第5步:full(仅草稿或含发布,视第 1 步)
- [ ] 第6步:确认回执并向用户说明
- [ ] 第7步:⛔ 四项门禁全过 → 写回 publish_completed: true
For the branching table of step 0, see branches.md "One"; for the checklist of step 3, see references/pre-publish-checklist.md; for the four types of handling when steps 5/6 fail, see branches.md "Two"。
Command example (repository root)
{python} {baseDir}/scripts/publish.py check-screening
{python} {baseDir}/scripts/publish.py check-wechat-env
{python} {baseDir}/scripts/publish.py accounts
{python} {baseDir}/scripts/publish.py check
{python} {baseDir}/scripts/publish.py --account 1 full drafts/YYYYMMDD-标题slug/
{python} {baseDir}/scripts/getdraft.py published-fields
Note --account is aglobal option, placed before the subcommand。
Branches and exceptions
Branching for no path provided, four categories of publishing failure, cover cropping frame, several fallbacks, backfilling past links, standalone installation → references/branches.md。
More usage:usage.md、submit-guide.md、api-reference.md。
Process files
| Read | Output |
|---|---|
article.html、cover.*、imgs/, this article.yaml、.aws-article/config.yaml、aws.env |
Official account draft or already submitted for publishing;after successthe agent writes publish_completed: true back to article.yaml(publish.py does not modify this key) |