CORTEXFLOW · FREE FOREVER

AI Agents

RAG Chatbot — Google Drive + Gemini + Pinecone

↓ Download workflow JSON

Import in n8n: Workflows → ⋯ → Import from file, then add your credentials. Free download with a free account.

How it works

This workflow has two branches that run independently:

Ingestion branch — documents → vector store:

  1. Google Drive triggers watch your folder — one fires when a file is created, the other when a file is updated (both poll every minute).
  2. The file is downloaded from Google Drive with its original name preserved.
  3. Text is extracted, split, and embedded — a binary data loader reads the file, a recursive character text splitter chunks it (100-character overlap), and Google’s text-embedding-004 model turns each chunk into a vector.
  4. Chunks are inserted into Pinecone — your vector index stays in sync with the Drive folder automatically.

Chat branch — questions → answers:

  1. Chat trigger receives the message — use n8n’s built-in chat widget or connect any chat frontend.
  2. The AI Agent answers — it runs on gemini-2.0-flash-exp with a system prompt that makes it a helpful HR assistant for company policies.
  3. Retrieval happens through a tool — the agent calls company_documents_tool, which searches Pinecone for relevant chunks and feeds them back as context.
  4. Honest fallback — if the answer isn’t in the documents, the agent replies “I cannot find the answer in the available resources.” instead of hallucinating.
  5. Window Buffer Memory keeps the conversation context so follow-up questions work naturally.

Set up steps

You’ll need:

  • A Google Cloud project with the Vertex AI API enabled
  • A Google AI API key — get one at Google AI Studio → Get API key
  • A Pinecone account — pinecone.io, free tier works; create an index with 768 dimensions (matches text-embedding-004) and cosine metric
  • A Google Drive folder containing your company documents (PDF, DOCX, TXT)
  1. Download the workflow JSON using the download button on this page.
  2. In n8n, go to Workflows → ⋯ → Import from file and select the JSON.
  3. Google Drive — Credentials → New → Google Drive OAuth2, sign in with Google, and save. Select it in Google Drive File Created, Google Drive File Updated, and Download File From Google Drive. Then open both trigger nodes and pick your documents folder in Folder to Watch.
  4. Google AI (PaLM API) — Credentials → New → Google PaLM API, paste your Google AI Studio API key, and save. Select it in Embeddings Google Gemini, Google Gemini Chat Model, and both (retrieval) variants.
  5. Pinecone — Credentials → New → Pinecone, paste your Pinecone API key, and save. Select it in Pinecone Vector Store and Pinecone Vector Store (Retrieval), then pick your index in both nodes.
  6. Activate the workflow, drop a document into the Drive folder, wait a minute, then ask a question in the chat.

Customize it

  • Chunk size and overlap — open Recursive Character Text Splitter and tune chunkSize / chunkOverlap for long vs. short documents.
  • Different models — swap models/text-embedding-004 for another embedding model (match your Pinecone index dimensions!) or models/gemini-2.0-flash-exp for a different Gemini chat model.
  • System prompt — edit the system message in the AI Agent node to change its role, tone, or fallback behavior.
  • More triggers — the ingestion branch also works with a Schedule Trigger that sweeps the whole folder nightly, or add a Google Drive Trigger on fileDeleted plus a Pinecone delete step.
  • Richer answers — raise the retrieval Top K / add a score threshold in the Vector Store Tool node to control how many chunks the agent sees.

Workflow nodes

This workflow is built from 15 nodes. Here's what each one does:

#NodeTypeWhat it does
1 Google Drive File Created Google Drive Trigger Starts the workflow when a file changes in Google Drive.
2 Google Drive File Updated Google Drive Trigger Starts the workflow when a file changes in Google Drive.
3 Download File From Google Drive Google Drive Uploads, downloads, or manages files in Google Drive.
4 Pinecone Vector Store Pinecone Vector Store Semantic search over your documents stored in Pinecone.
5 Embeddings Google Gemini Google Gemini Embeddings Turns text into vector embeddings with Google Gemini.
6 Default Data Loader Document Loader Loads documents into the RAG pipeline.
7 Recursive Character Text Splitter Text Splitter Splits long documents into chunks for embedding.
8 When chat message received Chat Trigger Starts the workflow from the n8n chat interface.
9 AI Agent AI Agent The AI brain — reasons over the task and calls tools to get it done.
10 Google Gemini Chat Model Google Gemini Chat Model The language model powering the AI agent (Google Gemini).
11 Window Buffer Memory Window Buffer Memory Gives the agent short-term chat memory across messages.
12 Vector Store Tool Vector Store Tool Lets the agent search your vector database as a tool.
13 Pinecone Vector Store (Retrieval) Pinecone Vector Store Semantic search over your documents stored in Pinecone.
14 Embeddings Google Gemini (retrieval) Google Gemini Embeddings Turns text into vector embeddings with Google Gemini.
15 Google Gemini Chat Model (retrieval) Google Gemini Chat Model The language model powering the AI agent (Google Gemini).

