Back to Catalog

Smarter RAG agents with enriched retrieval and modular workflows

Alejandro ScunciaAlejandro Scuncia
2078 views
2/3/2026
Official Page

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.

📧 ascuncia.es@gmail.com

🔗 Linkedin

Smarter RAG Agents with Enriched Retrieval and Modular Workflows

This n8n workflow demonstrates how to build a sophisticated Retrieval-Augmented Generation (RAG) agent. It leverages modular components for data ingestion, vector storage, and conversational AI, enabling smarter agents with enriched retrieval capabilities.

What it does

This workflow is designed to handle two primary use cases:

1. Document Ingestion and Vectorization (Scheduled or Manual Trigger):

  1. Triggers on a Schedule: The workflow can be configured to run periodically (e.g., daily, weekly) to check for new documents.
  2. Extracts from File: It extracts content from a specified file (e.g., PDF, text, CSV).
  3. Loads Data: The extracted data is loaded into a structured format.
  4. Splits Text: The document content is broken down into smaller, manageable chunks using a Recursive Character Text Splitter. This is crucial for effective vectorization and retrieval.
  5. Generates Embeddings: Google Gemini Embeddings are generated for each text chunk, converting them into numerical representations.
  6. Stores in Supabase Vector Store: These embeddings, along with their original text, are then stored in a Supabase Vector Store, making them searchable for retrieval.

2. Conversational AI Agent with Enriched Retrieval (Chat Trigger):

  1. Triggers on Chat Message: The workflow activates upon receiving a chat message (e.g., from a user in a chat interface).
  2. Initializes AI Agent: An AI Agent is instantiated, configured to use a Google Gemini Chat Model for conversational capabilities.
  3. Manages Chat Memory: It utilizes Postgres Chat Memory to maintain conversation history, allowing the agent to understand context across turns.
  4. Retrieves Relevant Information: The AI Agent queries the Supabase Vector Store using the user's chat message to retrieve the most relevant document chunks (based on embeddings).
  5. Reranks Retrieved Documents: A Cohere Reranker is used to further refine the retrieved documents, ensuring the most pertinent information is prioritized.
  6. Generates Response: The AI Agent, combining the user's query, chat history, and the enriched retrieved information, generates a comprehensive and contextually relevant response.
  7. Processes and Merges: The generated response is processed and merged with other workflow outputs before being sent back to the user.

Prerequisites/Requirements

To use this workflow, you will need:

  • n8n Instance: A running n8n instance.
  • Supabase Account: For storing vectorized document chunks. You'll need credentials (Project URL, API Key).
  • Google Cloud Account: For Google Gemini Embeddings and Chat Model. You'll need an API Key.
  • Cohere Account: For the Cohere Reranker. You'll need an API Key.
  • PostgreSQL Database: For storing chat memory (can be part of Supabase or a separate instance). You'll need connection details.

Setup/Usage

  1. Import the workflow: Download the provided JSON and import it into your n8n instance.
  2. Configure Credentials:
    • Set up your Supabase credentials for the "Supabase Vector Store" node.
    • Set up your Google Gemini credentials for the "Embeddings Google Gemini" and "Google Gemini Chat Model" nodes.
    • Set up your Cohere credentials for the "Reranker Cohere" node.
    • Configure your Postgres credentials for the "Postgres Chat Memory" node.
  3. Configure Triggers:
    • Schedule Trigger: Adjust the schedule (e.g., daily, hourly) in the "Schedule Trigger" node based on how frequently you want to ingest new documents.
    • n8n Form Trigger / Chat Trigger: If using the form trigger for manual document upload, ensure the form fields are correctly mapped. If using the chat trigger, ensure it's connected to your desired chat platform (e.g., Slack, Telegram, custom webhook).
  4. Specify Document Source: In the "Extract from File" node, configure the source of your documents (e.g., a specific file path, a binary input from a previous node).
  5. Activate the Workflow: Once configured, activate the workflow in n8n.

