Automated RAG Chatbot Setup with Google Drive and Gemini - n8n Workflow

Implement a powerful RAG chatbot using this comprehensive n8n workflow. Automatically ingest Google Drive files, embed content using Gemini, store in Pinecone, and answer queries via an AI Agent.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Teams requiring automated document ingestion for internal RAG systems.

  • Users looking for advanced AI automation examples using the n8n node ecosystem.

  • Developers needing robust n8n templates for self-service AI knowledge bases.

  • Businesses wanting to turn internal knowledge documents into an instant Q&A tool.

Overview

This sophisticated n8n workflow provides a complete solution for building a dynamic, self-updating Retrieval-Augmented Generation (RAG) system. The core problem this solves is keeping an AI knowledge base synchronized with real-world documentation effortlessly. Instead of manual uploads, this n8n template uses a Google Drive n8n trigger to watch for new PDF files. Once detected, the file is processed, chunked, embedded using Google Gemini, and indexed into Pinecone.

This dual-purpose n8n workflow then allows real-time query handling via a chat n8n trigger, ensuring the AI Agent uses only the most relevant, context-specific information retrieved from the vector database. This integration demonstrates best practices in combining file operations, AI embedding, vector storage, and live chat functionality within a powerful n8n automation.

How it Works

This comprehensive n8n workflow operates in two distinct, yet interconnected phases: Document Ingestion and Chatbot Querying.

Phase 1: Document Ingestion (RAG Setup)


  1. Monitoring: The process starts with the Monitor Google Drive for New Files n8n trigger, which constantly checks a specified folder ('RAG_Files') for new PDF uploads.

  2. Extraction: Once a file is detected, the Google Drive n8n node downloads it, and the Extract PDF Content n8n node processes the file to retrieve the raw text.

  3. Preparation: A dedicated Code n8n node cleans and normalizes the text (removing line breaks and excess characters) before the Split Document Text into Chunks n8n node breaks it into manageable 3000-character segments.

  4. Embedding: The Generate Document Embeddings (Google Gemini) n8n node converts these text chunks into numerical vector representations.

  5. Indexing: Finally, the Insert Document into Pinecone Vector Store n8n node saves these high-quality embeddings into the Pinecone index (n8n-rag-demo), making the document content instantly searchable for the chatbot.

Phase 2: Chatbot Query (Live Flow)


  1. Query Activation: The live flow is initiated by the Chat Message n8n trigger when a user submits a question.

  2. Query Embedding: The Generate Query Embeddings (Google Gemini) n8n node immediately converts the user's question into a search vector.

  3. Retrieval: The Retrieve Relevant Documents from Pinecone n8n node uses this query vector to find the most contextually similar document chunks from the Pinecone vector database.

  4. Prompt Generation: A Code n8n node (Generate Chat Prompt with Context) dynamically formats a system prompt, appending the top 3 retrieved context snippets directly to the user's original question.

  5. Answer Generation: The enriched prompt is sent to the AI Agent n8n node, which uses the OpenRouter Chat Model Interface (utilizing Google Gemini) to provide a relevant, factual answer based strictly on the knowledge documents indexed by this n8n workflow.

Installation Guide

To deploy this complete n8n workflow, follow these steps:


  1. Import: Copy the provided n8n workflow JSON and import it into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Google Drive Credentials: Set up credentials for Google Drive OAuth2Api, ensuring the service account has read access to the target folder (specified as 1RQvAHIw8cQbtwI9ZvdVV0k0x6TM6HZwP in this n8n template).

  3. Pinecone Credentials: Configure the PineconeApi credentials (ldIxYWz8E9e0N4yV). Ensure the specified index (n8n-rag-demo) exists in your Pinecone environment.

  4. Google Gemini Credentials: Configure the Google Gemini (PaLM) Api credentials for both embedding n8n nodes (prd6Qnbbj4UbNH75). These are crucial for generating quality vector embeddings.

  5. OpenRouter Credentials: Configure the OpenRouter account credentials required by the LLM interface used by the AI Agent n8n node.

  6. Activate: Once all credentials are set up and verified, activate both parts of the n8n workflow (Ingestion and Chat Trigger) to begin automated processing.

Node Details

This n8n workflow utilizes several specialized n8n node types to achieve its RAG functionality:

Monitor Google Drive for New Files (n8n trigger): The primary n8n trigger for document ingestion. It monitors a specific folder ID (1RQvAHIw8cQbtwI9ZvdVV0k0x6TM6HZwP) for newly uploaded files.
Download File from Google Drive (Google Drive n8n node): Downloads the file detected by the n8n trigger so it can be accessed by subsequent processing steps.
Extract PDF Content (Extract From File n8n node): Dedicated function to parse the PDF binary data and extract the text content.
Clean and Normalize PDF Text (Code n8n node): Uses custom JavaScript to optimize the text output by removing unnecessary characters and formatting, improving the quality of the embeddings.
Split Document Text into Chunks (Text Splitter n8n node): A LangChain n8n node that applies a recursive character splitting strategy, configured with a chunk size of 3000 and overlap of 300.
Generate Document Embeddings (Google Gemini n8n node): Creates the vector representation for the document chunks using the models/text-embedding-004 model. This is key for the Pinecone search.
Insert Document into Pinecone Vector Store (Pinecone n8n node): The final step of the ingestion process, storing the vectors in the n8n-rag-demo index.
Chat Message Trigger (n8n trigger): The webhook n8n trigger that receives user input for the live chatbot functionality.
Retrieve Relevant Documents from Pinecone (Pinecone n8n node): Executes the search operation (load mode) against the vector database to retrieve contextual data matching the user's query vector.
AI Agent (LangChain n8n node): The core intelligence component. It takes the context-rich prompt and uses the connected language model (via OpenRouter) to formulate the final, authoritative response.

Related n8n Workflows

Free

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

AI Incarnation is a visionary automation expert dedicated to revolutionizing the way businesses and individuals streamline their workflows. With a passion for harnessing the power of artificial intelligence and cutting-edge automation, we specialize in creating intelligent, user-friendly solutions using n8n. Our mission is to simplify complex processes and unlock new opportunities for productivity and innovation—one node at a time. Let's build the future together!

Featured*