I built an n8n workflow that researches, writes and publishes SEO articles for an education site (tavaschool.com). Five articles have gone live through it so far. Connecting the AI model was the easy part. Most of the work went into making its output predictable enough that the rest of the workflow never breaks. Here’s the approach I’d recommend if you’re building something similar.
1. Split the job into small AI steps
One giant prompt (“research, outline, write, add meta tags”) fails in unpredictable ways. Separate nodes work much better:
- Research / keyword brief
- Outline
- Section writer (loop over the outline)
- SEO meta (title, description, slug)
Each step gets one job and a short prompt, so when something goes wrong you know exactly which node to fix.
2. Ask for JSON, then enforce it
In the Basic LLM Chain node, turn on “Require Specific Output Format” and attach a Structured Output Parser. Example for the meta step:
{
"title": "string, max 60 characters",
"meta_description": "string, max 155 characters",
"slug": "string, lowercase, hyphens only"
}
If your model sometimes adds extra text around the JSON, put an Auto-fixing Output Parser on top. Downstream nodes can then use {{ $json.output.title }} safely.
3. Write the system prompt like a spec
A shape that works well:
- Role = who the model is
- Task = one sentence
- Rules = language, tone, length, what to never do
- Output = the exact format, nothing else
Rules beat adjectives. “Max 3 sentences per paragraph, no generic intro” works better than “write engaging content”.
4. Pass context with expressions
Feed the keyword and outline from earlier nodes into one prompt template with expressions, e.g. Keyword = {{ $(‘Brief’).item.json.keyword }}. One template then serves every article.
5. Plan for failure
- Retry On Fail on every AI and HTTP node, with a wait between tries
- An IF check after each AI step (empty output, too short, missing fields)
- An Error Trigger workflow that alerts you with the execution link
- Consider publishing as draft first, so a human glance happens before going live
6. Keep costs predictable
Use a cheaper model for research and meta, a stronger one only for the actual writing, and cap max tokens per node.
The main lesson for me: the prompt is only half of it. The other half is the structure around the model, which validates, retries and stops bad output before it reaches your CMS.
Happy to answer questions or share the node layout. How do you keep AI output stable in your n8n workflows?