An n8n multi-agent pipeline that turns a single topic into a researched, fact-checked, illustrated, publication-ready Medium article — fully automated.
Drop a topic into a Google Sheet (or click Test), and a fixed chain of five specialized sub-agents researches the topic on the live web, generates a custom architecture diagram, sources a royalty-free hero image, writes the article, fact-checks it against the research, and delivers it by email with the Markdown attached.
| Stage | Output | |
|---|---|---|
| 🔎 | Research | Live web search with inline citations, grounded facts |
| 📊 | Diagram | A custom architecture diagram generated per topic (Excalidraw → Kroki SVG) |
| 🖼️ | Image | A royalty-free hero image with proper attribution (Unsplash) |
| ✍️ | Write | A structured Medium article in Markdown, grounded in the research |
| ✅ | Fact-check | An automated QA gate that scores the draft before delivery |
| 📬 | Deliver | Email with the .md attached + a best-effort local file export |
The pipeline runs as a deterministic chain — each stage is a separate n8n sub-workflow invoked in a fixed order by the main orchestrator.
flowchart TD
subgraph Trigger
A["📄 New Topic Row<br/>(Google Sheets)"]
B["▶️ Manual Test Run"]
end
A --> C["Extract Topic"]
B --> C
C --> R["🔎 Run Research<br/>sub-agent"]
R --> D["📊 Run Diagram<br/>sub-agent"]
D --> I["🖼️ Run Image<br/>sub-agent"]
I --> W["✍️ Run Writer<br/>sub-agent"]
W --> AS["🧩 Assemble Final<br/>Markdown + HTML<br/>embeds hero + diagram"]
AS --> Q["✅ Run QA<br/>sub-agent"]
Q --> QP{"QA Passed?"}
QP -->|yes| PM["Publish to Medium"]
PM --> POK{"Published OK?"}
QP -->|no| PE["Prepare Export"]
POK -->|no| PE
PE --> EM["📬 Email Article<br/>(.md attached)"]
PE --> EX["💾 Export Markdown File<br/>best-effort"]
classDef agent fill:#eef6ff,stroke:#3b82f6,color:#1e3a8a;
class R,D,I,W,Q agent;
| Sub-workflow | Role | Key nodes |
|---|---|---|
workflows/research-agent-subworkflow.json |
Web research & verification | LLM Agent + OpenAI web_search tool |
workflows/diagram-agent-subworkflow.json |
LLM designs a flow spec → code builds valid Excalidraw → Kroki renders SVG | Diagram Agent → Build Excalidraw Scene → Render (Kroki) → Data URI |
workflows/image-agent-subworkflow.json |
Royalty-free hero image | Clean Query → Search Unsplash → (fallback) → Extract URL |
workflows/writer-agent-subworkflow.json |
Writes the article in Markdown | Writer Agent (grounded in research) |
workflows/qa-agent-subworkflow.json |
Fact-check gate (pass/fail + score) | QA Agent |
An earlier version used one AI Agent node with the five sub-agents attached as tools. The LLM orchestrator routinely skipped steps — it would write the article itself and never call the diagram/image/QA tools, because tool-calling is non-deterministic and conflicts with a required fixed sequence.
The main workflow now invokes each sub-agent explicitly with Execute Sub-workflow nodes, so every step runs every time, in order. Each sub-agent still uses an LLM internally where reasoning is actually needed.
The system generated this end-to-end for the topic "LangChain Architecture":
| Article (with hero + citations) | Auto-generated diagram |
|---|---|
![]() |
![]() |
The image sub-agent handles sparse topics gracefully — cleaning the search query and falling back to a striking abstract-tech image when a niche term returns no results:
And every run executes cleanly through all nodes:
- n8n — workflow orchestration (Execute Sub-workflow chaining)
- OpenAI GPT — chat models for research, writing, QA +
web_searchtool - Kroki / Excalidraw — programmatic diagram rendering (→ SVG)
- Unsplash API — royalty-free hero images
- Google Sheets — topic queue / trigger
- SMTP — email delivery
- JavaScript — Code nodes for assembly, parsing, and Excalidraw scene building
All credentials live in n8n's encrypted credential store — never in the JSON files.
- Import all six workflows into n8n (Workflows → Import from File).
- Activate the five sub-workflows (research / diagram / image / writer / qa). Execute Sub-workflow calls require the called workflow to be active. Leave the main workflow inactive until you want the automatic Sheets trigger.
- OpenAI credential (
openAiApi) — used by the research, diagram, writer, and qa sub-agents. - Unsplash credential — Header Auth (
httpHeaderAuth): NameAuthorization, ValueClient-ID <your-unsplash-access-key>. Select it on theSearch Unsplashnode. - Google Sheets — add a Google Sheets OAuth credential and set the document ID on the
New Topic Rowtrigger. Columns:Topic(required),Audience,Notes(optional). - SMTP — bind your mail credential to the
Email Articlenode. - Test with the Manual Test Run node (no sheet needed), or click Test workflow.
| File | Role |
|---|---|
workflows/medium-article-generator-workflow.json |
Main chain — import and open this one |
workflows/research-agent-subworkflow.json |
Web research & verification |
workflows/diagram-agent-subworkflow.json |
Excalidraw → Kroki SVG diagram |
workflows/image-agent-subworkflow.json |
Unsplash hero image |
workflows/writer-agent-subworkflow.json |
Markdown article writer |
workflows/qa-agent-subworkflow.json |
QA / fact-check gate |
- Medium's public API is retired (no new tokens since 2023), so the publish node fails by design and routes to the email + file fallback. Delivery is resilient: email (with the
.mdattached) is the primary output and runs in parallel with a best-effort local file write. - Kroki uses the public
kroki.ioinstance (data leaves your network, rate-limited) — self-host for production. Diagrams embed as a base64 data URI, great for the.md/HTML/email but stripped by Medium's importer (host the SVG at a URL for true Medium embedding). - OpenAI
web_searchavailability depends on account/model access — swap the research HTTP tool for SerpApi/Tavily if unavailable. - Hero images use Unsplash (an earlier OpenAI Images path was dropped due to a key without Images entitlement); the extractor can be repointed to
POST /v1/images/generationsif you have image access.
Built with n8n. Free to adapt.




