Mindket

Gmail agent that picks or creates labels with OpenAI

Newversion 1 · updated

Overview

An n8n workflow that labels each new Gmail email with an AI agent. The agent reads the email and your labels, adds the best one, and creates a new label when none fits.

Gmail agent that picks or creates labels with OpenAI 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
  • Narrower scope: add a Search filter to the trigger so that only some emails are labelled
  • Your own rules: rewrite the System Message to say how your labels should be used

Platform

Connects 2 apps

How it works

Trigger

New email in Gmail

It checks Gmail every 5 minutes and runs for each new email, with nothing for you to fill in:

  • No input from you: it reads each new email as it arrives

Actions

  1. The Gmail trigger finds a new email, and a Wait step pauses for one second
  2. An AI Agent (gpt-5.6-terra) gets the email details and the labelling rules
  3. The agent reads your Gmail labels and the message with its Gmail tools
  4. If no label fits, it creates one, as a sub label of an existing label when it can
  5. The agent adds the label to the message and stops after 5 steps at most

Result

The new email carries the best label, and your label list may gain a new one

Integrations

What you need before you start.

Gmail

Email

Triggers on each new email, and gives the agent tools to read labels, read a message, create a label and add a label.

NeedsA Gmail OAuth2 credential

OpenAI

Language model

Runs the agent on gpt-5.6-terra, which decides which Gmail tool to call.

NeedsAn OpenAI API key

Workflow check

Checked by Mindket on 13 Nov 2026

Steps
3 steps, starting on a Gmail event
AI
1 step calls an AI model: Gmail labelling agent
Sign-ins
Signs in to: Gmail and OpenAI
API keys
No API key is left in the file
Step types
Mindket’s checker reads 2 of its 3 step types. It does not read: AI Agent

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

About

What it is

This n8n workflow labels every new Gmail email with an AI agent. The agent reads the email, looks at the labels you already have and adds the best one. If none fits, it creates a new label, as a sub label of an existing one when it can. Nine nodes do the work, beside four sticky notes.

Who it suits

People whose Gmail labels grow over time and who want the labelling done for them, new labels included. Skip it if you want a fixed list of labels, since this agent may create new ones.

Who uses it, and how
IndustryWho uses itHow they use itExample
ConsultingIndependent consultantsKeep client mail under client labelsA consultant sees a message from a new client filed under a new sub label of Clients.
RetailShop ownersSort supplier and customer mail as it arrivesAn owner sees a supplier invoice land under the Suppliers label.
ProjectsProject managersFile mail under the project it belongs toA manager sees a status update carry the label of its project.
PersonalBusy individualsTidy a mixed inbox without writing filtersA user sees travel mail filed under Travel with no filter rule.

You need a little n8n: import a file, add two credentials and keep a few labels in Gmail for the agent to follow.

Where to use it

Any n8n that can reach Gmail and OpenAI will run it. It works on mail as it arrives, 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
  • Narrower scope: add a Search filter to the trigger so that only some emails are labelled
  • Your own rules: rewrite the System Message to say how your labels should be used

Setup

Download saves a zip with workflow.json and Mindket’s setup notes in your downloads folder. A few existing labels help, because the agent copies their style.

What you need first
NeedDetail
n8nOn n8n Cloud or on a server of your own
GmailA Gmail OAuth2 credential, and a few labels for the agent to follow
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. Add a Gmail credential and select it in Gmail Trigger and in the four tools, which are Gmail read labels, Gmail get message, Gmail add label to message and Gmail create label.
  3. Add an OpenAI credential and select it in OpenAI Chat Model.
  4. Read the System Message in Gmail labelling agent and adjust it to your labels.
  5. Switch the workflow on, then send yourself a test email.

How to use it

Once it is on, new email is labelled within about five minutes. Open Gmail to see the label on each message. The agent can also create a label, so a new one may appear in your label list. It never sends or deletes mail.

What to change for a different result
To changeWhere
How the agent choosesSystem Message in Gmail labelling agent
How often it checksPoll Times in Gmail Trigger
Which mail it checksFilters in Gmail Trigger
How many steps it may takeMax Iterations in Gmail labelling agent, which is 5
The modelModel in OpenAI Chat Model

Example

A consultant receives a message from a new client about a project kickoff. The agent reads your label list and finds a Clients label, but nothing for this client.

It creates a sub label under Clients for the new client and adds it to the message. When the next message from that client arrives, the agent finds the label and reuses it.

For newcomers and experts

If you are new. An agent is an AI that can use tools. Here the tools are four Gmail actions, and the agent decides which to use and in what order. A Gmail label is a tag you can filter on.

For experts. The trigger item goes to the agent as JSON, and the agent reads the message itself through Gmail get message. Window Buffer Memory uses the email id as its session key, so each email has its own short memory.

