Templates / Generate Gmail reply drafts with GPT-4o, pgvector, and PostgreSQL

Generate Gmail reply drafts with GPT-4o, pgvector, and PostgreSQL

Ready for 3.0

by Vivekanand M ✓ · 20 views · created 2026-04-24 · Ticket Management, 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-10-19.

What this workflow does

This AI workflow has 22 nodes and runs on Gmail events. Along the way it connects OpenAI Chat Model, Postgres, OpenAI and Gmail.

How it runs

Trigger: On Gmail events.

  1. Parse & Validate (Code): runs custom JavaScript code
  2. If: checks a condition and branches into true / false
  3. AI Agent: runs an AI agent, with model: OpenAI Chat Model; memory: Simple Memory
  4. Merge: merges the data from its input branches
  5. DB - Log Skipped (Postgres): uses Postgres
  6. Parse Classification (Code): runs custom JavaScript code
  7. Generate Email Embedding (HTTP Request): calls an HTTP API
  8. Extract Embedding (Code): runs custom JavaScript code
  9. DB - Fetch KB Data (Postgres): uses Postgres
  10. DB - Fetch Similar Corrections (Postgres): uses Postgres

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

Services it uses

OpenAI Chat ModelPostgresOpenAIGmail

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 Gmail Trigger below v1.4 runs as v1.4 (drafts skipped, max emails per poll) (Gmail Trigger).

Nodes used (11)

From the author

Email Automation — AI Draft Generator n8n Workflow Template --- 📘 Description This workflow is the core of a three-part email automation system. It monitors your Gmail inbox in real time, classifies every inbound customer email with AI, retrieves…

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