Query PostgreSQL from Slack using Google Sheets metadata and Gemini
Ready for 3.0What this workflow does
This AI workflow has 21 nodes and runs on Slack events. Along the way it connects Slack, Google Gemini, Google Sheets and Postgres.
How it runs
Trigger: On Slack events.
- Extract Slack Message (Edit Fields (Set)): sets 1 field: question
- Load Table Definitions (Google Sheets): uses Google Sheets
- Prepare Table List (Code): runs custom JavaScript code
- Load Database Schema (Postgres): run a query
- Build AI Schema (Code): runs custom JavaScript code
- Generate SQL (Google Gemini): uses Google Gemini
- Parse LLM Result (Code): runs custom JavaScript code
- Handle Failure Response (Edit Fields (Set)): sets or maps fields
- Validate LLM Output (Code): runs custom JavaScript code
- Send Slack Reply (Slack): uses Slack
…plus 10 more steps. See the full node list below.
Services it uses
Other Google Sheets + Slack templates (1,314) · Other Google Gemini + Google Sheets templates (819) · Other Google Gemini + Slack templates (309)
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
- Still check Slack Trigger requires a signing secret on the Slack API credential (Slack Trigger).
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (8)
- Slack Trigger
n8n-nodes-base.slackTrigger - Code
n8n-nodes-base.code - Google Gemini
@n8n/n8n-nodes-langchain.googleGemini - Edit Fields (Set)
n8n-nodes-base.set - Google Sheets
n8n-nodes-base.googleSheets - Postgres
n8n-nodes-base.postgres - If
n8n-nodes-base.if - Slack
n8n-nodes-base.slack
From the author
Quick overview This workflow lets Slack users ask natural-language questions about a PostgreSQL database, uses Google Sheets metadata plus live schema data to generate and validate a safe read-only SQL query with Google Gemini, executes it, and replies in…