Use this advanced n8n workflow to build a powerful local Agentic RAG system using Ollama, PGVector, and PostgreSQL. Process PDFs, CSVs, and Excel files automatically for intelligent question answering. Ideal for self-hosted n8n templates.
Download this n8n workflow template and start using it instantly.





















Users running self-hosted n8n instances looking for local AI solutions.
Data scientists or developers needing to perform sophisticated RAG on proprietary documents without cloud services.
Anyone interested in advanced n8n templates for knowledge base creation.
Organizations requiring an n8n workflow that can intelligently handle mixed data types (text and tabular data).
This powerful n8n workflow solves the problem of reliable, local document question answering (Q&A) over diverse file types. Standard RAG solutions often struggle with numerical data or require complex, slow processing. This specific n8n workflow, leveraging the power of Ollama and PGVector, creates an 'Agentic RAG' system. This means the AI agent can dynamically choose the best tool for the job: performing a vector database lookup for text, or executing a dedicated SQL query for tabular data (CSVs/Excel files).
The complete automation is provided as a reusable set of n8n templates. The file ingestion process is fully automated via an n8n trigger, ensuring that any new document added to a local folder is immediately chunked, embedded using an Ollama embedding model, and stored in the PostgreSQL/PGVector database. This n8n node architecture provides maximum flexibility and power for local AI use cases.
The n8n workflow operates in two main phases: Document Ingestion and Agentic Querying.
Local File Trigger n8n trigger monitors a mounted local folder (/data/shared) for new or changed files.Set File ID n8n node to extract metadata (ID, type, title).documentmetadata PostgreSQL table.Read/Write Files from Disk n8n node loads the content.Switch n8n node directs processing based on file type:Recursive Character Text Splitter for chunking, and then embedded using the Embeddings Ollama n8n node before being stored in the Postgres PGVector Store.documentrows PostgreSQL table (as JSONB), and the schema is updated in the document_metadata table. This allows the RAG AI Agent to perform SQL queries later.When chat message received n8n trigger receives a user question.RAG AI Agent n8n node takes over. This agent is configured with an Ollama (Change Base URL) language model and uses Postgres Chat Memory for context.Respond to Webhook n8n node. This entire n8n workflow structure provides robust, intelligent interaction.To deploy this advanced n8n workflow, follow these steps:
Ollama (Change Base URL) node is an overridden OpenAI Chat n8n node. Create an OpenAI credential, but set the 'Base URL' to your local Ollama instance (e.g., http://ollama:11434/v1). The API key can be set to any placeholder value, as it is ignored for local models.Create Document Metadata Table and Create Document Rows Table (for Tabular Data) n8n node steps once to initialize the required database structure. Wait for successful execution./data/shared (this is where the Local File Trigger n8n trigger looks for documents).Local File Trigger and the When chat message received n8n trigger. The n8n automation is now live. Local File Trigger:
Function: This critical n8n trigger monitors the local shared folder (/data/shared) for document additions or changes, initiating the ingestion process.
Key Configuration: Monitors 'add' and 'change' events on the /data/shared path.
When chat message received (n8n trigger):
Function: The primary interface for users to submit questions to the RAG Agent.
Key Configuration: A public chat trigger endpoint.
RAG AI Agent:
Function: The core intelligence of the n8n workflow. It orchestrates the process, selects the best tool (RAG or SQL) to answer the query, and maintains conversation history.
Key Configuration: Uses the custom Ollama language model, Postgres chat memory, and references all RAG/Database tools.
Ollama (Change Base URL):
Function: Acts as the large language model for the RAG AI Agent, routing requests locally to Ollama.
Key Configuration: An OpenAI Chat n8n node where the Base URL is set to the Ollama API endpoint (http://ollama:11434/v1).
Postgres PGVector Store:
Function: Manages the storage of document chunks and their embeddings (via the Embeddings Ollama n8n node) in the documentspg table. Used for standard RAG lookups.
Key Configuration: Configured in 'insert' mode for the ingestion path and 'retrieve-as-tool' mode for the agent query path.
Embeddings Ollama:
Function: Generates vector embeddings for document chunks using a local Ollama embedding model (nomic-embed-text:latest). This is essential for the n8n workflow's RAG functionality.
Extract from CSV/Extract from Excel:
Function: Handles file parsing for tabular data before insertion into the documentrows PostgreSQL table.
Insert Table Rows & Query Document Rows (Postgres n8n node):
* Function: Stores and allows querying of tabular data rows. The agent can execute complex SQL against this n8n node to perform precise calculations.
Learn how to deploy a private Retrieval Augmented Generation (RAG) system. This n8n workflow uses local Ollama models for embeddings and LLM, integrating with Qdrant for vector storage.

Use this robust n8n workflow to automate the loading of JSON documents from an FTP server, embedding them using OpenAI, and storing the resulting vectors efficiently in a Qdrant database. Essential for RAG systems.

Use this structured n8n workflow to mock complex CRM data, transform contact properties (Name, Email), and prepare the clean output for insertion into any database or Google Sheet.

Use this efficient n8n workflow template to create location-based, time-sensitive reminders sent directly to Telegram. Ideal for chores like bin collection, triggered upon arrival home.

Use this powerful n8n workflow to automate logging your daily mood and local weather conditions directly to Notion using a Telegram input. This n8n template ensures consistent personal data tracking.

Hi 👋 I'm Jadai kongolo. As an AI Automation Expert, I’m passionate about simplifying tech and empowering small businesses and young coders through AI automation. With my AI agency, Oki, I create efficient, n8n-powered workflows that save time, streamline operations, and boost growth for SMBs.







































