Building an LLM-Driven Automated Content Pipeline for WeChat Official Accounts
This guide walks through how to build an end-to-end automated article writing pipeline powered by large language models, covering five stages: hot-topic scanning and deduplication, topic filtering and article generation, pre-publish quality checks and compliance, cost estimation, and failure fallback. It includes sample configuration, validation commands, and practical rules for keeping humans in the loop.
1. Architecture and Pre-Build Checks
The pipeline consists of five stages: hot-topic scanning and deduplication, topic filtering and generation, pre-publish quality and compliance checks, cost estimation, and fallback handling. Each stage has clearly defined inputs and outputs, where the output of one stage feeds into the next. A failure at any single step should never abort the entire run.
Before building, confirm three things:
- Your AI coding environment supports four mechanisms: Skills, Commands, external tools (MCP), and Hooks. The exact location and syntax of configuration files should follow the environment’s official documentation.
- Every external service has its own credentials, granted only the permissions this workflow requires.
- Your test environment is separate from your production account. Validate the pipeline with test data first, then connect real accounts.
Pre-build checklist:
- Directory structure: skills/, commands/, hooks/, and the tool configuration file all exist, with paths matching the official documentation.
- Credential injection: secrets are read via environment variables or a local secret manager, never written into skill packages, config files, or logs.
- Permission scope: scraping tools are read-only; the database only writes to designated local tables; no delete permissions.
- Dry run: use a test channel and a small sample set to confirm every step produces its expected output files.
2. Hot-Topic Scanning and Deduplication
Hot-topic scanning is the entry point of the pipeline. Information sources are split into multiple channels by domain, each with its own scraping rules. Channels can run concurrently to reduce total runtime. Set concurrency based on the target sites’ rate limits and your local resources—do not hammer external services for speed.
Sample configuration (field names are illustrative; follow your tool’s actual syntax):
scan:channels:- name: tech_newssource_whitelist: ["example-news.com"]window_hours: 24- name: finance_briefsource_whitelist: ["example-finance.com"]window_hours: 24concurrency: 4timeout_seconds: 20retry: 2on_fail: skip_channeldedup_key: normalized_url
Field meanings:
- source_whitelist: only scrape whitelisted sources to avoid unverified content.
- window_hours: keep only items within the time window to prevent stale news from slipping in.
- concurrency: number of scraping tasks running simultaneously. Start small and adjust after observing how target sites respond.
- timeout_seconds and retry: per-request timeout and retry count. When retries are exhausted, the on_fail policy applies—skip the channel, log it, and continue the run.
- dedup_key: the deduplication basis. Use the normalized URL as the primary key—strip tracking parameters and trailing slashes so identical links keep only one entry. Title similarity can serve as a second layer of dedup; calibrate the threshold manually against historical samples.
Dry-run command (adjust to your environment’s command syntax):
/scan --channel tech_news --dry-run
The expected output is a JSON list where each record contains url, title, published_at, channel, and dedup_hash. If the item count is zero, check the time window and whitelist first instead of simply raising concurrency.
3. Topic Filtering and Article Generation
The filtering stage picks topics suitable for your account from the list, in three steps. First, domain matching: remove items irrelevant to your account’s positioning. Second, duplicate checking: compare against recently published historical titles. Third, risk screening: remove items involving unverified claims, personal privacy, or highly sensitive events.
Topics can be ranked with a weighted scoring table—for example, relevance 40%, timeliness 30%, and available source material 30%, each scored 1–5. Scores are for ranking only; an editor still makes the final call.
The generation stage reads the selected topic, style guidelines from the skill package, and source materials, then produces a draft. Require the model to attach a source link for every factual claim in the draft. Numbers and conclusions without a source should be deleted or rewritten as qualitative statements.
Manual review checkpoints:
- Whether facts and figures can be traced to a source;
- Whether the title is exaggerated, e.g., using absolute terms like “shocking” or “the best”;
- Whether there are unauthorized long quotations.
Failure handling: on generation timeout, save existing fragments and mark them for retry. Incomplete articles should never enter the publish queue.
4. Pre-Publish Quality Checks and Compliance
Quality checks run automatically via hooks and cover four categories:
- Sensitive words and advertising-law language: detect absolute promises, health or income claims, and similar phrasing. On a hit, block the article and let an editor decide how to revise it.
- Title and formatting: check title length, duplication against historical titles, image copyright information, and whether paragraph structure and heading levels are reasonable.
- AI-generated content disclosure: declare that content was AI-assisted according to the platform’s current rules. Follow the platform’s latest requirements for the disclosure mechanism.
- Copyright and privacy: check that quotations are attributed, and that no personal phone numbers, addresses, or unauthorized screenshots appear in the text.
Blocking follows an “intercept and notify” model—no automatic bypass. False positives are released manually with the reason logged, making it easier to tune rules later. This pipeline should not be used to circumvent platform moderation, mass-register accounts, or inflate engagement.
5. Cost Estimation and Failure Fallback
Cost has three components: model API fees, external tool or data interface fees, and manual review time. The estimation formula:
Monthly cost = cost per article × articles per month + fixed API fees + review hours × hourly rate
Cost per article depends on input length, output length, and the unit price of the chosen model. Calculate your own averages from dry-run data. Prices change frequently, so this article does not list specific rates—defer to your provider’s current pricing.
Design fallback strategies per stage:
- Scan failure: skip the affected channel, log it, retry next round.
- Generation failure: keep intermediate results and mark them as pending.
- QC block: route to the manual queue; never auto-publish.
- Tool unavailable: switch to a manual data-export alternative and notify the owner.
Assign an owner to every stage. The goal of automation is to reduce repetitive work—the responsibility for publishing decisions and final content always stays with people.
