Build a WordPress RAG & GenAI Chatbot with n8n Automation

This n8n workflow automates embedding WordPress content into a vector database and enables a context-rich GenAI chatbot. It solves the challenge of dynamically integrating updated website content for intelligent visitor interactions.
wordpress
embeddingsOpenAi
vectorStoreSupabase
+18
Workflow Identifier: 1308
NODES in Use: ManualTrigger, embeddingsOpenAi, documentDefaultDataLoader, textSplitterTokenSplitter, lmChatOpenAi, memoryPostgresChat, respondToWebhook, set, markdown, postgres, aggregate, wordpress, merge, httpRequest, supabase, splitInBatches, switch, chatTrigger, vectorStoreSupabase, agent, supabaseDeleteRow
Automate WordPress RAG chatbot with n8n and OpenAI

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

Learn how to Build this Workflow with AI:

What This Automation Does

This workflow collects your WordPress posts and pages that are live and not locked by password.

It changes HTML text into Markdown, then cuts it into small parts that fit an AI model’s limits.

These parts get turned into vectors — numbers that AI understands — and saved in a Supabase table.

There is also a Postgres database ready to remember chat talks with visitors.

You get a webhook chat interface where customers ask questions, and the AI answers using the latest site content.

This stops old content being used and saves you hours of manual work every time site content changes.


Who Should Use This Workflow

This workflow is for users who manage WordPress sites and want a smart chatbot that knows recent content.

If coding or manual updates confuse you, this automation helps by doing all content fetching, processing, and embedding automatically.

You also need to be okay with setting API keys and credentials in n8n for WordPress, OpenAI, Supabase, and Postgres.


Tools and Services Used

  • WordPress REST API: To get published posts and pages.
  • OpenAI API: To create embeddings and chat completions.
  • Supabase: Stores vector embeddings and tracks workflow runs.
  • Postgres with pgvector: Keeps chat memory for context-aware conversations.
  • n8n: Automates the whole process and runs the workflow.
  • Langchain integration: Powers the AI chat agent and memory storage.

Inputs, Processing Steps, and Output

Inputs

  • WordPress site with REST API access.
  • OpenAI API key with embedding and chat permissions.
  • Supabase project with tables for documents and embedding histories.
  • Postgres database with pgvector extension enabled.
  • n8n credentials configured for all services.

Processing Steps

  1. Fetch published posts and pages from WordPress.
  2. Filter out drafts and password-protected articles.
  3. Change HTML into Markdown format to keep text clean.
  4. Cut long texts into chunks of 300 tokens with 30-token overlap for embeddings.
  5. Format chunks as documents with metadata for context.
  6. Use OpenAI to generate vector embeddings for each chunk.
  7. Save vectors and metadata into Supabase vector store.
  8. Record workflow run times in Supabase for incremental updates.
  9. On schedule, fetch only changed documents since last run.
  10. Delete old embeddings for updated documents and insert new ones.
  11. When a chat message arrives, retrieve similar documents from Supabase.
  12. Use GPT-4o-mini with Postgres memory to reply to visitor questions, referencing content.
  13. Send AI-generated answer back through webhook response.

Output

Fresh vector embeddings stored in Supabase.

Updated chat memory in Postgres for better AI dialog.

Chat answers wired to a webhook ready for visitor interaction.


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

Step 1: Download and Import Workflow

  1. Click the Download button on this page to get the workflow file.
  2. Open your n8n editor.
  3. Use the “Import from File” option to load this workflow.

Step 2: Configure Credentials and Settings

  1. Add your WordPress API credentials in the nodes named WordPress – Get all posts and WordPress – Get all pages.
  2. Enter your OpenAI API key in nodes Embeddings OpenAI and AI Agent.
  3. Update Supabase API credentials in Supabase Vector Store and related nodes.
  4. Set Postgres database connection details in the chat memory nodes.
  5. Check metadata IDs or table names in nodes like Supabase – Store documents on Supabase and update if needed.

Step 3: Test the Workflow

  1. Run the workflow once manually by clicking “Execute Workflow” in the n8n editor.
  2. Watch the output and check that posts, pages, and embeddings are processed without errors.

Step 4: Activate for Production

  1. Switch the workflow status to “Active” to enable scheduled triggers.
  2. Use the webhook URL from the When chat message received node as your chat interface endpoint.

Note: If hosting n8n on your server or VPS, check self-host n8n for stable operation.


Customization Ideas

  • Change token chunk size or overlap in Token Splitter nodes to balance speed and memory.
  • Try higher-quality OpenAI models like “text-embedding-3-large” or GPT-4o in embedding and chat nodes.
  • Add filters to include custom post types or tags in Filter – Only published & unprotected content.
  • Write your own AI agent prompt in AI Agent to tailor responses by role or language.
  • Set error handling around API calls for retries or sending failure alerts.

Common Issues and Fixes

  • WordPress API authorization fails
    Make sure WordPress API credentials are correct and REST API is enabled.
  • Embeddings empty or wrong
    Check that the HTML to Markdown conversion outputs valid text and that chunks have content before embedding.
  • Chat returns no answers
    Verify Supabase documents table has vectors and the index is not corrupted; rerun embedding if needed.
  • Workflow runs too often and hits API limits
    Increase the scheduled trigger interval beyond 30 seconds to reduce calls.

Pre-Production Checklist

  • Verify WordPress API connection by testing data retrieval nodes.
  • Confirm Supabase tables exist with correct permissions.
  • Test OpenAI keys in embeddings and chat nodes.
  • Run manual trigger for initial full embedding.
  • Send test chat messages to check AI replies via webhook.
  • Backup your Postgres and Supabase data before scheduling workflow runs.

Deployment Guide

Turn on the workflow in n8n by setting status to Active.

Adjust the schedule trigger time according to how often the WordPress site updates new content.

Watch logs and Supabase inserts to catch error early.

Use the webhook URL from the When chat message received node to connect your chat frontend.

Summary

✓ Automatically keeps WordPress content updated in AI embeddings and chat memory.
✓ Saves time by removing manual syncing steps.
✓ Uses AI to give visitors accurate answers with latest site info.
✓ Runs inside n8n with scheduled and manual triggers.
✓ Works with WordPress REST API, OpenAI, Supabase, and Postgres memory.

→ Result is a live chatbot that understands your website content and updates itself without extra effort.

Automate WordPress RAG chatbot with n8n and OpenAI

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

Open the Wordpress – Get all posts and Wordpress – Get all pages nodes in n8n. Enter the API Key or username and password in the Authentication section.
Check the HTML To Markdown and Token Splitter nodes outputs. Make sure the content is converted properly and chunks contain text before embedding.
Yes, but nodes for vector storage and retrieval need changing to match the new database API. The current workflow is built for Supabase vector tables.
Send test messages to the webhook URL from the When chat message received node. You should get AI-generated replies that include site content references.

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.