Auto WordPress Blog Generator with GPT & Postgres in n8n

This workflow automates WordPress blog post creation using GPT for content, Postgres for category management, and media upload, saving hours of manual writing and publishing. It smartly picks the least-used category ensuring well-distributed posts.
scheduleTrigger
agent
postgres
+7
Workflow Identifier: 1111
NODES in Use: Schedule Trigger, HTTP Request, Code, Postgres, OpenAI Chat Model, Langchain Agent, Set, Merge, No Operation, Sticky Note
Auto blog posts with GPT and n8n

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

Learn how to Build this Workflow with AI:

What This Automation Does ⚙️

This workflow automates writing and publishing WordPress blog posts without manual work.
It picks a category that was used least recently, writes a unique SEO-friendly article, and posts it with a featured image.
This solves the problem of repetitive topics and slow publishing.

The system gets categories from WordPress, filters out ones not wanted, and tracks how often each is used in a Postgres database.
It uses AI to make fresh article titles and full blog content formatted with WordPress blocks.

Images get generated or placeholder ones created, downloaded, then uploaded to WordPress as featured media.
Finally, the post is published, and use data saved for next time.

This saves time and helps keep content fresh and organized.


Tools and Services Used

  • WordPress REST API: To get categories, upload media, and publish posts.
  • PostgreSQL database: Tracks category usage so posts have good topic variety.
  • OpenAI GPT API: Generates unique, SEO-friendly titles and full post content.
  • n8n automation platform: Runs the entire workflow in scheduled intervals.


Inputs, Processing, and Outputs

Inputs

  • WordPress domain URL and API credentials.
  • PostgreSQL database connection and credentials.
  • OpenAI API key for content generation.
  • Schedule trigger set to run periodically.

Processing Steps

  1. Load all categories from WordPress.
  2. Filter out unwanted categories with code.
  3. Query Postgres for recent category use.
  4. Select the least recently used category.
  5. Get last 10 headlines from Postgres for that category.
  6. Send info to OpenAI to get a new unique SEO title.
  7. Build the full article content formatted with WordPress HTML blocks via OpenAI.
  8. Create or get placeholder image URL for cover.
  9. Download the image and upload it to WordPress media.
  10. Combine all post data (title, content, image, category).
  11. Publish the post on WordPress.
  12. Update Postgres DB with usage info for category tracking.

Outputs

  • New WordPress post with fresh SEO content.
  • Post linked to a diverse category.
  • Featured image uploaded and assigned.
  • Postgres DB updated to track used category.


Beginner Step-by-Step: How to Use This Workflow in n8n

Prepare to Use the Workflow

  1. Download the workflow JSON file from the Download button on this page.
  2. Open your n8n editor where you manage workflows.
  3. Choose “Import from File” and upload the downloaded JSON to import this workflow.

Configure the Workflow Settings

  1. In the imported workflow, open the Config node and update the domain field with the actual WordPress site URL.
  2. Enter your WordPress API credentials in the HTTP Request nodes that post to the WordPress API.
  3. Make sure Postgres credentials and database details are correct in the Postgres nodes.
  4. Enter your OpenAI API key in the OpenAI Langchain Agent nodes.
  5. If excluded category IDs differ for your site, update the array of IDs in the Category Filter code node.

Test and Activate

  1. Run the workflow manually once inside n8n to check for errors.
  2. Check that posts are created correctly on your WordPress site.
  3. If all works right, activate the Schedule Trigger to run the workflow on its set schedule.
  4. Monitor logs regularly for any failures or API issues.
  5. For improved reliability, consider self-host n8n so the workflow runs from a stable environment.


Customizations ✏️

  • Change excluded categories by updating the excludeIds array in the Category Filter node.
  • Adjust posting frequency by changing the Schedule Trigger settings.
  • Improve images by plugging in an AI image generator instead of using placeholder URLs in the Placeholder creator node.
  • Refine the AI prompts in OpenAI Langchain Agent nodes to better fit your blog’s style or brand voice.
  • Extend Postgres table structure to store more post metadata like author or tags.


Troubleshooting 🔧

Cannot fetch categories: REST API returns 403 Forbidden

Security plugins might block WordPress REST API calls.
Try whitelisting your automation server’s IP or temporarily disable REST API restrictions.

OpenAI nodes fail with authentication error

Make sure the OpenAI API key entered in the nodes is valid and not expired.
Update credentials in n8n if needed.

Postgres node returns empty result or connection error

Check database credentials, ensure the used_categories table exists.
Test connection with a manual SQL query node.


Pre-Production Checklist ✅

  • Confirm WordPress URL is correct in Config node.
  • Test WordPress API using Load Categories node.
  • Ensure Postgres DB connects and has required table via Selecting recent.
  • Check OpenAI generates reasonable titles and content from AI Agent SEO Headings and AI Agent SEO writer.
  • Confirm Schedule Trigger is switched on.
  • Run a full test run manually and verify posted content.


Summary of Benefits and Results

✓ Saves many hours of writing and manual posting work.
✓ Keeps blog topics varied by tracking category use.
✓ Creates unique, SEO-friendly titles and content.
✓ Handles featured image creation and upload automatically.
✓ Publishes posts continuously on a schedule without delays.

Auto blog posts with GPT and n8n

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

This workflow is designed to work with PostgreSQL due to its specific queries. Using another database would require changing SQL commands and credentials setup.
The workflow uses OpenAI tokens mainly to generate post titles and content, minimizing API calls by only requesting needed text per post.
API credentials are stored securely in n8n and communication uses encrypted protocols, protecting blog content during automation.
Yes, but users should adjust the schedule trigger frequency and verify OpenAI and WordPress API rate limits to avoid overloads.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.