RAG & GenAI App With WordPress Content n8n Workflow Template

n8n workflow template · 45 nodes · OpenAI

RAG & GenAI App With WordPress Content is a free n8n workflow template that runs on a schedule and works with OpenAI, Postgres, WordPress and Supabase. It has 45 nodes, 14 of them AI nodes (OpenAI Embeddings, Default Data Loader, Token Splitter and OpenAI Chat Model).

At a glance

Trigger
Schedule Trigger (Every 30 seconds)
Nodes
45
Apps
OpenAI, Postgres, WordPress and Supabase
AI nodes
14
Credentials
None
Category
RAG, documents and vector search

Apps and integrations

  • OpenAI
  • Postgres
  • WordPress
  • Supabase

Node types used

  • Manual Trigger
  • OpenAI Embeddings
  • Default Data Loader
  • Token Splitter
  • OpenAI Chat Model
  • Postgres Chat Memory
  • Respond to Webhook
  • Edit Fields (Set)
  • Markdown
  • Postgres
  • Aggregate
  • WordPress
  • Filter
  • Supabase
  • Schedule Trigger
  • HTTP Request
  • Loop Over Items
  • Supabase Vector Store
  • Merge
  • Switch
  • Chat Trigger
  • AI Agent

How it works

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

Workflow 1: Initial Embedding

Use this workflow to create the initial embedding for your WordPress website content

Workflow 3: Use this workflow to enable chat functionality with your website content. The chat can be embedded into your website to enhance user experience

Run these two nodes if the "documents" table on Supabase and the "[redacted]" table do not exist

Use filters to create embeddings only for content that you want to include in your GenAI application

Retrieve documents from Supabase immediately after chat input to send metadata to OpenAI

Workflow 2: Upsert

Use this workflow to upsert embeddings for documents stored in the Supabase vector table

Set this node to match the frequency of publishing and updating on your website

Switch

  • If the document exists and has been updated: delete rows and insert new embedding
  • If it’s a new document: insert embedding

Nodes in this workflow

The 45 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:

  1. When clicking ‘Test workflow’ (Manual Trigger)
  2. Embeddings OpenAI (OpenAI Embeddings)
  3. Default Data Loader (Default Data Loader)
  4. Token Splitter (Token Splitter)
  5. Embeddings OpenAI1 (OpenAI Embeddings)
  6. OpenAI Chat Model (OpenAI Chat Model)
  7. Postgres Chat Memory (Postgres Chat Memory)
  8. Respond to Webhook (Respond to Webhook)
  9. Set fields (Edit Fields (Set))
  10. Embeddings OpenAI2 (OpenAI Embeddings)
  11. Default Data Loader1 (Default Data Loader)
  12. Token Splitter1 (Token Splitter)
  13. Markdown1 (Markdown)
  14. Postgres (Postgres)
  15. Aggregate (Aggregate)
  16. Aggregate1 (Aggregate)
  17. Aggregate2 (Aggregate)
  18. Wordpress - Get all posts (WordPress)
  19. Wordpress - Get all pages (WordPress)
  20. Set fields1 (Edit Fields (Set))
  21. Filter - Only published & unprotected content (Filter)
  22. HTML To Markdown (Markdown)
  23. Supabase - Store workflow execution (Supabase)
  24. Every 30 seconds (Schedule Trigger)
  25. Wordpress - Get posts modified after last workflow execution (HTTP Request)
  26. Wordpress - Get posts modified after last workflow execution1 (HTTP Request)
  27. Set fields2 (Edit Fields (Set))
  28. Filter - Only published and unprotected content (Filter)
  29. Loop Over Items (Loop Over Items)
  30. Set fields3 (Edit Fields (Set))
  31. Set fields4 (Edit Fields (Set))
  32. Store documents on Supabase (Supabase Vector Store)
  33. Store workflow execution id and timestamptz (Supabase)
  34. Aggregate documents (Aggregate)
  35. Postgres - Create documents table (Postgres)
  36. Postgres - Create workflow execution history table (Postgres)
  37. Merge Wordpress Posts and Pages (Merge)
  38. Merge retrieved WordPress posts and pages (Merge)
  39. Postgres - Filter on existing documents (Postgres)
  40. Supabase - Delete row if documents exists (Supabase)
  41. Switch (Switch)
  42. When chat message received (Chat Trigger)
  43. Supabase - Retrieve documents from chatinput (Supabase Vector Store)
  44. AI Agent (AI Agent)
  45. Supabase Vector Store (Supabase Vector Store)

Credentials you need

The workflow JSON lists no credentials. Nodes that call external services may still need credentials after you import it.

How to import into n8n

  1. Download the JSON file with the button above.
  2. In n8n, open a new workflow, select the ... menu and choose Import from File. You can also paste the JSON straight into the editor canvas.
  3. Open each node that shows a warning and select or create its credential.
  4. Read the notes on the canvas, test the workflow with sample data, then activate it.

Do you need somewhere to run it? Read our guide to self-hosted n8n.

Need this customised?

We can adapt this workflow to your apps, data and process, then deploy and support it.

Contact Us