Video Chapters
0:00 How I Made AI Write My Blogs For Me using n8n and OpenAI - Part 01
0:00 How I Turned One Blog Into 4 Social Posts Fast! [n8n Tutorial to Automate Social Media] - Part 02

AI Blog Writer

Learn AI Blog Writer in this comprehensive n8n tutorial. Step-by-step guide with video, code examples, and expert tips from the n8n Zero to Hero course.

Table of Contents

Overview

This lesson is part of the n8n AI Automation - Zero to Hero course, Section: 6. AI-Powered Workflows.

Watch the video above for the full tutorial, or read the written guide below.

What is the AI Blog Writer workflow in n8n?

The AI Blog Writer workflow in n8n connects a Google Sheet of content topics to OpenAI, producing an SEO-optimized blog post first, then using that post as input to generate Twitter, LinkedIn, Facebook, and YouTube script content. A status column in the source sheet tracks which topics are pending, and a separate AI Prompts sheet holds all platform-specific system and user prompts, keeping the workflow dynamic without hardcoded text.

How to build the AI Blog Writer workflow in n8n

The Google Sheets trigger fires on row added and runs every hour, preventing the workflow from publishing too fast. A second Google Sheets node fetches only the first row where the status column equals "pending," returning one topic at a time with its audience, tone, word count, domain/niche, and status fields. A manual trigger node pairs with this fetch step so you can test without waiting for a new sheet row.

The AI Prompts sheet stores five rows, one per platform: WordPress, Twitter, LinkedIn, Facebook, and YouTube. Each row holds a system prompt and a user prompt with double-curly-brace placeholders such as {{topic}}, {{word_count}}, {{tone}}, and {{domain_niche}}. A code node, generated by n8n's built-in Ask AI tab from a plain-English instruction, loops over all five prompt rows and replaces every placeholder with the matching value from the fetched topic row. Adding a new platform like TikTok only requires a new row in the AI Prompts sheet, not a new node in the canvas.

An IF node checks whether the content platform equals "WordPress" and routes that branch to an OpenAI node configured with the dynamic system and user prompts. The model returns a full HTML blog post wrapped in triple-backtick fences, so a Set Fields node strips those fences with a replaceAll expression before passing clean HTML to the WordPress node, which saves the post as a draft. The false branch from the IF node handles all social platforms, where each prompt receives the completed blog post as input rather than the raw topic title, keeping blog and social content consistent.

Key Takeaways

  • The AI Prompts Google Sheet stores system and user prompts for all five platforms (WordPress, Twitter, LinkedIn, Facebook, YouTube), making the workflow extensible without adding or rewiring nodes.
  • Double-curly-brace placeholders like {{topic}} and {{word_count}} in prompt text get replaced at runtime by a code node generated via n8n's Ask AI tab from a plain-English description, so no manual coding is required.
  • The IF node branches on content platform equals "WordPress" so the blog post is generated first; every social media prompt then uses that completed blog post as its input, not the original topic title.
  • The WordPress node saves posts in draft mode, giving you an editing checkpoint before anything goes live, because AI output needs human review for hallucinations and tone mismatches before publishing.
  • The status column in the topics sheet controls which rows the workflow processes, letting you queue content for multiple blogs or niches in a single sheet by adding columns like blog name.

Next Steps

Continue your n8n journey with the full n8n AI Automation - Zero to Hero course.

Frequently Asked Questions

The AI Prompts sheet decouples prompt logic from workflow structure. Each platform gets its own row with a system prompt and user prompt, so adding TikTok, for example, means adding one row to the sheet. The code node loops over all rows automatically, and the canvas needs no new nodes or rewiring.

The code node replaces double-curly-brace placeholders in both the system prompt and user prompt with real values from the fetched topic row. For example, `{{topic}}` becomes "Top 5 AI Tools for Solopreneurs" and `{{word_count}}` becomes 1200. n8n's Ask AI tab inside the code node generates this replacement logic from a plain-English instruction, so you don't write any code manually.

The IF node ensures the full blog post exists before any social content is created. Twitter, LinkedIn, Facebook, and YouTube prompts all receive the completed blog post as their input, not just the topic title. This keeps blog and social content connected and avoids the disconnected feel that comes from generating both independently from the same raw topic.

The OpenAI node wraps its HTML output in triple-backtick fences with an 'html' label. A Set Fields node uses a `replaceAll` expression to strip both the opening fence and the closing fence, leaving pure HTML. The WordPress node then receives that clean HTML and saves it as a draft post ready for manual review.

Dheeraj Sharma

Dheeraj Sharma

AI Systems Builder
Creator of the n8n Zero to Hero course (42 lessons, 31+ hours). I help solopreneurs build AI systems that grow revenue without growing workload.

Get the n8n Mastery Bundle

All workflows, cheat sheets, and premium resources from the entire course in one package.

Get Premium Resources