automation lab / workflow 06

RAG agent

A two-workflow n8n system that automatically vectorises documents from Google Drive into Pinecone, then lets users ask questions through a conversational AI agent grounded in that knowledge base.

The problem this solves

Teams drown in documents but can't get fast, accurate answers from them. This agent turns static files into a searchable knowledge base in under a minute.

Instead of reading through PDFs or searching folders manually, a user simply asks a question and the agent retrieves only the relevant passages from the vector store to answer it.

The project

Most teams store important information in documents that sit in shared drives. When someone needs an answer, they open the folder, skim through files, and hope they find the right paragraph. The bigger the knowledge base grows, the longer this takes, and the more context gets missed.

This project solves that with two connected n8n workflows. The first watches a Google Drive folder for new files, downloads each PDF, splits it into overlapping chunks of 850 characters, generates OpenAI embeddings, and inserts them into a Pinecone vector index. The second workflow is a chat-based AI agent: it receives a user question, queries the vector store for the most relevant passages, and returns a grounded answer using only the stored content. No hallucination, no guessing, no external sources.

The demo uses iOS 26 documentation as the knowledge base, but the architecture works for any domain: internal policies, product specs, research papers, or training materials.

By the numbers

2

connected workflows

One for ingestion (vectorise), one for retrieval (chat agent). They share the same Pinecone index and namespace.

14

total nodes

6 nodes handle the vectorisation pipeline; 8 nodes power the conversational agent with memory, tools, and dual LLM calls.

850

characters per chunk

Documents are split into 850-character segments with 50-character overlap, keeping context intact across chunk boundaries.

10

messages in memory

The agent retains the last 10 conversation turns, so follow-up questions stay contextual without re-stating the topic.

Workflow anatomy

Workflow A: Vectorise (Google Drive → Pinecone)

01 / watch

Monitor the folder

A Google Drive trigger polls the designated "RAG KB's" folder every minute for newly created files.

02 / process

Download and split

Each PDF is downloaded, loaded through a document parser, and split into overlapping chunks using a recursive character text splitter.

03 / store

Embed and index

OpenAI generates embeddings for each chunk, which are inserted into the "rag-agent" Pinecone index under the "rag-vector" namespace.

Workflow B: Chat Agent (Question → Answer)

01 / ask

Chat trigger

A public chat interface receives the user's question and passes it to the AI agent node.

02 / retrieve

Search the vector store

The agent's vector store tool queries Pinecone for the most relevant document chunks, scored by semantic similarity.

03 / answer

Generate a grounded response

GPT-5 Mini synthesises the retrieved passages into a clear, concise answer. If the information isn't in the store, the agent says so rather than guessing.