Templates / Natural language database queries with dual-agent AI & PostgreSQL integration

Natural language database queries with dual-agent AI & PostgreSQL integration

Ready for 3.0

by Paul ✓ · 9,801 views · created 2025-06-17 · Engineering, AI RAG

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 17 nodes and runs on Telegram events (message) (plus 1 other trigger). Along the way it connects OpenRouter Chat Model, Postgres Chat Memory, Telegram and OpenAI and 1 more.

How it runs

Trigger: On Telegram events (message) (plus 1 other trigger).

  1. Voice or Text (Switch): routes items into 2 branches
  2. Query agent (AI Agent): runs an AI agent, with model: OpenRouter Chat Model; 1 tool (Think)
  3. Download File (Telegram): work with file
  4. Text (Edit Fields (Set)): sets 1 field: text
  5. ACCES DATABASE WITH DYNAMIC QUERYS (Postgres): run a query
  6. Transcribe (OpenAI): transcribe (audio)
  7. Merge: merges the data from its input branches
  8. Main agent (AI Agent): runs an AI agent, with model: OpenRouter Chat Model; 2 tools (Think, CALL QUERY AGENT); memory: Postgres Chat Memory
  9. SEND MESSAGE (Telegram): uses Telegram

Services it uses

OpenRouter Chat ModelPostgres Chat MemoryTelegramOpenAIPostgres

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.

Nodes used (13)

From the author

AI Database Assistant with Smart Query's & PostgreSQL Integration Description: 🚀 Transform Your Database into an Intelligent AI Assistant This workflow creates a smart database assistant that safely handles natural language queries without crashing your…

Excerpt from Paul'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.