π¬ Reindex markdown RAG chunks with Supabase pgvector and webhooks
β‘ 27 views Β· π¬ Document Extraction & Analysis
Description
Quick Overview
This workflow reindexes Markdown documentation into a Supabase Postgres pgvector table by fetching source docs from an HTTP API, chunking and embedding them via a Supabase Edge Function, upserting the vectors, and deleting stale chunks on a daily schedule or on-demand webhook.
How it works
- Runs daily on a schedule or triggers when a POST request hits the webhook endpoint.
- Fetches Markdown sources (for example FAQ and blog posts) from a configured HTTP API endpoint.
- Strips frontmatter, splits content on H2 sections, chunks long sections with overlap, and batches chunks for embedding.
- For each batch, calls a Supabase Edge Function to generate embeddings for the chunk texts.
- Upserts each chunkβs source, index, content, and pgvector embedding into a Supabase Postgres
rag_chunkstable using conflict updates. - After processing batches, deletes rows in
rag_chunkswhoseupdated_attimestamp is older than the current run to remove stale chunks.
Setup
- Add an HTTP Header Auth credential for the sources API request and for calling the Supabase Edge Function.
- Add Supabase Postgres credentials with access to the database where the vector table lives.
- Create a
public.rag_chunkstable with a pgvectorembeddingcolumn (matching your modelβs dimensions) and a primary key on(source, chunk_idx). - Update the sources API URL, the Supabase Edge Function
/embedURL, and (optionally) the daily schedule time and batch/chunk sizing constants to match your environment.
π Nodes Used
HTTP Request, Postgres, Webhook, Schedule Trigger
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File