Skip to main content

Smarter RAG agents with enriched retrieval and modular workflows

Workflow preview

Workflow preview
100%
Smarter RAG agents with enriched retrieval and modular workflows preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

An extendable RAG template to build powerful, explainable AI assistants — with query understanding, semantic metadata, and support for free tier tools like Gemini, Gemma and Supabase. Description T...

Best for

  • Internal Wiki automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.documentdefaultdataloader, n8n-nodes-base.stickynote, @n8n/n8n-nodes-langchain.textsplitterrecursivecharactertextsplitter, n8n-nodes-base.supabase, @n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.vectorstoresupabase, @n8n/n8n-nodes-langchain.embeddingsgooglegemini, n8n-nodes-base.formtrigger

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Alejandro Scuncia.

Original n8n.io source

1.1 Workflow description

Title
Smarter RAG agents with enriched retrieval and modular workflows
Workflow name
Smarter RAG agents with enriched retrieval and modular workflows

An extendable RAG template to build powerful, explainable AI assistants — with query understanding, semantic metadata, and support for free-tier tools like Gemini, Gemma and Supabase.

Description

This workflow helps you build smart, production-ready RAG agents that go far beyond basic document Q&A.

It includes:

✅ File ingestion and chunking

✅ Asynchronous LLM-powered enrichment

✅ Filterable metadata-based search

✅ Gemma-based query understanding and generation

✅ Cohere re-ranking

✅ Memory persistence via Postgres

Everything is modular, low-cost, and designed to run even with free-tier LLMs and vector databases.

Whether you want to build a chatbot, internal knowledge assistant, documentation search engine, or a filtered content explorer — this is your foundation.

⚙️ How It Works

This workflow is divided into 3 pipelines:

📥 Ingestion

  • Upload a PDF via form
  • Extract text and chunk it for embedding
  • Store in Supabase vector store using Google Gemini embeddings

🧠 Enrichment (Async)

  • Scheduled task fetches new chunks
  • Each chunk is enriched with LLM metadata (topics, use_case, risks, audience level, summary, etc.)
  • Metadata is added to the vector DB for improved retrieval and filtering

🤖 Agent Chat

  • A user question triggers the RAG agent
  • Query Builder transforms it into keywords and filters
  • Vector DB is queried and reranked
  • The final answer is generated using only retrieved evidence, with references
  • Chat memory is managed via Postgres

🌟 Key Features

  • Asynchronous enrichment → Save tokens, batch process with free-tier LLMs like Gemma
  • Metadata-aware → Improved filtering and reranking
  • Explainable answers → Agent cites sources and sections
  • Chat memory → Persistent context with Postgres
  • Modular design → Swap LLMs, rerankers, vector DBs, and even enrichment schema
  • Free to run → Built with Gemini, Gemma, Cohere, Supabase (free tier-compatible)

🔐 Required Credentials

|Tool|Use| |-|-|-| |Supabase w/ PostreSQL|Vector DB + storage| |Google Gemini/Gemma|Embeddings & LLM| |Cohere API|Re-ranking| |PostgreSQL|Chat memory|

🧰 Customization Tips

  • Swap extractFromFile with Notion/Google Drive integrations

  • Extend Metadata Obtention prompt to fit your domain (e.g., financial, legal)

  • Replace LLMs with OpenAI, Mistral, or Ollama

  • Replace Postgre Chat Memory with Simple Memory or any other

  • Use a webhook instead of a form to automate ingestion

  • Connect to Telegram/Slack UI with a few extra nodes

💡 Use Cases

  • Company knowledge base bot (internal docs, SOPs)

  • Educational assistant with smart filtering (by topic or level)

  • Legal or policy assistant that cites source sections

  • Product documentation Q&A with multi-language support

  • Training material assistant that highlights risks/examples

  • Content Generation

🧠 Who It’s For

  • Indie developers building smart chatbots
  • AI consultants prototyping Q&A assistants
  • Teams looking for an internal knowledge agent
  • Anyone building affordable, explainable AI tools

🚀 Try It Out!

Deploy a modular RAG assistant using n8n, Supabase, and Gemini — fully customizable and almost free to run.

1. 📁 Prepare Your PDFs
  • Use any internal documents, manuals, or reports in **PDF **format.

  • Optional: Add Google Drive integration to automate ingestion.

2. 🧩 Set Up Supabase
  • Create a free Supabase project

  • Use the table creation queries included in the workflow to set up your schema.

  • Add your *supabaseUrl *and *supabaseKey *in your n8n credentials.

> 💡 Pro Tip: Make sure you match the embedding dimensions to your model. This workflow uses Gemini text-embedding-04 (768-dim) — if switching to OpenAI, change your table vector size to 1536.

3. 🧠 Connect Gemini & Gemma
  • Use Gemini/Gemma for embeddings and optional metadata enrichment.

  • Or deploy locally for lightweight async LLM processing (via Ollama/HuggingFace).

4. ⚙️ Import the Workflow in n8n
  • Open n8n (self-hosted or cloud).

  • Import the workflow file and paste your credentials.

You’re ready to ingest, enrich, and query your document base.

💬 Have Feedback or Ideas? I’d Love to Hear

This project is open, modular, and evolving — just like great workflows should be :).

If you’ve tried it, built on top of it, or have suggestions for improvement, I’d genuinely love to hear from you. Let’s share ideas, collaborate, or just connect as part of the n8n builder community.

📧 [email protected]

🔗 Linkedin

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Default Data Loader

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1

Block 2 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Recursive Character Text Splitter

Type / Role
@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter - textSplitterRecursiveCharacterTextSplitter
Config choices
Version 1

Block 4 - Delete Old Doc Rows

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 5 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 6 - Insert into Supabase Vectorstore

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreSupabase - vectorStoreSupabase
Config choices
Version 1

Block 7 - Embeddings Google Gemini1

Type / Role
@n8n/n8n-nodes-langchain.embeddingsGoogleGemini - embeddingsGoogleGemini
Config choices
Version 1

Block 8 - On form submission

Type / Role
n8n-nodes-base.formTrigger - formTrigger
Config choices
Version 2.2

Block 9 - Extract from File

Type / Role
n8n-nodes-base.extractFromFile - extractFromFile
Config choices
Version 1

Block 10 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 11 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Get many rows

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 13 - Update a row

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 14 - Merge

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 15 - Wait

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 16 - Set File Data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 17 - Metadata Obtention

Type / Role
@n8n/n8n-nodes-langchain.googleGemini - googleGemini
Config choices
Version 1

Block 18 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 19 - Edit Fields

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 20 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Query Builder

Type / Role
@n8n/n8n-nodes-langchain.googleGemini - googleGemini
Config choices
Version 1

Block 22 - RAG Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2

Block 23 - Reranker

Type / Role
@n8n/n8n-nodes-langchain.rerankerCohere - rerankerCohere
Config choices
Version 1

Block 24 - Google Gemini 2.0 Flash

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Showing the first 24 of 32 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Smarter RAG agents with enriched retrieval and modular workflows
Complexity advanced
Nodes 32
Categories Internal Wiki, AI RAG
Author Alejandro Scuncia
Published 28 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/8008/8008.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Smarter RAG agents with enriched retrieval and modular workflows do?

An extendable RAG template to build powerful, explainable AI assistants — with query understanding, semantic metadata, and support for free tier tools like Gemini, Gemma and Supabase. Description T...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Internal Wiki, AI RAG use case.