Mindket

Draft Gmail replies with OpenAI for labelled threads

Newversion 1 · updated

Overview

An n8n workflow that writes reply drafts in Gmail with an AI agent. Every minute it finds threads with your trigger label, drafts a reply to the last message and removes the label.

Draft Gmail replies with OpenAI for labelled threads is an n8n workflow in the Productivity category, listed by Mindket. It is free. This is version 1, last updated on . Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

At a glance

Runs in
  • n8n Cloud: import the file into a new workflow there and switch it on
  • Your own n8n server: the same file and steps
  • A different rhythm: change the interval in the Schedule trigger
  • Another tone: rewrite the System Message in Write reply

Platform

Connects 2 apps

How it works

Trigger

Every minute

It starts on a timer, once every minute, and looks for work in your Gmail:

  • Threads that carry your trigger label

Actions

  1. Gmail lists the threads that carry the trigger label
  2. The last message of each thread is read in full
  3. An AI agent on OpenAI (gpt-6-luna) writes a reply in Markdown, which becomes HTML
  4. The reply is wrapped as an email, encoded and saved as a draft in the same thread
  5. The trigger label is removed from the thread

Result

A reply draft waiting in each labelled thread, ready for you to read, edit and send

Integrations

What you need before you start.

Gmail

Email

Lists the labelled threads, reads the last message, saves the draft and removes the label.

NeedsA Gmail OAuth2 credential and a trigger label

OpenAI

Language model

Writes the reply text for each thread, on gpt-6-luna.

NeedsAn OpenAI API key

Workflow check

Checked by Mindket on 13 Nov 2026

Steps
13 steps, starting on a schedule
AI
1 step calls an AI model: Write reply
Sign-ins
Signs in to: Gmail and OpenAI
API keys
No API key is left in the file
Step types
Mindket’s checker reads 8 of its 9 step types. It does not read: Gmail

Read from the workflow’s file, not from a run.

About

What it is

This n8n workflow writes reply drafts in Gmail with an AI agent. Every minute it looks for threads that carry a label you chose, reads the last message of each and asks the agent for a reply. The reply is saved as a draft in the same thread, and the label is removed. Fourteen nodes do the work, beside ten sticky notes.

Who it suits

Support teams and shops that answer many similar emails and want a first draft waiting for them. Skip it if you want replies sent without a check, since this workflow only saves drafts.

Who uses it, and how
IndustryWho uses itHow they use itExample
SupportSupport agentsStart from a draft instead of a blank replyAn agent labels a thread and finds a polite reply waiting in it a minute later.
RetailShop ownersAnswer order questions fasterAn owner sees a draft that answers a delivery question and edits one line.
AgenciesAccount managersKeep the tone of replies consistentA manager describes the agency’s tone once and every draft follows it.
FreelanceIndependent consultantsHandle routine enquiries quicklyA consultant labels a pricing enquiry and reviews the draft before sending.

You need a little n8n: import a file, add two credentials, create one label in Gmail and describe your business to the agent.

Where to use it

Any n8n that can reach Gmail and OpenAI will run it. It checks on its own once a minute, so you do not need to open n8n.

  • n8n Cloud: import the file into a new workflow there and switch it on
  • Your own n8n server: the same file and steps
  • A different rhythm: change the interval in the Schedule trigger
  • Another tone: rewrite the System Message in Write reply

Setup

Download saves a zip with workflow.json and Mindket’s setup notes in your downloads folder. Create the trigger label in Gmail first, since you pick it in two nodes.

What you need first
NeedDetail
n8nOn n8n Cloud or on a server of your own
GmailA Gmail OAuth2 credential that can read mail, change labels and create drafts, and a label that marks threads
OpenAIAn API key, for an OpenAI credential
  1. In n8n, create a workflow, open its menu, choose Import from File and pick workflow.json.
  2. In Gmail, create the trigger label, for example Needs reply.
  3. Add a Gmail credential and select it in Get threads with specific labels, Get thread messages, Get single message content, Add email draft to thread and Remove AI label from email.
  4. Add an OpenAI credential and select it in OpenAI Chat Model.
  5. In Get threads with specific labels and Remove AI label from email, replace <YOUR_TRIGGER_LABEL_ID> by choosing your trigger label.
  6. Describe your business and your tone in the System Message of Write reply.
  7. Switch the workflow on, then add the label to a test thread.

