Chapter 17

AI Content Production Pipeline

Chapter 17: AI Content Production Pipeline

Content creation is one of the fastest AI automation wins. A well-designed n8n workflow can collect trending topics, filter and rank them, generate full articles, create cover images, and publish to multiple platforms — all automatically. This chapter builds the complete pipeline end-to-end, with detailed API cost analysis.

17.1 Pipeline Overview

Five stages, each implemented as a distinct section of the n8n workflow (or separate sub-workflows for easier debugging):

  1. Step 1 — Trend Collection: RSS Feed + Google Trends API
  2. Step 2 — AI Filtering + Dedup: LLM relevance scoring + fingerprint deduplication
  3. Step 3 — Content Generation: Claude/GPT with structured prompt templates
  4. Step 4 — Image Generation: DALL-E 3 or Stable Diffusion API
  5. Step 5 — Scheduled Publishing: Platform-specific APIs for multi-channel distribution

n8n's native RSS Read node handles any RSS/Atom feed without XML parsing code. Configure multiple feed URLs — n8n merges all entries automatically. For Google Trends, use the HTTP Request node to call SerpAPI's trends endpoint.

GET https://serpapi.com/search.json
  ?engine=google_trends
  &q=n8n+automation,AI+workflow
  &date=now+7-d
  &geo=US
  &api_key={{ $credentials.serpApiKey }}

# Extract rising queries from related_queries.rising
# Use these as content angle suggestions

17.3 Step 2: AI Filtering and Deduplication

Use GPT-4o-mini to score each RSS item for relevance (0–10) at roughly $0.0001 per item. A Filter node keeps only items scoring 7 or above. A Code node then fingerprints titles (first 15 chars, normalized) to remove near-duplicates, then sorts by score and keeps the top 5.

// Code node: deduplication by title fingerprint
const items = $input.all();
const seen = [];
const deduped = [];

for (const item of items) {
  const fingerprint = item.json.title.toLowerCase()
    .replace(/[^a-z0-9]/g, '').slice(0, 15);
  if (!seen.includes(fingerprint)) {
    seen.push(fingerprint);
    deduped.push(item);
  }
}

deduped.sort((a, b) => b.json.aiScore - a.json.aiScore);
return deduped.slice(0, 5);

17.4 Step 3: Content Generation

Claude 3.5 Sonnet outperforms GPT-4o on Chinese long-form writing and follows style instructions more reliably. Use a structured prompt that specifies: author persona, target platform, article structure, word count, and style constraints.

Cost tip: For budget-conscious setups, use Claude 3 Haiku for first drafts ($0.25/M tokens), human-review the top picks, then publish. Quality is lower but acceptable for high-volume informational content.

17.5 Step 4: Image Generation

// DALL-E 3 API call
{
  "method": "POST",
  "url": "https://api.openai.com/v1/images/generations",
  "body": {
    "model": "dall-e-3",
    "prompt": "{{ $json.imagePrompt }}",
    "size": "1792x1024",
    "quality": "standard"
  }
}

// DALL-E 3 standard 1792x1024: $0.080/image
// Self-hosted Stable Diffusion: ~$0.002/image on a GPU VPS

Before calling DALL-E, use an LLM node to translate the Chinese article title into an English image prompt. DALL-E 3 interprets English prompts far more accurately than Chinese.

17.6 Step 5: Multi-Platform Publishing

n8n has native nodes for WordPress and Notion. Use HTTP Request for platforms with public APIs.

Platform Integration Notes
WeChat Official Account HTTP Request (WeChat API, requires service account) Cannot publish directly; save as draft first
Xiaohongshu Third-party API Platform restrictions; watch for rate limits
WordPress Native WordPress node Full API support, direct publish
Telegraph HTTP Request (Telegraph API) Free, good for quick distribution
Notion Native Notion node Use as content management backend

Editorial safeguard: Never auto-publish raw AI output to public platforms. Write generated content to a Notion database with status "pending review." After human approval, a second n8n workflow (triggered by Notion status change) handles the actual publishing. This preserves quality control without sacrificing automation.

17.7 Cost Analysis

5 articles per day, ~1,200 words each. Per-article API costs:

Step Cost
RSS collection $0.000
AI relevance scoring × 50 items (GPT-4o-mini) ≈ $0.005
Content generation ~1,200 words (Claude 3.5 Sonnet) ≈ $0.028
Image prompt generation (GPT-4o-mini) ≈ $0.001
DALL-E 3 image × 1 ≈ $0.080
Per-article total ≈ $0.114

5 articles/day = ~$0.57/day or ~$17/month. Swap DALL-E for a self-hosted Stable Diffusion instance and the monthly cost drops under $5.

Rate this chapter
4.9  / 5  (12 ratings)

💬 Comments