You can now either:

  • Manually trigger the document ingestion path via the "n8n Form Trigger" (if configured) or let the "Schedule Trigger" handle it.
  • Interact with the AI agent by sending messages to the configured "Chat Trigger."

Related Templates

Generate song lyrics and music from text prompts using OpenAI and Fal.ai Minimax

Spark your creativity instantly in any chat—turn a simple prompt like "heartbreak ballad" into original, full-length lyrics and a professional AI-generated music track, all without leaving your conversation. 📋 What This Template Does This chat-triggered workflow harnesses AI to generate detailed, genre-matched song lyrics (at least 600 characters) from user messages, then queues them for music synthesis via Fal.ai's minimax-music model. It polls asynchronously until the track is ready, delivering lyrics and audio URL back in chat. Crafts original, structured lyrics with verses, choruses, and bridges using OpenAI Submits to Fal.ai for melody, instrumentation, and vocals aligned to the style Handles long-running generations with smart looping and status checks Returns complete song package (lyrics + audio link) for seamless sharing 🔧 Prerequisites n8n account (self-hosted or cloud with chat integration enabled) OpenAI account with API access for GPT models Fal.ai account for AI music generation 🔑 Required Credentials OpenAI API Setup Go to platform.openai.com → API keys (sidebar) Click "Create new secret key" → Name it (e.g., "n8n Songwriter") Copy the key and add to n8n as "OpenAI API" credential type Test by sending a simple chat completion request Fal.ai HTTP Header Auth Setup Sign up at fal.ai → Dashboard → API Keys Generate a new API key → Copy it In n8n, create "HTTP Header Auth" credential: Name="Fal.ai", Header Name="Authorization", Header Value="Key [Your API Key]" Test with a simple GET to their queue endpoint (e.g., /status) ⚙️ Configuration Steps Import the workflow JSON into your n8n instance Assign OpenAI API credentials to the "OpenAI Chat Model" node Assign Fal.ai HTTP Header Auth to the "Generate Music Track", "Check Generation Status", and "Fetch Final Result" nodes Activate the workflow—chat trigger will appear in your n8n chat interface Test by messaging: "Create an upbeat pop song about road trips" 🎯 Use Cases Content Creators: YouTubers generating custom jingles for videos on the fly, streamlining production from idea to audio export Educators: Music teachers using chat prompts to create era-specific folk tunes for classroom discussions, fostering interactive learning Gift Personalization: Friends crafting anniversary R&B tracks from shared memories via quick chats, delivering emotional audio surprises Artist Brainstorming: Songwriters prototyping hip-hop beats in real-time during sessions, accelerating collaboration and iteration ⚠️ Troubleshooting Invalid JSON from AI Agent: Ensure the system prompt stresses valid JSON; test the agent standalone with a sample query Music Generation Fails (401/403): Verify Fal.ai API key has minimax-music access; check usage quotas in dashboard Status Polling Loops Indefinitely: Bump wait time to 45-60s for complex tracks; inspect fal.ai queue logs for bottlenecks Lyrics Under 600 Characters: Tweak agent prompt to enforce fuller structures like [V1][C][V2][B][C]; verify output length in executions

Daniel NkenchoBy Daniel Nkencho
601

Auto-reply & create Linear tickets from Gmail with GPT-5, gotoHuman & human review