How to use it

Add the trigger label to a Gmail thread. Within a minute a draft reply appears in that thread, and the label disappears. Open the draft, edit it and send it yourself. The draft is addressed to the sender of the last message.

What to change for a different result
To changeWhere
The trigger labelThe label in Get threads with specific labels and Remove AI label from email
How often it checksThe interval in Schedule trigger (1 min)
The content and the toneSystem Message in Write reply
The modelModel in OpenAI Chat Model

Example

A shop owner labels a thread where a customer asks about an order. A minute later the thread holds a draft, a short and polite reply that thanks the customer and asks for the order number.

The owner reads the draft, adds a tracking link and sends it. The trigger label is already gone, so the thread is not drafted a second time.

For newcomers and experts

If you are new. n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. A Gmail thread is a conversation of several emails, and a draft is a message that is saved but not sent. The agent is an AI step that writes the reply text.

For experts. Gmail’s API wants the raw message encoded in base64url, so Build email raw writes the headers and Convert raw to base64 encodes them. Loop over threads collects the last message of every thread, and its done output feeds the rest of the flow.

Where to look closer
NodeWhat it doesWhat to know
Schedule trigger (1 min)Schedule Trigger 1.1, every minuteSwitch the workflow off when you do not need it
Get threads with specific labelsGmail 2.1, Thread, Get Many, all resultsThe trigger label picks the threads
Loop over threadsSplit In Batches 3Its loop output reads each thread, and its done output carries the last messages on
Get thread messagesGmail 2.1, Thread, Get, messages onlyReturn last message in thread keeps the last one
Get single message contentGmail 2.1, Get, full messageIt gives the agent the plain text
Write replyAgent 1.7 with a system message and no toolsIt answers in Markdown
Convert response to HTMLMarkdown 1, Markdown to HTMLThe draft body is HTML
Build email rawSet 3.3, headers and body as one stringIt writes To, Subject and Content-Type
Convert raw to base64Code 2, once for each itemIt encodes the string as base64url
Add email draft to threadHTTP Request 4.1, a POST to the Gmail drafts addressIt uses the Gmail credential and the thread id
Remove AI label from emailGmail 2.1, Thread, Remove LabelsIt runs after the draft is saved

Good to know

The original called a service that has been shut down, and it needed your label before it could run safely.

  • Models: the original asked an OpenAI Assistant for the reply. OpenAI’s deprecations page, read on 12 November 2026, lists the Assistants API as shut down on 26 August 2026, with the Responses API and Conversations API as the replacement. Mindket’s copy uses an AI Agent on gpt-6-luna, and the assistant’s instructions lived in the OpenAI dashboard, so write the System Message in Write reply yourself
  • Your trigger label: the label is yours, so two nodes hold <YOUR_TRIGGER_LABEL_ID>. Without a label the list would cover every thread in the mailbox, and the workflow would draft a reply for each
  • Encoding: the original encoded the message in plain base64, while Gmail’s documentation asks for base64url. Mindket’s copy uses base64url
  • A leftover field: the original also stored a message id in Map fields for further processing, but no step used it, so it is gone
  • Drafts only: nothing is sent, and the draft goes to the sender of the last message, so label threads where the other person wrote last
  • A failed run: if a step fails after the draft is saved, the label stays and the next run drafts again
  • Your data: the text of the last message in each labelled thread goes to OpenAI
  • Credentials: the JSON holds none, so add the Gmail and OpenAI credentials yourself

README and files

README

Draft Gmail replies with OpenAI for labelled threads

An n8n workflow that writes reply drafts in Gmail. Every minute it looks for threads that carry a label you chose, asks an AI agent
for a reply to the last message and saves it as a draft in the same thread. The label is removed afterwards, and nothing is sent.

What is inside

  • workflow.json: the workflow as n8n exports it, fourteen working nodes and ten sticky notes. It holds no credential.
  • README.md: these notes.

What we changed from the original copy

  • The original asked an OpenAI Assistant for the reply, and the Assistants API is shut down. Mindket's copy has an AI Agent named
    Write reply with an OpenAI Chat Model on gpt-6-luna. See Good to know.
  • The trigger label is now <YOUR_TRIGGER_LABEL_ID> in Get threads with specific labels and Remove AI label from email, so you
    pick your own.
  • Convert raw to base64 now writes base64url, which is what Gmail's documentation asks for.
  • Map fields for further processing no longer stores a message id that no step used.
  • Three sticky notes were rewritten as setup notes, in place of the author's own notes.

