Skip to content
FlowHubFluxonLab
A
AI Automationfree

Query Google Sheets/CSV data through an AI Agent using PostgreSQL

by Leonardo Grigorioadapted from n8n official workflow galleryUpdated Aug 2026
RequiresAAI AgentCall n8n Workflow ToolCall n8n Workflow ToolCCodeGoogle Gemini Chat ModelGoogle SheetsGoogle SheetsPostgresPostgres
Share Post Share
Cocreate table querycreate table qu…Cocreate insertion querycreate insertio…GDGoogle Drive TriggerGoogle Drive Tr…TWexecute_query_toolexecute_query_t…Google Gemini Chat ModelGoogle Gemini C…TWget_postgres_schemaget_postgres_sc…Sechange_thisIfis not in databaseis not in datab…table exists?fetch sheet dataremove tablecreate tableperform insertionperform inserti…EWExecute Workflow TriggerExecute Workflo…MCWhen chat message receivedWhen chat messa…Seresponse outputsql query executorsql query execu…schema finderCoschema to stringAgAI Agent With SQL Query PromptAI Agent With S…12345678910
1/5
FLOWS
STEPS · 10
Starts on a Google Drive event

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 Retrieves data from Google Sheets or CSV files Infers the data schema and builds a PostgreSQL table Populates the table with your data Uses an AI agent to translate natural language questions into SQL queries Returns precise numerical results quickly and efficiently Why Use This? No SQL knowledge required—the AI generates queries for you Bypasses the inefficiencies and costs of vector database approaches Scales effortlessly without overwhelming the language model Fully free and open-source Setup Requirements Pre-Conditions PostgreSQL Database**: A running PostgreSQL instance (no specific extensions required beyond standard installation).

Tags

n8nreference-onlyagentgoogle-sheetslm-chat-google-geminipostgrestool-workflow
Connects
AAI Agentcalln8nworkflowtoolCall n8n Workflow ToolCCodeGoogle Gemini Chat ModelsheetsGoogle SheetspostgresPostgres
CategoryAI Automation
Triggermanual
Complexitycomplex
Nodes20
AddedMar 4, 2025

Related workflows

See all AI Automation
ACgmailgoogledrive
free

Qualify leads and send personalized audio follow-ups with Gemini and Smallest.ai

Quick Overview This workflow receives lead submissions via a webhook, uses Google Gemini to qualify the lead and write a personalized spoken follow-up script, and for qualified leads generates an MP3 with Smallest.ai, shares it from Google Drive, emails it via Gmail, logs outcomes to Google Sheets, and alerts sales in Slack. How it works Receives a POST webhook request containing a lead’s name, email, and message. Sends the lead details to a Google Gemini–powered AI agent to determine whether the lead is qualified and, if so, generate a short personalized audio script. Parses the agent’s JSON response and routes the workflow based on the qualified flag. If the lead is qualified, Smallest.ai synthesizes the script into an MP3 and uploads it to Google Drive. Shares the Google Drive audio file publicly and sends the lead a Gmail message with a link to listen. Appends the qualified lead record (including the audio link and timestamp) to Google Sheets and posts a notification to a Slack channel. If the lead is unqualified, appends the lead details and timestamp to Google Sheets without generating audio or sending email. Setup Enable the webhook and copy the generated /lead-capture URL i

by Zain Khan
ACgmailsheets
free

Analyze YouTube comments with OpenAI, Google Sheets, and Gmail

Quick overview This workflow monitors a Google Sheets list of YouTube video IDs, fetches video details and top comments from the YouTube Data API, analyzes the comments with OpenAI into structured sentiment and themes, emails an HTML report via Gmail, and writes the results back to Google Sheets. How it works Triggers every minute when a row in Google Sheets is added or updated. Reads the video ID and status from the row and continues only if the status is set to “Pending”. Calls the YouTube Data API to fetch the video’s metadata and the top comment threads for that video. Flattens the comment threads, calculates basic stats (comment count and average likes), and compiles a limited comment text block for analysis. If comments exist, sends the compiled comments and video title to OpenAI to generate a structured analysis (sentiment score, sentiment breakdown, themes, questions, feedback, insights, and summary). Builds an HTML email report from the structured results, sends it to the configured recipient with Gmail, and updates the Google Sheet row with the analysis fields; if no comments exist, marks the row as “No comments”. Setup Create or duplicate a Google Sheet with at least “Vi

by Dr. Firas
ACgoogledrive
free

Create narrated blog audio from RSS with Google Gemini, Smallest.ai and WordPress

Quick Overview This workflow polls a blog RSS feed, rewrites new posts into a spoken-word script using Google Gemini, generates an MP3 with Smallest.ai, uploads it to Google Drive, and updates the matching WordPress post to embed a public audio player. How it works Polls an RSS feed every minute to detect newly published or updated blog items. Extracts the post body and strips HTML, scripts, styles, and common entities to produce clean plain text. Uses Google Gemini to rewrite the text into a single, conversational narration script with an intro/outro and length limits. Sends the rewritten script to Smallest.ai to synthesize an English MP3 audio file. Uploads the MP3 to Google Drive and updates sharing so anyone with the link can play it. Updates the corresponding WordPress post to embed an HTML5 audio player pointing to the Google Drive link and includes the article text below it. Setup Set the RSS feed URL in the RSS Feed Trigger node and confirm the feed provides the fields used for the post content and GUID. Add credentials for Google Gemini (Google AI / Gemini) and select that connection in the chat model used by the rewrite step. Add your Smallest.ai API credentials and verif

by Zain Khan