Christian Maribong

n8n / PROJECT USE CASE

Event-Driven Self-Cleaning RAG Architecture

A self-maintaining knowledge base built in n8n that auto-syncs Google Drive documents into a Supabase Vector Store, deletes stale embeddings on file updates, and powers an AI Agent with always-fresh contextual retrieval.

RAGSupabaseAI Agent

INTERACTIVE WORKFLOW DEMO

Change the source.
See the answer change.

Sample data · Browser simulation

This demo illustrates the workflow using local document records and keyword retrieval. It does not connect to Google Drive, n8n, Supabase, or a live AI model. Changes disappear when you reload.

  1. 01 / SOURCEDocument changedGoogle Drive
  2. 02 / CLEANRemove old recordsn8n workflow
  3. 03 / SYNCIndex fresh contentSupabase
  4. 04 / RETRIEVEUse current contextAI agent

1. Edit the source

Try changing the refund window from 14 to 30 days.

Source and index are in sync.

2. Inspect the stored knowledge

The previous record is removed before the updated version is stored.

Version
1
Active records
1
Old records removed
0
customer-policy:v1

Refunds are available within 14 days of purchase. Contact support@example.com with your order number to request a refund.

  1. Sample policy loaded into the demo index.

3. Ask the knowledge base

Ask before syncing to see the old text, then sync and ask again.

RETRIEVED SOURCE TEXT · NOT AI-GENERATED

Select “Retrieve answer” to query the indexed policy.

THE BUSINESS NEED

Keep an AI assistant’s knowledge up to date

The challenge

An AI assistant needs current reference material. When a source document changes, old embeddings can leave outdated information in the knowledge base.

My role

I built an n8n workflow connecting Google Drive, a Supabase Vector Store, and an AI agent, including logic to remove stale embeddings when files change.

How the workflow works

  1. Use Google Drive documents as the source knowledge.
  2. Synchronize document content into the Supabase Vector Store through n8n.
  3. Remove stale embeddings on file updates so retrieval uses the refreshed content.
  4. Provide the AI agent with contextual retrieval from the maintained knowledge base.

WHAT THE SYSTEM DELIVERS

The workflow maintains the connection between changing source documents and the AI agent’s retrieval store. Updating the knowledge source becomes part of the automated process.

n8n · Google Drive · Supabase · AI agent

Event-Driven Self-Cleaning RAG Architecture workflow overview
Workflow overview · Select the image to inspect it at full size.

HAVE A SIMILAR CHALLENGE?

Let’s connect
the right pieces.

Discuss your automation project ↗
← Explore all automation projects