Templates / Improve AI support email drafts with Gmail, OpenAI and PostgreSQL

Improve AI support email drafts with Gmail, OpenAI and PostgreSQL

Ready for 3.0

by Vivekanand M ✓ · 25 views · created 2026-03-10 · 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-12-01.

📬 Weekly n8n 3.0 breakage alerts, free

What this workflow does

This AI workflow has 27 nodes and runs on a schedule (every 3 hours). Along the way it connects Postgres, Gmail, OpenAI Chat Model and OpenAI. It also calls api.openai.com over HTTP.

How it runs

Trigger: On a schedule (every 3 hours).

  1. 🗄️ DB - Get Last Watermark (Postgres): run a query
  2. ⚙️ Set Watermark (Code): runs custom JavaScript code
  3. 🗄️ DB - Start Run Log (Postgres): run a query
  4. ⚙️ Carry Run Context (Code): runs custom JavaScript code
  5. Gmail: get many
  6. 🔄 Loop - Sent Emails (Loop Over Items (Split in Batches)): loops over the items in batches
  7. 🗄️ DB - Complete Run Log (Postgres): run a query
  8. 📧 Gmail - Fetch Full Message (HTTP Request): calls an HTTP API
  9. ⚙️ Parse Full Message Body (Code): runs custom JavaScript code
  10. 🗄️ DB - Match Thread ID (Postgres): run a query

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

Services it uses

PostgresGmailOpenAI Chat ModelOpenAI

HTTP calls to: api.openai.com

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.

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 (10)

From the author

Self-learning feedback loop for AI customer support email drafts with Gmail, OpenAI and PostgreSQL Automatically compare AI-generated email drafts against what your support team actually sent, learn from the differences, and improve future drafts over time —…

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.