🔬 Query Google Sheets/CSV data through an AI agent using PostgreSQL

⚡ 10,174 views · 🔬 Document Extraction & Analysis

Description

Want to see it in action? Watch the full breakdown here: 📺 Video Link

Template Description

This n8n workflow empowers you to query structured financial data from Google Sheets or CSV files using AI-generated SQL. Unlike traditional vector database solutions that falter with numerical queries, this template leverages PostgreSQL for efficient data storage and an AI agent to dynamically create optimized SQL queries from natural language inputs.

What It Does

Why Use This?


Setup Requirements

Pre-Conditions

Step-by-Step Instructions

  1. Add Your Google Sheets URL

    • Open the “Google Drive Trigger” node.
    • Replace the placeholder URL with your Google Sheet’s link.
    • Verify the sheet name matches your data source.
  2. Configure PostgreSQL

    • Update the “PostgreSQL” nodes with your database credentials (host, database, user, password).
    • The workflow automatically creates and populates the table based on your data schema.
  3. Run the Workflow

    • Execute the workflow manually to set up the database.
    • Once initialized, use the AI agent by asking questions like:
      • “How much did I sell last week?”
      • “What were the total sales for Product X in February?”
  4. (Optional) Automate Updates

    • Add a “Schedule Trigger” node to sync your Google Sheets data with PostgreSQL on a regular basis.

How It Works


Tips for Success

đź”— Nodes Used

Google Sheets, Postgres, Google Drive Trigger, Execute Workflow Trigger, AI Agent, Call n8n Workflow Tool

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup