← Back to library

Keep AI steps in an n8n content workflow from breaking

Amin Mahmodi (Amin_Mahmodi on the n8n forum) uses n8n to research, draft and post search-optimized articles for an education website, with five live so far. His lesson: connecting the model was easy, making its output predictable was the work. Small steps, enforced JSON, spec-like prompts, checks and draft-first publishing. We turn it into a build plan.

  • OutcomeBuild an n8n article pipeline from small single-purpose AI steps (brief, outline, section writing, page metadata), require structured JSON from each, check every output before it moves on, retry and alert on failures, publish as a draft for a human look, and run the lighter steps on a less expensive model.
  • SetupAn afternoon+
  • LevelIntermediate
  • CreditAmin_Mahmodi
View original
Works with
n8n

Published Nov 5, 2026Updated Nov 5, 2026AI dry run on sample input: passed Nov 5, 2026Source verified Nov 5, 2026

When should you use it?

  • An AI step in your workflow sometimes returns extra text, empty results or broken JSON
  • You want to publish articles through n8n without a person rebuilding each one
  • Model costs in a content workflow are hard to predict

Not for: Publishing straight to a live site with no human review; Topics where facts must be checked by an expert, unless that check is a step in the workflow; One-off articles, which are quicker to write with a chat assistant

What do you need, and what do you get?

You need

  • An n8n instance with an AI model credential
  • A keyword or topic list and your style rules
  • A CMS that accepts drafts through its API

You get

  • Separate AI nodes for brief, outline, section drafts and metadata
  • Structured JSON from each AI step, checked before use
  • Retries, error alerts with a link to the failed run, and draft posts awaiting review

How does it work, step by step?

  1. Split the jobUse one AI node each for the keyword brief, the outline, the sections (looping over the outline) and the title, description and slug.
  2. Require a formatTurn on structured output for each chain, attach a parser with the exact fields and length limits, and add an auto-fix parser if the model wraps its JSON.
  3. Write prompts as specsGive each system prompt a role, a one-sentence task, firm rules and the exact output, and pass earlier results in with expressions.
  4. Check and retryEnable retry with a pause on AI and HTTP nodes, add an IF check for empty, short or incomplete output, and connect an error workflow that alerts you.
  5. Publish as draftsSend finished articles to the CMS as drafts and approve them by hand before they go live.

The prompt

Our own prompt, inspired by Amin_Mahmodi and written to work in n8n. Values in lime are placeholders.

Fill in the blanks (optional; the copied prompt uses your values)

Prompt7 variables
You are the {step_name} step in an article workflow for {site}.

Task: {one_sentence_task}.
Rules: write in {language} for {audience}; paragraphs of at most three sentences; no generic opening; never state a figure that is not in the input.
Input from earlier steps: {previous_output}.
Return only JSON matching this schema, with no other text: {schema}.
If the input is missing something you need, return {"error": "<what is missing>"} instead of guessing.

Inspired by Amin_Mahmodi: n8n Community: prompting AI nodes for reliable output, lessons from a production content pipeline. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.

What can go wrong?

  • One big prompt for the whole article fails in ways you cannot trace. Keep each node to one job.
  • A parser only checks shape, not truth. Add a human review or fact-check step for claims and figures.
  • Retries on an HTTP publish step can create duplicate posts. Check for an existing draft before creating one.
  • Without token caps, a long section loop can surprise you on cost. Set a maximum per node.

Our take

Mahmodi's main point is one that most people learn the hard way: the prompt is half the job, and the scaffolding that inspects the model's output is the other half. His pipeline treats the model like an unreliable contractor whose work is inspected at every handoff. Each step has a single responsibility, returns a fixed JSON shape with length limits, and is checked before the next node touches it. That makes failures boring and traceable, which is exactly what you want in a workflow that runs unattended. We also like that the cost advice is specific, spending on the strong model only where writing quality matters, and that draft-first publishing keeps a person in the loop. Our additions: a structured parser proves the output has the right fields, not that its claims are true, so add a fact-check pass for figures, and guard the publish step against duplicates when retries fire. In our dry run of our prompt on a fictional tutoring company's keyword, the four steps returned valid JSON, the length check caught a 74-character title, and the retry produced a compliant one.

Where the time goes back: Articles arrive as reviewable drafts instead of broken runs you have to debug, and the checks and alerts mean you only step in when something actually fails.

FAQ

Why so many small AI nodes?
When every node handles a single task with a brief prompt, a bad result points straight to the node to fix. A single long prompt hides where it went wrong.
Which model should each step use?
He suggests paying for a more capable model only on the section drafts and using a less expensive one for the brief and metadata.
Does it publish automatically?
It can, but he recommends saving as a draft first so a person checks each article before it goes live.

Source and credit

Inspired by Amin_Mahmodi. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.

Inspired by
n8n Community: prompting AI nodes for reliable output, lessons from a production content pipeline
Creator
Amin_Mahmodi
Published on
n8n Community
Original date
Nov 4, 2026
License
Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
Originally for
n8n
AI dry run
Nov 5, 2026: passed. Dry-run tested by our AI test agent on sample input. Valid JSON per step, the length check caught an overlong title and the retry fixed it, and missing input produced an error object rather than a guess.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails.
Verified
Nov 5, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.

Are you the creator? Claim or correct this page.

More in Marketing

All 97 Marketing playbooks →

Related playbooks

MarketingPrompt✓ AI dry run

Explain a business process with a short animated walkthrough

Turn the documents that describe one of your processes into a short, vertical animated explainer for investors, new hires or clients, with every on-screen claim traced back to a file.

Credit: Avi Hacker, J.D.

Under an hour
MarketingWorkflow✓ AI dry run

Only show research findings whose quotes check out

Build research automations where the model must quote its source and a code step drops any finding whose quote isn't actually on that page.

Credit: u/Fit-Appointment700 on r/n8n

An afternoon+
MarketingSkill✓ AI dry run

Make an AI-built screen look designed with the unslop skill

Install Damir Sokolovsky's open unslop skill in Claude Code or Codex, point it at a dashboard, app screen, landing page or even a live URL, approve the short design direction it proposes from your product, and let it fix the screen in nine ordered passes, stopping early if the screen is already good.

Credit: Damir Sokolovsky (@heydamir)

Minutes
MarketingWorkflow✓ AI dry run

Run a freelance writing desk from one folder with Cowork

Let a desktop agent handle keyword research, topic overlap checks, first drafts in your style, the publishing tracker and image drafts, while you write the experience and do the final check.

Credit: 片倉慧@webライター

Under an hour
MarketingWorkflow✓ AI dry run

Turn one sheet row into an approved social post

Generate a caption and image from a spreadsheet row, write both back, ask for approval in team chat, then schedule the post.

Credit: u/willruzMtl on r/automation

Under an hour