Conversational AI Agent for Google Drive RAG Knowledge Base - n8n Workflow

Use this powerful n8n workflow to create a Retrieval-Augmented Generation (RAG) agent that answers questions based on documents stored in Google Drive, utilizing OpenAI and Pinecone.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users looking for advanced n8n templates integrating RAG and vector databases.
Companies needing a private, internal knowledge base AI chatbot integrated directly into their existing data storage.
Developers building custom AI automation solutions with LangChain functionality in n8n.
Anyone needing to automatically index Google Drive documents into Pinecone using a reliable n8n workflow.

Overview

This comprehensive solution addresses the challenge of making unstructured corporate data (like PDFs or documents in Google Drive) instantly accessible via a natural language chat interface. This n8n workflow orchestrates both the document ingestion and the real-time querying phases. When a file is created or updated in a monitored Google Drive folder, the document is automatically downloaded, processed, embedded using an OpenAI n8n node, and indexed in a Pinecone vector store. The second, crucial part of the n8n workflow uses a specialized AI Agent that leverages conversational memory and a custom tool to query this robust vector store, providing factual answers grounded strictly in your documentation. This setup demonstrates an advanced application of n8n automation and provides excellent foundational n8n templates for RAG implementation.

How it Works


  1. Ingestion Trigger: The ingestion process begins with two dedicated n8n trigger nodes: Google Drive File Created and Google Drive File Updated. These n8n trigger nodes monitor a specific folder, ensuring the knowledge base stays current.

  2. Document Download: Upon triggering, the relevant document metadata is passed to the Download File From Google Drive n8n node, which fetches the raw file content.

  3. Data Processing & Indexing: The raw document is processed through the LangChain components (Recursive Character Text Splitter, Default Data Loader). The Embeddings OpenAI n8n node converts document chunks into vectors, which the Pinecone Vector Store n8n node then inserts, thus building the RAG knowledge base.

  4. Chat Trigger: The query process begins with the When chat message received n8n trigger, which exposes a public webhook to receive user questions (chatInput). This robust n8n trigger starts the conversation.

  5. Agent Orchestration: The input is routed to the AI Sales Agent. This powerful n8n node uses the connected OpenAI Chat Model (gpt-4o) for reasoning and the Window Buffer Memory n8n node to maintain session context across messages.

  6. Knowledge Retrieval: If the agent determines the question requires external data, it utilizes the custom Vector Store Tool (named get_documents). This tool consults the retrieval-specific Pinecone Vector Store (Retrieval) n8n node, using search embeddings to perform a semantic search against the indexed documents.

  7. Final Response: The agent synthesizes the retrieved information with its internal instructions and returns a short, factual response via the interface connected to the initial n8n trigger. This entire n8n workflow provides enterprise-grade conversational AI.

Installation Guide


  1. Import the n8n Workflow: Copy the provided JSON data and paste it directly into your n8n instance to import this complex n8n workflow.

  2. Credentials Setup: You must configure credentials for three services:

OpenAI: Set up credentials for the OpenAI API for both chat models and embedding generation.
Google Drive: Set up OAuth2 credentials for Google Drive so the n8n trigger nodes can monitor and download files.
* Pinecone: Set up API credentials for Pinecone, ensuring the index name (my-docs in the configuration) matches your setup.

  1. Configure Triggers: Update the Google Drive File Created and Google Drive File Updated n8n trigger nodes to point to the specific folder ID you wish to use as your knowledge source.

  2. Activate: Save and activate the n8n workflow. The chat functionality starts immediately, and documents will be indexed automatically upon creation or update.

Node Details

Google Drive File Created / Updated (n8n trigger): These crucial n8n trigger nodes initiate the knowledge indexing process whenever documents are added or modified in the designated folder. They are fundamental to this n8n workflow.
Download File From Google Drive: This n8n node ensures that the full file content is fetched, preparing it for RAG processing.
Embeddings OpenAI (n8n node): Configured to use text-embedding-3-small, this n8n node generates the high-quality vectors necessary for efficient semantic searching in Pinecone.
Pinecone Vector Store (Insert Mode): The core storage n8n node for RAG data, responsible for inserting and updating the knowledge base index.
When chat message received (n8n trigger): This is the entry n8n trigger point for all user interactions, receiving chat input and passing it to the agent.
AI Sales Agent (n8n node): The orchestrator of this n8n workflow, handling system prompt instructions, routing, and synthesizing the final answer using the connected OpenAI Chat Model (gpt-4o).
Window Buffer Memory (n8n node): Maintains the conversation history by linking messages to a custom session ID based on the user (=docs-{{ $json.messages[0].from }}).
Vector Store Tool (n8n node): This n8n node allows the Agent to use its designated retrieval capability. It connects the Agent to the retrieval components (Pinecone and Search Embeddings) to ensure factual grounding.

Related n8n Workflows

Free

Nodes: 12 Nodes
Updated: December 26 2025
View all
Created by

Backend engineer with 10+ years of experience designing and optimizing database-driven systems. I help teams build scalable, secure, and high-performance infrastructure using modern backend stacks. Book a call to discuss how I can support your API, data, or automation workflows.

Featured*