Build a RAG & GenAI App for WordPress with n8n

This workflow automates embedding your WordPress content into a vector database and enables Generative AI-powered chat on your website. Save hours on manual content indexing and enhance user engagement with live AI responses sourced from your site content.
wordpress
embeddingsOpenAi
postgres
+14
Workflow Identifier: 1160
NODES in Use: Manual Trigger, Wordpress, Merge, Set, Filter, Markdown, Token Splitter, Default Data Loader, Embeddings OpenAI, Supabase Vector Store, Schedule Trigger, Postgres, Switch, Loop Over Items, AI Agent, Respond to Webhook, Supabase
Automate RAG and GenAI with n8n and OpenAI

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

Learn how to Build this Workflow with AI:

What This Workflow Does

This workflow fetches all your WordPress posts and pages automatically. It cleans the HTML content and breaks it into small pieces. Then, it creates vector embeddings using OpenAI models to store in a database. When visitors ask questions, the workflow finds related content and answers using AI.

This stops you from doing the slow, hard work of manual indexing. It keeps the AI chat up to date and accurate with fresh website information. Visitors get better answers. You save time and improve your site interaction.


Tools and Services Used

  • n8n automation platform: Runs and manages the workflow.
  • WordPress REST API: Provides website posts and pages data.
  • OpenAI API: Generates text embeddings and chat completions.
  • Supabase or PostgreSQL (with pgvector): Stores vector embeddings for similarity search.

Inputs, Processing Steps, and Output

Inputs

  • Published and accessible WordPress posts and pages via REST API.
  • User chat messages sent to the webhook.
  • OpenAI API Key for embeddings and chat models.
  • Supabase or PostgreSQL database connection details.

Processing Steps

  1. Retrieve posts and pages using WordPress API node.
  2. Merge and filter content to keep only published and unprotected data.
  3. Convert HTML content to clean Markdown.
  4. Split Markdown content into 300 token chunks with overlaps.
  5. Generate embeddings for each chunk with OpenAI “text-embedding-3-small” model.
  6. Save vector embeddings and metadata into Supabase or PostgreSQL vector store.
  7. Use scheduled triggers to update only new or changed content incrementally.
  8. On receiving chat input, embed user message and find related chunks in vector store.
  9. Generate AI chat reply using GPT-4o-mini with context metadata.
  10. Send back AI answer via webhook response.

Output

  • Indexed and searchable vector store of WordPress content.
  • Real-time AI chat answers referencing content and metadata.
  • Logs of embedding and workflow executions for monitoring.

Who Should Use This Workflow

This is great for website owners or content managers who want fast AI chat on their WordPress sites. No need to do manual data exports or complicated indexing anymore. Anyone using n8n with WordPress, OpenAI, and a vector database can easily keep site content synced and ready for AI answers.

It works well for those with many posts and frequent content updates. Also useful for teams avoiding errors from manual embedding updates. It improves chat accuracy and visitor experience without extra manual work.


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

Step 1: Import Workflow

  1. Download the workflow file using the Download button on this page.
  2. Open n8n editor where you want to use the workflow.
  3. Click on “Import from File” and select the downloaded workflow file.

Step 2: Configure Credentials

  1. Set up WordPress API credentials with site URL and API Key if needed.
  2. Add your OpenAI API Key for embedding and chat models.
  3. Enter Supabase or PostgreSQL connection details, ensuring pgvector is enabled for PostgreSQL.

Step 3: Update Workflow Details

  1. If needed, update any IDs, email addresses, table names, or folder paths in nodes.
  2. Check Default Data Loader node and add any extra metadata fields you want included.
  3. If prompts or system messages for AI chat are shown in the Input fields, copy them exactly.

Step 4: Test Workflow Manually

  1. Use the Manual Trigger node to run the workflow once.
  2. Confirm it pulls posts/pages, converts content, creates embeddings, and stores them without errors.
  3. Use the chat webhook URL to send a test chat message and see if AI replies relevantly.

Step 5: Activate for Production

  1. Enable the Schedule Trigger node to start automatic updates every set time (default 30 seconds).
  2. Check execution logs regularly for problems.
  3. Consider self-host n8n for reliable uptime if not on cloud.

Customization Ideas

  • Change chunk size and overlap in the Token Splitter node to balance context and token use.
  • Add more custom metadata fields like tags or author info in the Default Data Loader.
  • Switch OpenAI models for cheaper or more powerful embeddings and chat responses.
  • Adjust schedule frequency for faster or slower incremental updates.
  • Secure chat webhook with authentication or IP whitelist in the Webhook node.

Troubleshooting Common Issues

  • OpenAI API rate limit errors: Occurs if too many requests sent quickly. Fix by slowing schedule trigger or adding delays.
  • WordPress API errors or empty data: Check credentials and API endpoint accessibility. Use tools like Postman to test.
  • PostgreSQL pgvector dimension mismatch: Make sure vector column matches OpenAI embedding size (1536 for text-embedding-3-small).

Pre-Production Checklist

  • Ensure WordPress, OpenAI, and Supabase/PostgreSQL credentials are correctly set in n8n.
  • Run setup SQL queries to enable pgvector and create required tables.
  • Test one full manual run from Manual Trigger pulling data and generating embeddings.
  • Send a test chat message to webhook and verify AI responses include correct content references.
  • Backup vector store database data before enabling scheduled workflow runs.

Deployment Guide

Turn on the Schedule Trigger node for periodic incremental embedding updates. Set the frequency based on how often new content is published on the WordPress site. Watch the n8n execution logs to catch errors fast.

Choose between n8n cloud or self-host n8n for hosting. Self-host helps control uptime and data privacy better. Keep logs of visitor chats to improve AI answers over time.


Summary of Result

✓ Saves hours by automating WordPress content indexing for AI chat.
✓ Keeps AI responses fresh and contextually accurate.
✓ Cuts manual errors and complex workflows.
✓ Enables real-time visitor questions answered with latest website data.
✓ Works with popular tools: WordPress API, OpenAI, Supabase/PostgreSQL, n8n.
✓ Suitable for users with little coding needing fast deployment.


Automate RAG and GenAI with n8n and OpenAI

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

The workflow copies published WordPress posts and pages, converts the content, creates vector embeddings with OpenAI, stores them in a database, and answers visitor questions with AI chat.
You need WordPress REST API access, OpenAI API Key for embeddings and chat, and either Supabase or PostgreSQL with pgvector for vector storage.
It uses a scheduled trigger to find new or changed posts since last run, re-embeds only updated content, and saves it, so the AI chat always uses fresh data.
Download the workflow file, import it in n8n, add required API credentials, update any IDs or prompts, test using Manual Trigger, then activate the schedule trigger for production.

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.