Generate Gmail reply drafts with GPT-4o, pgvector, and PostgreSQL
Ready for 3.0What 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.
- Parse & Validate (Code): runs custom JavaScript code
- If: checks a condition and branches into true / false
- AI Agent: runs an AI agent, with model: OpenAI Chat Model; memory: Simple Memory
- Merge: merges the data from its input branches
- DB - Log Skipped (Postgres): uses Postgres
- Parse Classification (Code): runs custom JavaScript code
- Generate Email Embedding (HTTP Request): calls an HTTP API
- Extract Embedding (Code): runs custom JavaScript code
- DB - Fetch KB Data (Postgres): uses Postgres
- DB - Fetch Similar Corrections (Postgres): uses Postgres
…plus 9 more steps. See the full node list below.
Services it uses
Other OpenAI + Gmail templates (1,623) · Other OpenAI + PostgreSQL templates (191) · Other Gmail + PostgreSQL templates (82)
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).
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (11)
- Code
n8n-nodes-base.code - If
n8n-nodes-base.if - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow - AI Agent
@n8n/n8n-nodes-langchain.agent - Merge
n8n-nodes-base.merge - HTTP Request
n8n-nodes-base.httpRequest - Postgres
n8n-nodes-base.postgres - OpenAI
@n8n/n8n-nodes-langchain.openAi - Gmail
n8n-nodes-base.gmail - Gmail Trigger
n8n-nodes-base.gmailTrigger
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…