Automate WordPress Blog Publishing with n8n & OpenAI

Struggling to manage content scheduling and publishing on WordPress efficiently? This unique n8n workflow leverages Google Sheets, OpenAI, and XML-RPC to automate blog post creation and publication, saving hours weekly and reducing errors.
googleSheets
lmChatOpenAi
httpRequest
+7
Learn how to Build this Workflow with AI:
Workflow Identifier: 2163
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

1. Opening Problem Statement

Meet Sarah, a content manager juggling multiple blog posts that must be scheduled and published precisely on her company’s WordPress site. Managing content ideas, scheduling, and manually publishing each post wastes Sarah nearly 4 hours weekly—time lost to copying, pasting, formatting, and error-checking. Missed deadlines and inconsistent formatting lead to lost audience engagement and a hit to the company’s online credibility.

This is exactly the challenge our automation workflow solves: it eliminates manual content publishing hassles by seamlessly integrating Google Sheets for content management, OpenAI’s language model for dynamic blog content generation, and XML-RPC calls to WordPress for direct publishing—all triggered automatically on a schedule.

2. What This Automation Does

When this n8n workflow runs, it fully automates blog publishing by doing the following:

  • Loads blog post drafts and scheduling details from a Google Sheet.
  • Fetches configurable prompts and settings for each post type from another sheet, enabling dynamic content generation.
  • Generates unique blog content via OpenAI’s language model tailored per post requirements.
  • Processes and normalizes AI output to fit WordPress publishing format.
  • Prepares and sends an XML-RPC request to WordPress to publish the post, including authentication and proper XML payload formatting.
  • Logs all activities and outcomes back to Google Sheets for transparency and review.

By automating the whole pipeline, Sarah saves approximately 4+ hours per week, avoids manual publishing mistakes, and keeps her editorial calendar seamlessly synced and up-to-date.

3. Prerequisites ⚙️

  • 📧 WordPress account with application password enabled (for XML-RPC publishing)
  • 📊 Google Sheets with two sheets: one for blog schedule, one for configuration prompts
  • 🔑 Google Sheets OAuth2 credentials in n8n
  • 🔐 OpenAI API (via OpenRouter) account for AI content generation
  • ⏱️ n8n account to build and host the automation workflow
  • Optional: Self-hosting n8n through services like Hostinger

4. Step-by-Step Guide

Step 1: Setup Google Sheets for Content Scheduling and Configuration

Create a Google Sheet with three tabs: Schedule (blog posts queue), Config (prompts and settings), and Log (for logging results). Use the URL in the Settings node.

Common Mistake: Forgetting to share the sheet with your Google service account or using incorrect document IDs in n8n.

Step 2: Configure the Settings Node with URLs and Credentials

In the Settings Set node, enter your Google Sheet URL, WordPress subdomain, username, application password, and sheet tab names. This centralizes your config values for easy maintenance.

You should see key-values loaded when you run the node manually.

Step 3: Setup Triggers to Run Workflow

Use the ScheduleTrigger node set to run every hour (or your preferred interval). A ManualTrigger can be employed to test the workflow manually.

Expected Outcome: Workflow triggers either on schedule or manually initiates updating tasks.

Step 4: Fetch Configuration Settings Dynamically

The fetchConfig Google Sheets node reads your config sheet. The following Config Code node converts key-value pairs into an accessible JSON to control prompts, output formats, and models dynamically per blog post.

Step 5: Pull Scheduled Blog Posts

The Schedule Google Sheets node loads blog post rows needing action based on status and scheduled time.

Step 6: Prepare Prompt and AI Input

The PreparedData Code node merges the blog row data with config placeholders—it’s where your prompt templates in Config sheet get filled dynamically. It also decides if an action (like publish or update) is needed.

replacePlaceholders function replaces variables like {{Topic}} within prompts with actual data from the row.

Step 7: Condition Checks Before Content Creation

Branches include the IfTakeAction and IfPromptExists nodes. They ensure the workflow only proceeds if the status requires action and a prompt string exists.

