How I Built a $0 Automated Content Pipeline: n8n + OpenRouter + ComfyUI + WordPress

n8n workflow overview

Written by

in

Over the past month I built an automated content pipeline that generates 2500+ word SEO articles, creates images, and publishes to WordPress — all for free. Here is exactly how it works, what it cost, and the real Rank Math scores it achieves.

What the Pipeline Does

The pipeline runs daily and performs these steps:

  • Research: Queries SearXNG for trending topics in AI/automation niches
  • Generation: Uses OpenRouter’s gpt-oss-120b:free model to write 2500+ word articles in two parts (Part A + Part B concatenated)
  • SEO Structure: Injects Rank Math TOC shortcode, FAQ blocks, internal/external links, anchor-linked headings
  • Images: Generates hero image via ComfyUI (juggernaut model), uploads 4 inline images
  • Publishing: Creates WordPress post, sets Rank Math meta, uploads images, publishes if score ≥ 81
  • Social: Posts to X and LinkedIn (when bridge is running)

Pipeline Architecture

Pipeline Architecture

The pipeline is a single Python script (~1100 lines) running in WSL, not a complex n8n workflow. n8n handles image generation and has webhooks for WordPress publishing, but the orchestration is local Python. This keeps it simple and debuggable.

The n8n Workflows

n8n runs on Docker at 172.30.0.10:5678 with 100+ workflows. Three are critical to the pipeline:

n8n Overview
  • ComfyUI Image Gen (WDiBQ0A8n49Gd7MO): Receives a prompt, calls ComfyUI API on Windows host, returns the image URL. ~20s runtime.
  • WP Publish (0RdzR0MKwrQtXIk9): Creates WordPress post, sets Rank Math meta, handles media upload via upload-media.php. Auth via app password.
  • SEO Article Writer (mQNioKkECklJd24i): Generates 2500+ word articles via groq webhook. ~75s runtime.

Cost Comparison: Manual vs Automated

Cost Comparison
MethodCost/articleTime/articleSEO Score
Manual writer (Fiverr)$503-4 hoursVaries
ChatGPT API (gpt-4o)$85 min~70
OpenRouter (gpt-oss-120b:free)$05 min~85
This pipeline$0~6 min85-91

SEO Score Evolution

SEO Score Evolution

We iterated from 55 to 91 by fixing specific Rank Math score factors:

  • v2: Added TOC (table of contents) → +10 points
  • v3: Added inline images → +6 points
  • v4: Added keyword in slug, proper TOC classes → +10 points
  • v5: Fixed heading keyword stuffing → +5 points
  • v6: Added image alt text → +5 points
  • v7: Removed hero image duplication, fixed TOC to shortcode → stabilized at 85

Key Technical Decisions

Two-Part Generation

Single API calls cap at ~2000 tokens output. We split generation into Part A (intro + setup) and Part B (advanced + troubleshooting + FAQ), concatenating them. This reliably produces 2500+ rendered words.

Focus Keyword in URL

Rank Math penalizes slugs that don’t contain the focus keyword. We build the slug from the focus keyword (e.g., “best-free-ai-tools”) not the full title. Short, keyword-rich URLs score higher.

Rank Math TOC Shortcode

Raw HTML TOC divs don’t collapse. Using the [rank_math_table_of_contents] shortcode gives you the native Rank Math JS with collapsible sections and proper styling.

What Still Needs Work

  • Social posting: The bridge at 172.30.0.6:9121 is down. Need to route through n8n webhooks instead.
  • Image alt text: Using focus keyword as alt — could be more descriptive.
  • Topic selection: Currently random from 10 niches. Should use actual search volume data.
  • Internal linking: Links to slugs that may not exist yet. Need to check post existence first.

Source Code

The pipeline script is at /workspace/scripts/auto_content_pipeline.py (~1121 lines). Key functions:

generate_article(title, focus_keyword)     # Two-part OpenRouter generation
inject_seo_structure(content, title, kw)   # TOC, links, FAQ
publish_wordpress(title, content, kw, ...) # REST API + Rank Math meta
verify_score(post_id, focus_keyword)       # Parse actual post content

For the full setup — n8n Docker Compose, WordPress config, ComfyUI API — check the infrastructure docs in /workspace/infra/.

[rank_math_table_of_contents]

How much does the pipeline cost to run?

$0. The OpenRouter model (gpt-oss-120b:free) has no cost. ComfyUI runs on local RTX 3090. WordPress hosting is already paid. The only cost is electricity.

Can this scale to multiple posts per day?

Yes. Each post takes ~6 minutes end-to-end. The bottleneck is ComfyUI image generation (~1 min per image, 5 images per post). Running 10 posts/day would take ~1 hour.

Why Rank Math score 85 and not 95?

95 requires perfect keyword density, readability, and AI detection scores. Current models (gpt-oss-120b) are not large enough to hit 95 reliably. The practical ceiling with free-tier models is 85-91.

Is the content unique?

Yes. Each article is generated fresh with live SearXNG research context. No spinning or rewriting. The two-part generation produces original content every run.

What is the biggest technical challenge?

Image pipeline reliability. ComfyUI occasionally fails to generate, and inline image URLs need to be swapped from private ComfyUI IPs to public WordPress URLs after upload. We fixed this by always updating post content after all uploads complete.