Automate Blog Writing and Publishing with n8n and OpenAI

Discover how this n8n workflow automates blog content creation and publishing for WordPress using Google Sheets and OpenAI. Save hours by streamlining your editorial process with automated content generation, scheduling, and posting via XML-RPC.
set
googleSheets
lmChatOpenAi
+7
Learn how to Build this Workflow with AI:
Workflow Identifier: 1067
NODES in Use: set, scheduleTrigger, manualTrigger, googleSheets, code, lmChatOpenAi, if, chainLlm, httpRequest, stickyNote

Press CTRL+F5 if the workflow didn't load.

Visit through Desktop for Best experience

Opening Problem Statement

Meet Sarah, the content manager for a busy marketing agency. Every week, she spends countless hours juggling article ideas, drafting blog posts, and manually publishing content on the company’s WordPress site. Managing editorial calendars in spreadsheets while juggling approvals often results in delays and errors that cost Sarah precious time and frustrate her team. What if Sarah could automate the entire blog post creation and publishing process based on a single Google Sheet schedule?

Manually coordinating multiple tools wastes at least 5 hours per week and risks inconsistent publishing schedules and duplicated work. Errors from copy-pasting content or forgetting to hit “publish” further delay marketing campaigns, negatively impacting audience engagement and revenue.

What This Automation Does ⚙️

This workflow automates blog post creation and publishing using the power of n8n, Google Sheets, OpenAI, and WordPress. When it runs, here’s what it accomplishes:

  1. Reads blog post schedules and configurations from a Google Sheet, enabling dynamic management of posts without changing the workflow.
  2. Generates blog post content automatically using OpenAI language models based on prompts and authoring stages defined in your sheet.
  3. Processes and prepares the generated content by replacing placeholders and normalizing data to fit your editorial structure.
  4. Publishes posts to WordPress automatically via XML-RPC calls with post title and content, supporting immediate publishing.
  5. Logs all actions and status updates back into Google Sheets for full tracking and auditing, so you know what happened and when.
  6. Allows scheduled or manual triggering, making it flexible for different editorial workflows.

By automating these steps, Sarah saves an estimated 4-6 hours weekly and reduces manual errors by 90%, allowing her to focus on strategy instead of busy work.

Prerequisites ⚙️

  • n8n account with basic familiarity — self-hosting optional 🔧
  • Google Sheets account with access to your editorial schedule and config sheets 📊
  • OpenAI API key or compatible OpenRouter credentials for AI content generation 🔐
  • WordPress account configured with Application Password for XML-RPC publishing 🔑

Step-by-Step Guide to Setup This Automated Blog Workflow

1. Setting Up Your Google Sheets

Configure two sheets in your spreadsheet:
Schedule sheet – where you list blog post topics, actions, statuses, publish times, and the AI prompts to use.
Config sheet – contains your authoring prompts for various stages, model settings, and other parameters.

Be sure your Google Sheets URL is accessible and you set it exactly in the Settings node’s urlSpreadsheet parameter.

Common mistake: Not updating Google Sheets URL or sheet names exactly can break the workflow.

2. Configure the Settings Node

In the Settings (Set) node, set your spreadsheet URL, WordPress site subdomain, username, and application password. This centralizes your credentials and URLs.

Expected outcome: These settings feed all downstream nodes dynamically.

3. Add Your Google Sheets Credentials in n8n

Navigate to Credentials in n8n and add your Google Sheets OAuth2 credentials to allow n8n to access your editorial spreadsheets securely.

Visual cue: You will see your Google Sheets nodes able to fetch and update sheets once credentials are correctly set.

4. Trigger Setup for Automation

Two triggers are included:
ScheduleTrigger node set to run hourly to check for scheduled posts.
ManualTrigger for running the workflow on demand.

This flexibility supports both automatic publishing and on-demand content generation.

5. Fetch Authoring Configuration

The fetchConfig Google Sheets node reads configuration data for prompt templates and models from the Config sheet.

This data is processed by the Config (Code) node which dynamically builds a key-value mapping for later use.

6. Load Scheduled Posts

The Schedule Google Sheets node loads rows from the schedule sheet based on the configured sheet name.

Note: Data includes blog post topics, scheduled times, current status, and desired action.

7. Prepare Data with Placeholder Replacement

The PreparedData (Code) node handles dynamic replacement of placeholders in prompts and config values based on each row’s content.

Javascript snippet: This code replaces all {{property}} placeholders in prompts with actual values from rows or config, enabling dynamic prompt crafting.

8. Check if an Action is Needed