Step 8: Generate Content Using OpenAI Large Language Model

The Basic LLM Chain Langchain node sends the prepared prompts to OpenAI via your API credentials. The AI returns blog content per the specified model and prompt style captured in your Config.

Step 9: Normalize and Recombine AI Output

The RecombinedDataRow Code node processes AI responses. It parses possible malformed JSON from AI, merges generated text back into the blog row, and updates the status.

Step 10: Log Result Into Google Sheet for Transparency

The LogStatus node appends info about the action taken, status updates, or possible errors, providing an audit trail in your Log sheet.

Step 11: Publish Post to WordPress via XML-RPC

PrepareXmlPost Code node builds an XML request body with your blog title and AI-generated content. It escapes special XML characters and formats the request per WordPress API specs.

xmlRequestBody is then sent in the CreatePost HTTP Request node to your WordPress xmlrpc.php endpoint for posting.

Step 12: Process WordPress XML-RPC Response

HandleXMLRPCResponse Code node parses the XML response to detect success or errors, extracting post IDs or fault codes.

Step 13: Log Publishing Result

The LogPublished Google Sheets node logs successful post IDs or error messages in the Log sheet.

Step 14: Update Status to Published on Schedule Sheet

Upon successful publishing confirmed by the PostingSuccessful node, the SetToPublish Google Sheets node updates the blog post status to “publish”.

5. Customizations ✏️

  • Change Post Status Handling: Edit the Settings node’s actionPublish value to customize different post actions like draft or update.
  • Switch AI Models: Modify your Config sheet’s model keys (e.g., prompt_publish_model) to try different OpenAI models per blog stage.
  • Add Internal or External Links Automation: Extend prompts in the Config sheet and pass additional fields from Google Sheets when generating content.
  • Custom Publishing Timing: Adjust the ScheduleTrigger node interval to publish posts at specific times or according to editorial priorities.

6. Troubleshooting 🔧

Problem: “XML-RPC post failed with error code X”
Cause: Incorrect WordPress app password or XML formatting errors.
Solution: Check application password in Settings node and validate escaped XML in PrepareXmlPost code node.

Problem: “Google Sheets credentials error”
Cause: OAuth token expired or missing permissions.
Solution: Re-authenticate Google Sheets credentials in n8n, ensure sheets shared properly.

Problem: “OpenAI API call fails or returns no content”
Cause: Invalid API key or prompt syntax errors.
Solution: Validate your OpenAI API key in n8n and review prompt templates in Config sheet for proper placeholders.

7. Pre-Production Checklist ✅

  • Verify all Google Sheets URLs and sheet names in the Settings node.
  • Test OpenAI API connection with a simple prompt in the Langchain node.
  • Ensure WordPress application password works by manual XML-RPC test (outside n8n).
  • Check placeholder replacements by reviewing PreparedData node outputs.
  • Run full manual trigger test verifying log records in your Log sheet.

8. Deployment Guide

Activate the ScheduleTrigger node and save your workflow. Monitor runs in n8n for any errors or skipped items. Logs pushed to Google Sheets provide live audit. Adjust trigger frequency for balancing server load and publishing cadence.

9. FAQs

Q1: Can I use another blogging platform instead of WordPress?
A1: This workflow is tailored for WordPress via XML-RPC, but can be adapted if your platform offers a similar API.

Q2: Does this consume a lot of OpenAI API credits?
A2: Usage depends on text length and model choice; optimize prompts to minimize tokens.

Q3: Is my data secure?
A3: Use secured credentials in n8n, and avoid exposing API keys publicly.

10. Conclusion

With this detailed n8n workflow, you now have a hands-free system to manage, generate, and publish WordPress blog posts right from Google Sheets and OpenAI. You save hours weekly while minimizing manual errors and maintaining editorial flow.

Next, you might explore adding automatic social media sharing after publishing or incorporate feedback loops for content review. Embrace automation to focus more on content strategy than the details of execution!

Happy publishing!

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