Before you start

  • An n8n instance, on n8n Cloud or on a server of your own.
  • A Gmail account, and a label in it that marks the threads you want drafts for, for example Needs reply.
  • An OpenAI API key.

Set it up

  1. In n8n, create a workflow, open its menu, choose Import from File and pick workflow.json.
  2. In Gmail, create the trigger label.
  3. Add a Gmail credential and select it in Get threads with specific labels, Get thread messages, Get single message content,
    Add email draft to thread and Remove AI label from email.
  4. Add an OpenAI credential and select it in OpenAI Chat Model.
  5. In Get threads with specific labels and Remove AI label from email, replace <YOUR_TRIGGER_LABEL_ID> by choosing your label.
  6. In Write reply, describe your business and your tone in the System Message.
  7. Switch the workflow on, then add the label to a test thread and wait a minute.

How a run goes

  1. Schedule trigger (1 min) starts the workflow.
  2. Get threads with specific labels lists the threads that carry the label.
  3. Loop over threads takes them one at a time, and Get thread messages reads each one.
  4. Return last message in thread keeps the last message, and Get single message content reads it in full.
  5. Write reply asks the model for a reply in Markdown.
  6. Map fields for further processing collects the thread and reply, and Convert response to HTML makes the reply HTML.
  7. Build email raw writes the message and Convert raw to base64 encodes it.
  8. Add email draft to thread saves the draft in the thread.
  9. Remove AI label from email takes the trigger label off.

What to change for a different result

  • The label: the label in Get threads with specific labels and Remove AI label from email.
  • How often it checks: the interval in Schedule trigger (1 min).
  • The content and the tone: the System Message in Write reply.
  • The model: OpenAI Chat Model.

Good to know

  • OpenAI's deprecations page, read on 12 November 2026, lists the Assistants API as shut down on 26 August 2026, with the Responses
    API and Conversations API as the replacement. The original's assistant, named Customer assistant, kept its instructions in the
    OpenAI dashboard, so they are not in the file. Write them in the System Message of Write reply.
  • The same page lists the gpt-4o, gpt-4o-mini and gpt-4.1 snapshots as shutting down on 14 January 2027, with gpt-6-luna as the
    replacement. This copy uses gpt-6-luna.
  • Without a label in the two nodes, the list covers every thread in the mailbox, and the workflow would draft a reply for each.
  • Gmail's API documentation, read on 12 November 2026, describes the raw field as "RFC 2822 formatted and base64url encoded string".
  • Nothing is sent. The draft goes to the sender of the last message, so label threads where the other person wrote last.
  • If a step fails after the draft is saved, the label stays and the next run drafts again.
  • The text of the last message in each labelled thread goes to OpenAI.
Files
NOTICE.md  643 B
README.md  4 KB
workflow.json  15 KB

3 files, 19 KB, downloaded as a zip.

What’s new

  • Version 1 · 2026-11-12

Reviews

No ratings yet

Write a review

No reviews yet.

More from Mindket

See all from Mindket

anaksor-ocr

Sokheng · Kit

Reads Khmer and English text from documents, receipts and photos of signs, using a detector for text lines and a recogniser for each line. Suits developers who…

New

Qwen2.5-7B-Instruct as GGUF files in eight quantization sizes, to chat with locally through llama.cpp. For people who want a capable 7.6B model on their own co…

New

ACE-Step 1.5 XL SFT

ACE-Step · Kit

Generates music from text with a 4B diffusion decoder, 50 steps and guidance control, aiming for higher audio quality than the base. For creators with a GPU of…

New

Similar in Productivity

See all in Productivity

Guizang PPT Skill

op7418 · Skill

Skill that makes single-file HTML slide decks, slide illustrations and platform covers in two visual styles, with a presenter mode for rehearsal. For speakers…

New29.8k

Frontend Slides

zarazhangrui · Skill

Builds HTML presentations from scratch or from a PowerPoint file and shows visual style previews to pick from, for people who want web slides with no CSS or Ja…

New32.3k

IPTV

iptv-org · Kit

Collects publicly available live TV channels from many countries into playlists that any video player with live streaming can open. Made for viewers and for de…

New144k