The IfTakeAction (If) node evaluates if the current row requires an AI prompt execution based on whether the action differs from the status.

9. Validate If It’s Time to Publish

The IfScheduledNow (If) node compares the current timestamp with the scheduled date in the row to determine if the post should be published now.

10. Generate Content via OpenAI

The AgentLLM node calls OpenAI’s chat completion API using your configured prompt from your schedule.

Credential notes: Uses OpenRouter-compatible OpenAI credentials.

11. Normalize and Merge LLM Output

The RecombinedDataRow (Code) node cleans up AI output JSON to ensure proper formatting, merges results back into the row, and updates post status.

12. Prepare XML-RPC Payload for WordPress

PrepareXmlPost (Code) builds the XML request body needed to create or update posts on WordPress using your username and application password.

Important: Escapes XML reserved characters in titles and content to prevent malformed requests.

13. Post Content to WordPress via HTTP Request

The CreatePost (HTTP Request) node sends the XML-RPC request to the WordPress site endpoint /xmlrpc.php.

It uses POST method with raw XML payload and custom content headers.

14. Handle Publishing Response

The HandleXMLRPCResponse (Code) node parses the XML response, detects errors (fault codes), or extracts posted article IDs.

15. Log Publishing Outcome to Google Sheets

LogPublished and LogStatus Google Sheets nodes append entries recording success or error messages and update the schedule row’s status.

16. Update Post Status to Published

SetToPublish (Google Sheets) updates the post status in your schedule sheet after successful publishing.

Customizations ✏️

  • Change publishing action: In the Settings node, modify actionPublish from “publish” to another keyword to trigger differently.
  • Use a different LLM model: Adjust the model names in the Config sheet for different authoring stages.
  • Add more placeholders: Extend the PreparedData code node to support additional dynamic placeholders based on your editorial needs.
  • Switch WordPress endpoint: If using a custom domain, update urlWordpress in Settings to your actual site URL.
  • Schedule frequency: Change the ScheduleTrigger interval from hours to minutes or days depending on your publishing cadence.

Troubleshooting 🔧

Problem: “Google Sheets node returns empty data or authentication error.”
Cause: Incorrect or expired OAuth credentials.
Solution: Re-authenticate Google Sheets credentials in n8n and verify access to the configured spreadsheet.

Problem: “AI prompt returns empty or irrelevant content.”
Cause: Faulty or missing prompt templates in Config sheet.
Solution: Check Config sheet for properly defined prompt keys matching the exact action names.

Problem: “WordPress publishing fails with XML-RPC error.”
Cause: Wrong WordPress credentials or XML escaping issues.
Solution: Double-check WordPress username and _Application Password_, confirm correct endpoint URL, and review XML escaping logic in PrepareXmlPost code node.

Pre-Production Checklist ✅

  • Verify Google Sheets URLs and sheet names in the Settings node match your actual document and tab names.
  • Test credentials for Google Sheets and OpenAI/OpenRouter to ensure connectivity.
  • Run the workflow manually via ManualTrigger to validate initial setup.
  • Confirm that the Schedule sheet rows have future scheduled dates and appropriate action flags.
  • Ensure XML-RPC is enabled in your WordPress site and application password is valid.
  • Back up your Google Sheets data regularly before automated updates.

Deployment Guide

Activate the workflow in n8n by switching it from inactive to active.

The hourly ScheduleTrigger will now automatically check for posts to generate and publish.

Monitor the Log sheet in your spreadsheet for real-time status and error messages.

If needed, use manual trigger to run individual tests or push urgent content.

FAQs

  • Can I use other AI models besides OpenAI? Yes, replace AgentLLM node credentials with compatible APIs, ensuring prompt format compliance.
  • Does this consume many API credits? The workflow generates content only when new actions are detected, so usage depends on schedule volume.
  • Is my data secure? Credentials are stored safely in n8n, and data transmission uses standard encrypted APIs.
  • Can this scale for large editorial teams? Yes, by expanding your schedule sheet and possibly optimizing LLM calls for batching.

Conclusion

By following this guide, you’ve set up a powerful end-to-end automated blog writing and publishing system using n8n, Google Sheets, OpenAI, and WordPress. You’ve transformed tedious manual tasks into streamlined, scheduled executions that save you hours each week.

This automation ensures higher consistency, faster turnaround, and better content control, freeing you to focus on creativity and strategy instead of admin work.

Next steps? Experiment with adding social media posting nodes to share your blogs automatically or integrate SEO analysis tools to enhance content quality further.

Happy automating!

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free