Setup instructions

1. Add your credentials

In n8n go to Credentials → New, create each credential below, then open the named node and select it:

NodeCredential to add
Google Drive File Created Google Drive OAuth2
Google Drive File Updated Google Drive OAuth2
Download File From Google Drive Google Drive OAuth2
Pinecone Vector Store Pinecone API
Embeddings Google Gemini Google PaLM / Gemini API
Google Gemini Chat Model Google PaLM / Gemini API
Pinecone Vector Store (Retrieval) Pinecone API
Embeddings Google Gemini (retrieval) Google PaLM / Gemini API
Google Gemini Chat Model (retrieval) Google PaLM / Gemini API

How this workflow starts

  • Google Drive Trigger: Fires automatically on its event — activate the workflow and connect the service.
  • Google Drive Trigger: Fires automatically on its event — activate the workflow and connect the service.
  • Chat Trigger: Fires automatically on its event — activate the workflow and connect the service.

Use cases

This is the zero-maintenance version of a company-documents chatbot: you never manually ingest anything. Two Google Drive triggers watch your documents folder — one fires when a file is created, the other when a file is updated, both polling every minute — so dropping a PDF into the folder automatically downloads it, extracts the text, splits it with a recursive character splitter using 100-character overlap, embeds each chunk with Google's text-embedding-004, and inserts the vectors into Pinecone. On the chat side, a Gemini-powered AI agent answers through a company_documents_tool that searches Pinecone, keeps conversation context with Window Buffer Memory, and replies with a clear honest fallback when the answer is not in the documents.

The HR team at a 200-person company

The agent's system prompt already frames it as a helpful HR assistant for company policies, so the HR team just points the two Drive triggers at a folder of policy PDFs and DOCX files. When the leave policy is revised, updating the file re-indexes it within a minute — no one has to remember to re-ingest anything. Employees ask about notice periods, reimbursements, and benefits in plain language, and follow-up questions work naturally thanks to the window buffer memory. Practical tip: if the honest fallback triggers too often on new topics, check that the updated file actually landed in the watched folder — the most common miss is editing a copy outside the folder the triggers watch.

The IT helpdesk with ever-changing runbooks

An internal IT team keeps runbooks for VPN setup, laptop provisioning, and access requests — documents that change monthly. With file-updated triggers polling every minute, the Pinecone index tracks the runbooks almost in real time, and the helpdesk answers from the current version instead of last quarter's. The 100-character chunk overlap keeps procedures that span chunk boundaries retrievable. Practical tip: open the Recursive Character Text Splitter and tune chunk size and overlap for your document style — long runbooks benefit from larger chunks, while short FAQ-style docs work fine with smaller ones.

The sales team that needs current pricing and specs

Sales reps quote from spec sheets and price lists that product teams update constantly. Pointing the ingestion branch at the sales collateral folder means the chatbot always answers from the latest files, and the agent's retrieval tool feeds the relevant chunks back as context before answering. When a rep asks about a feature, the answer reflects this week's spec sheet, not last quarter's. Practical tip: raise the retrieval Top K or add a score threshold in the Vector Store Tool node to control how many chunks the agent sees — more chunks for complex comparison questions, fewer for quick spec lookups.

The property management firm drowning in tenant questions

A firm managing 300 units gets the same questions about maintenance requests, pet policies, and move-out procedures. Office staff drop lease templates, policy memos, and FAQ docs into the Drive folder, and the chat widget becomes the first line of defense — staff query it instead of interrupting the property manager. Practical tip: deleted files leave stale vectors behind, so add a Google Drive trigger on fileDeleted plus a Pinecone delete step, keeping the index as clean as the folder it mirrors.

The cost-conscious startup staying on Gemini

Because everything runs on Google's models — text-embedding-004 for embeddings and gemini-2.0-flash-exp for chat — a startup already on Google AI Studio gets a full RAG system without an OpenAI bill. The Pinecone free tier covers the vector side, with the index set to 768 dimensions to match the embedding model. Practical tip: if you ever swap the embedding model, the Pinecone index dimensions must match the new model exactly — and remember to select the Google PaLM API credential in the embeddings nodes, the chat model nodes, and both retrieval variants, or half the workflow will fail silently.

← All templates