AI Assistant with RAG, Google Sheets Context, and Pinecone Memory - n8n Workflow

Deploy a powerful n8n workflow for an AI chat assistant using Pinecone RAG and Google Sheets logging. This n8n template features auto-indexing, weekly reports, and GPT-5 integration.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Businesses needing a self-updating, knowledge-based chatbot solution.

  • Technical users looking for advanced n8n templates integrating LangChain, OpenAI, and Pinecone.

  • Teams requiring automatic conversation logging and weekly compliance reporting via Gmail.

  • Developers seeking robust examples of RAG implementation within an n8n workflow.

Overview

This comprehensive n8n workflow implements a high-functioning AI chat assistant powered by the OpenAI Chat Model (simulating GPT-5). The primary value lies in its sophisticated Retrieval-Augmented Generation (RAG) system, utilizing Pinecone as the vector database for custom knowledge retrieval. This particular n8n template is designed with three major functions: real-time, context-aware chat response; automatic conversation logging via Google Sheets; and a robust document auto-indexing pipeline triggered by new files in Google Drive. This advanced n8n node configuration ensures the AI is always leveraging the latest information, making it a dynamic knowledge agent. By using this end-to-end n8n workflow, you establish audit trails, enhance AI accuracy through RAG, and automate weekly reporting via Gmail.

How it Works

The execution of this n8n workflow is divided into three distinct automated flows:

1. Real-Time Chat Response


  1. Initiation: The When chat message received n8n trigger (LangChain Chat Trigger) captures the incoming user query via a webhook.

  2. Pre-processing: The input passes through the Format Data For AI Agent n8n node, standardizing the data format.

  3. Core Agent: The AI Agent (Chat Composer) n8n node orchestrates the response, utilizing Short-Term Memory for context continuity.

  4. Tool Use: The agent intelligently chooses between two tools: the Get Previous Content from Sheet n8n tool (for structured data context) or the Pinecone Vector Store Query n8n node (for semantic knowledge retrieval via RAG).

  5. Generation & Parsing: The OpenAI Chat Model generates the response, which is guaranteed to be a valid JSON object by the Output Parser (JSON Enforcement) n8n node.

  6. Logging: Every interaction is logged to a specific Google Sheet via the Conversation Logging n8n node.

2. Knowledge Base Auto-Indexing


  1. Monitoring: The Google Drive Trigger n8n trigger monitors a specified folder for new file uploads.

  2. Ingestion: New files are downloaded, loaded by the Default Data Loader n8n node, and broken into chunks by the Recursive Character Text Splitter n8n node.

  3. Vectorization: The Embeddings OpenAI n8n node converts text chunks into vectors.

  4. Storage: The Pinecone Vector Store Insert n8n node uploads these vectors to the Pinecone index, updating the RAG knowledge base instantly.

3. Weekly Reporting


  1. Schedule: A Schedule Trigger n8n trigger fires every Monday at 10 PM.

  2. Data Extraction: The Get Data from Sheet Google Sheets n8n node pulls the entire conversation history.

  3. Formatting: Data is aggregated and then converted into a single text file using the Convert Data to file n8n node.

  4. Delivery: The Send Chat History with attachment Gmail n8n node emails the compiled conversation history as an attachment for weekly compliance or review.

Installation Guide

To deploy this powerful n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON and import it directly into your n8n instance.

  2. Credentials Setup: This n8n workflow requires credentials for:

OpenAI API (for chat model and embeddings).
Google Sheets OAuth2 (for logging and context retrieval).
Pinecone API (for RAG operations).
Google Drive OAuth2 (for the auto-indexing n8n trigger).
* Gmail OAuth2 (for weekly report sending).

  1. Configuration Check: In the Conversation Logging n8n node and the Get Data from Sheet n8n node, update the Document IDs to point to your specific Google Sheets conversation log.

  2. Pinecone Index: Update the Pinecone Index name in the Pinecone Vector Store Insert n8n node and the Pinecone Vector Store Query for Knowledge Base n8n node (currently set to whatsappchatbot).

  3. Google Drive Folder: Configure the folder ID in the Google Drive Trigger n8n trigger to monitor your source documents folder.

  4. Activate: Save and activate the n8n workflow. Use the webhook URL generated by the When chat message received n8n trigger to integrate your chat platform.

Node Details

When chat message received (n8n Trigger):
Function: Serves as the primary entry point, listening for incoming user messages to initiate the chat automation.
Key Configuration: Configured as a LangChain Chat Trigger with a unique webhook ID.
AI Agent (Chat Composer) (LangChain Agent n8n node):
Function: The central intelligence unit. It manages memory, accesses external tools (Google Sheets and Pinecone RAG), and directs the conversation flow.
Key Configuration: Uses a complex systemMessage defining its persona and behavior rules, and requires the response to be in a structured JSON format.
Pinecone Vector Store Query for Knowledge Base (Pinecone n8n node):
Function: Acts as the RAG tool. The agent uses this n8n node to semantically search the Pinecone vector database for relevant documentation before generating a response.
Key Configuration: Configured for retrieve-as-tool mode, retrieving the top 5 relevant documents (topK: 5). Requires the Embeddings OpenAI Query for Chat modal for vector generation.
Google Drive Trigger (n8n Trigger):
Function: Activates the knowledge update pipeline whenever a new file is created in a monitored Google Drive folder.
Key Configuration: Set to trigger on the fileCreated event for a specific folder ID.
Pinecone Vector Store Insert (Pinecone n8n node):
Function: Handles the indexing part of the RAG system, taking the output from the text splitters and embeddings generator and uploading it to Pinecone.
Key Configuration: Set to insert mode, crucial for maintaining the knowledge base.
Conversation Logging (Google Sheets n8n node):
Function: Appends the full conversation interaction (user message, intent, AI reply) to a designated Google Sheet for auditing and future analysis.
Schedule Trigger (n8n Trigger):
Function: Initiates the weekly reporting flow reliably.
Key Configuration: Set to run once a week, specifically on Monday at 10 PM.

Related n8n Workflows

Free

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

Rahul Joshi is a seasoned technology leader specializing in the n8n automation tool and AI-driven workflow automation. With deep expertise in building open-source workflow automation and self-hosted automation platforms, he helps organizations eliminate manual processes through intelligent n8n ai agent automation solutions.

Featured*