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
Settingsnode’sactionPublishvalue 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
ScheduleTriggernode 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
Settingsnode. - 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
PreparedDatanode 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!