Templates / Query PostgreSQL from Slack using Google Sheets metadata and Gemini

Query PostgreSQL from Slack using Google Sheets metadata and Gemini

Ready for 3.0

by Rishabh Patil · 10 views · created 2026-07-23 · Internal Wiki, AI Chatbot

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-12-01.

📬 Weekly n8n 3.0 breakage alerts, free

What 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.

  1. Extract Slack Message (Edit Fields (Set)): sets 1 field: question
  2. Load Table Definitions (Google Sheets): uses Google Sheets
  3. Prepare Table List (Code): runs custom JavaScript code
  4. Load Database Schema (Postgres): run a query
  5. Build AI Schema (Code): runs custom JavaScript code
  6. Generate SQL (Google Gemini): uses Google Gemini
  7. Parse LLM Result (Code): runs custom JavaScript code
  8. Handle Failure Response (Edit Fields (Set)): sets or maps fields
  9. Validate LLM Output (Code): runs custom JavaScript code
  10. Send Slack Reply (Slack): uses Slack

…plus 10 more steps. See the full node list below.

Services it uses

SlackGoogle GeminiGoogle SheetsPostgres

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).
Check at runtime on n8n 3.0
  • Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Informational: a static scan can't see the data, so test these on your own instance. Status above is unchanged.

Nodes used (8)

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…

Excerpt from Rishabh Patil's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.