This workflow automatically classifies every new email from your linked mailbox, drafts a personalized reply, and creates Linear tickets for bugs or feature requests. It uses a human-in-the-loop with gotoHuman and continuously improves itself by learning from approved examples. How it works The workflow triggers on every new email from your linked mailbox. Self-learning Email Classifier: an AI model categorizes the email into defined categories (e.g., Bug Report, Feature Request, Sales Opportunity, etc.). It fetches previously approved classification examples from gotoHuman to refine decisions. Self-learning Email Writer: the AI drafts a reply to the email. It learns over time by using previously approved replies from gotoHuman, with per-classification context to tailor tone and style (e.g., different style for sales vs. bug reports). Human Review in gotoHuman: review the classification and the drafted reply. Drafts can be edited or retried. Approved values are used to train the self-learning agents. Send approved Reply: the approved response is sent as a reply to the email thread. Create ticket: if the classification is Bug or Feature Request, a ticket is created by another AI agent in Linear. Human Review in gotoHuman: How to set up Most importantly, install the gotoHuman node before importing this template! (Just add the node to a blank canvas before importing) Set up credentials for gotoHuman, OpenAI, your email provider (e.g. Gmail), and Linear. In gotoHuman, select and create the pre-built review template "Support email agent" or import the ID: 6fzuCJlFYJtlu9mGYcVT. Select this template in the gotoHuman node. In the "gotoHuman: Fetch approved examples" http nodes you need to add your formId. It is the ID of the review template that you just created/imported in gotoHuman. Requirements gotoHuman (human supervision, memory for self-learning) OpenAI (classification, drafting) Gmail or your preferred email provider (for email trigger+replies) Linear (ticketing) How to customize Expand or refine the categories used by the classifier. Update the prompt to reflect your own taxonomy. Filter fetched training data from gotoHuman by reviewer so the writer adapts to their personalized tone and preferences. Add more context to the AI email writer (calendar events, FAQs, product docs) to improve reply quality.

gotoHumanBy gotoHuman
353

Synchronizing WooCommerce inventory and creating products with Google Gemini AI and BrowserAct

Synchronize WooCommerce Inventory & Create Products with Gemini AI & BrowserAct This sophisticated n8n template automates WooCommerce inventory management by scraping supplier data, updating existing products, and intelligently creating new ones with AI-formatted descriptions. This workflow is essential for e-commerce operators, dropshippers, and inventory managers who need to ensure their product pricing and stock levels are synchronized with multiple third-party suppliers, minimizing overselling and maximizing profit. --- Self-Hosted Only This Workflow uses a community contribution and is designed and tested for self-hosted n8n instances only. --- How it works The workflow is typically run by a Schedule Trigger (though a Manual Trigger is also shown) to check stock automatically. It reads a list of suppliers and their inventory page URLs from a central Google Sheet. The workflow loops through each supplier: A BrowserAct node scrapes the current stock and price data from the supplier's inventory page. A Code node parses this bulk data into individual product items. It then loops through each individual product found. The workflow checks WooCommerce to see if the product already exists based on its name. If the product exists: It proceeds to update the existing product's price and stock quantity. If the product DOES NOT exist: An If node checks if the missing product's category matches a predefined type (optional filtering). If it passes the filter, a second BrowserAct workflow scrapes detailed product attributes from a dedicated product page (e.g., DigiKey). An AI Agent (Gemini) transforms these attributes into a specific, styled HTML table for the product description. Finally, the product is created in WooCommerce with all scraped details and the AI-generated description. Error Handling: Multiple Slack nodes are configured to alert your team immediately if any scraping task fails or if the product update/creation process encounters an issue. Note: This workflow does not support image uploads for new products. To enable this functionality, you must modify both the n8n and BrowserAct workflows. --- Requirements BrowserAct API account for web scraping BrowserAct n8n Community Node -> (n8n Nodes BrowserAct) BrowserAct templates named “WooCommerce Inventory & Stock Synchronization” and “WooCommerce Product Data Reconciliation” Google Sheets credentials for the supplier list WooCommerce credentials for product management Google Gemini account for the AI Agent Slack credentials for error alerts --- Need Help? How to Find Your BrowseAct API Key & Workflow ID How to Connect n8n to Browseract How to Use & Customize BrowserAct Templates How to Use the BrowserAct N8N Community Node --- Workflow Guidance and Showcase STOP Overselling! Auto-Sync WooCommerce Inventory from ANY Supplier

Madame AI Team | KaiBy Madame AI Team | Kai
600