AI Agent Retrieval from Google Sheets Data Vector Store - n8n Workflow

Use this powerful n8n workflow to ingest Google Sheets data into a Supabase vector store using OpenAI embeddings, then query it using a Gemini-powered n8n agent for rapid RAG functionality.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

• Users needing knowledge retrieval from proprietary data.
• Developers building custom Retrieval-Augmented Generation (RAG) systems using n8n templates.
• Businesses automating personalized data lookups and requiring chat-based access.
• n8n specialists seeking advanced agent and vector database implementation examples.

Overview

This comprehensive n8n workflow addresses the challenge of creating a searchable, proprietary knowledge base from structured data sources like Google Sheets. It leverages the power of embedding models (OpenAI) and modern database technology (Supabase) to transform raw data into a dense vector index. This specific n8n workflow is designed in two critical stages: initialization (loading data) and execution (answering chat queries). Once indexed, a sophisticated n8n agent, powered by the Google Gemini Chat Model and utilizing Postgres for memory, can accurately retrieve and answer questions based on the stored personal information. This highly modular n8n template provides robust data integration and advanced AI functionality, showcasing complex Langchain integrations within n8n.

How it Works

Part 1: Data Ingestion (Vector Store Creation)

The initialization phase of this n8n workflow is designed to run separately to build the vector index. The process begins by using the Google Sheets n8n node (Get row(s) in sheet1) to fetch all relevant personal data rows from a designated sheet. This tabular data is then converted into a structured file format by the Convert to File n8n node. The Default Data Loader prepares this content for vectorization using a CSV loader configuration. The Embeddings OpenAI n8n node generates high-quality vector embeddings. Finally, these resulting documents and their embeddings are inserted into the personal_data table within Supabase via the Vector Store n8n node, completing the data load process for this powerful n8n workflow.

Part 2: AI Agent Retrieval

The active part of the n8n workflow starts with the When chat message received n8n trigger, initiating the automation upon receiving a user query. The query is passed to the core AI Agent n8n node. This agent relies on several components to formulate its response:


  1. Reasoning: The Google Gemini Chat Model provides the reasoning capabilities.

  2. Memory: The Postgres Chat Memory ensures the conversation context is maintained across multiple messages.

  3. Tool: The Supabase Vector Store n8n node, configured specifically for retrieval (as a tool), allows the agent to search the vector index when the user's question requires personal data lookup. The agent uses the relevant personal data retrieved by this tool to synthesize an accurate answer, completing the query for this n8n template.

Installation Guide


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

  2. Google Sheets Setup: Configure the Google Sheets n8n node credentials and ensure the documentId and sheetName parameters point to the source spreadsheet containing your personal data.

  3. Supabase Setup: Configure the Supabase n8n node credentials. This requires connecting to a Supabase project where the personaldata table is set up to handle vector embeddings (Postgres with pgvector).

  4. OpenAI Embeddings: Set up the OpenAI n8n node credentials. These are used both during the data ingestion phase (Embeddings OpenAI) and during the retrieval phase (Embeddings OpenAI1) for vector matching. A valid API key is required.

  5. Postgres Memory: Configure the Postgres n8n node credentials for the chat memory.

  6. Gemini LLM: Configure the Google Gemini Chat Model n8n node credentials.

  7. Initial Run: Run the Data Ingestion path (Nodes: Get row(s) in sheet1 to Vector Store) once manually to populate your Supabase vector store before activating the Agent path (triggered by the chat n8n trigger).

Node Details

This n8n workflow uses a combination of standard data manipulation nodes and specialized Langchain-based n8n nodes:

When chat message received (n8n trigger): The starting point for the agent flow, waiting for an incoming chat query to execute the n8n workflow logic.
Get row(s) in sheet1 (Google Sheets n8n node): Fetches all rows from the specified 'Personal Birthday' Google Sheet, providing the raw data source for the n8n workflow.
Convert to File (n8n node): Converts the spreadsheet row data into a binary file format, which is essential input for the subsequent document loader.
Default Data Loader2 (Langchain n8n node): Loads the converted file data using the CSV loader to prepare the documents for embedding.
Embeddings OpenAI (Langchain n8n node): Uses OpenAI services to calculate vector embeddings for the documents destined for insertion into the vector store. This is a critical step in the n8n vectorization process.
Vector Store (Supabase Vector Store n8n node - Insert Mode): This node inserts the documents and their OpenAI embeddings into the Supabase personaldata table, building the vector index.
Google Gemini Chat Model (Langchain n8n node): Serves as the primary Language Model for the AI Agent n8n node, handling complex reasoning and response generation.
Postgres Chat Memory (Langchain n8n node): Stores the ongoing conversation history, allowing the AI Agent to maintain context within this n8n workflow.
Supabase Vector Store (Langchain n8n node - Retrieve Mode): Configured as a tool named 'Personal details table,' this node allows the AI Agent to search the vector index using the query name matchpersonal_data to retrieve factual information.
AI Agent (Langchain n8n node): The core control n8n node, orchestrating the LLM, Memory, and the Supabase Vector Store retrieval tool to answer user questions based on the vectorized knowledge base.

Related n8n Workflows

Free

Nodes: 10 Nodes
Updated: December 26 2025
View all
Created by
Mustafa Polat
Mustafa Polat

With 20+ years in marketing, I’ve worked as a developer and manager, leading teams and building innovative solutions. My expertise includes data engineering, designing native architectures on Google and AWS cloud, and integrating APIs to optimize workflows. I specialize in developing custom APIs and leveraging data to drive business efficiency, making impactful, data-driven decisions for organizations.

Featured*