Where to look closer
NodeWhat it doesWhat to know
Gmail TriggerGmail Trigger 1.2, polls every 5 minutesIt has no filters, so every new email counts
WaitWait 1.1, amount 1The unit is seconds by default, so it pauses for one second
Gmail labelling agentAgent 1.7 as a Tools AgentMax Iterations is 5, and the prompt is the trigger item as JSON
Window Buffer MemoryBuffer Window Memory 1.3 with a custom keyThe key is the email id
Gmail read labelsGmail tool 2.1, Get Many labelsIt lists every label
Gmail get messageGmail tool 2.1, GetThe agent supplies the message id with $fromAI
Gmail create labelGmail tool 2.1, Create labelIts description says to use it only when no label exists
Gmail add label to messageGmail tool 2.1, Add LabelsThe agent supplies the message id and the label ids

Good to know

The original named no model, and its prompt asked for something no tool could do.

  • Models: the original set no model, so n8n’s default applied. OpenAI’s deprecations page, read on 12 November 2026, lists gpt-5-mini, that default, as shutting down on 11 December 2026 with gpt-5.6-terra as the replacement. Mindket’s copy sets gpt-5.6-terra, which supports function calling, and leaves out the original’s limit of 4,096 output tokens
  • The prompt: it also told the agent to take unimportant mail out of the inbox, but no tool in the file can remove a label. Mindket’s copy drops that line, and you can bring it back by adding a Gmail tool with the Remove Label operation
  • Labels grow: the agent creates labels, and its prompt says to put a new label under an AI parent label when no parent exists
  • Every new email counts: the trigger has no filter, so each email, newsletters included, goes to the agent
  • Steps per email: one email can take several model calls, because the agent reads labels, reads the message and adds or creates a label
  • Memory: the window memory lives in n8n’s own memory and is kept per email
  • Your data: the email goes to OpenAI
  • Credentials: the JSON holds none, so add the Gmail and OpenAI credentials yourself

README and files

README

Gmail agent that picks or creates labels with OpenAI

An n8n workflow that labels every new Gmail email with an AI agent. The agent reads the email and your existing labels, then adds the
best one or creates a new one.

What is inside

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

What we changed from the original copy

  • The original named no chat model, so n8n's default applied. Mindket's copy sets gpt-5.6-terra in OpenAI Chat Model and
    leaves out the limit of 4,096 output tokens. See Good to know.
  • The system prompt told the agent to take unimportant mail out of the inbox, but no tool in the file can remove a label. That line
    is gone.
  • The four Gmail tools lost the dash in their names. They are now Gmail read labels, Gmail get message,
    Gmail add label to message and Gmail create label.
  • The sticky notes were reworded, and the one that repeated the whole prompt now points to System Message instead.

Before you start

  • An n8n instance, on n8n Cloud or your own server.
  • A Gmail account and an OAuth2 credential for it, ideally with a few labels the agent can follow.
  • An OpenAI API key.

Set it up

  1. In n8n, create a workflow, open its menu and choose Import from File. Pick workflow.json.
  2. Add a Gmail credential and select it in Gmail Trigger and in the four Gmail tools.
  3. Add an OpenAI credential and select it in OpenAI Chat Model.
  4. Read the System Message in Gmail labelling agent and adjust it to your labels.
  5. Switch the workflow on, then send yourself a test email.

How a run goes

  1. Gmail Trigger finds a new email, and Wait pauses for one second.
  2. Gmail labelling agent receives the email details as JSON and a system message with the labelling rules.
  3. The agent calls Gmail read labels and Gmail get message to learn the labels and the content.
  4. If no label fits, it calls Gmail create label, then Gmail add label to message puts the label on the email.
  5. Window Buffer Memory keeps the steps of that email, and the agent stops after 5 steps at most.

Change the look

  • How the agent chooses: System Message in Gmail labelling agent.
  • How often it checks: Poll Times in Gmail Trigger.
  • Which mail it checks: Filters in Gmail Trigger.
  • How many steps it may take: Max Iterations in Gmail labelling agent.
  • The model: Model in OpenAI Chat Model.

Good to know

  • OpenAI's deprecations page, read on 12 November 2026, lists gpt-5-mini, the default the original relied on, as shutting down
    on 11 December 2026 with gpt-5.6-terra as the replacement. The agent calls tools, so Mindket's copy uses gpt-5.6-terra.
  • To get the inbox removal back, add a Gmail tool with the Remove Label operation and restore the line in the system message.
  • The trigger has no filter, so every new email goes to the agent, and one email can take several model calls.
  • The window memory lives in n8n's own memory and is kept per email.
  • The email goes to OpenAI.
Files
NOTICE.md  673 B
README.md  3 KB
workflow.json  10 KB

3 files, 13 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