Templates / Compose reply draft in Gmail with OpenAI assistant

Compose reply draft in Gmail with OpenAI assistant

Ready for 3.0

by Oskar ✓ · 19,530 views · created 2024-03-27 · Ticket Management, Multimodal AI

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 13 nodes and runs on a schedule (every minute). Along the way it connects Gmail and OpenAI. It also calls googleapis.com over HTTP.

How it runs

Trigger: On a schedule (every minute).

  1. Get threads with specific labels (Gmail): work with thread
  2. Loop over threads (Loop Over Items (Split in Batches)): loops over the items in batches
  3. Get single message content (Gmail): get
  4. Get thread messages (Gmail): get (thread)
  5. Ask OpenAI Assistant (OpenAI): work with assistant
  6. Return last message in thread (Limit): keeps the first few items
  7. Map fields for further processing (Edit Fields (Set)): sets 5 fields: response, threadId, to…
  8. Convert response to HTML (Markdown): converts between Markdown and HTML
  9. Build email raw (Edit Fields (Set)): sets 1 field: raw
  10. Convert raw to base (Code): runs custom JavaScript code

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

Services it uses

GmailOpenAI

HTTP calls to: googleapis.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.

Nodes used (9)

From the author

This workflow uses OpenAI Assistant to compose draft replies for labeled email messages. It automatically connects the drafts to Gmail threads. 💡 You can add knowledge base to your OpenAI Assistant and make your reply drafts very customized (e.g. compose…

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