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

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

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

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.

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 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 Workflows in n8n

A complete beginner guide to building an AI 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