---
title: "Label new Gmail emails by topic with OpenAI"
kind: "Kit"
category: "Productivity"
price: "Free"
seller: "Mindket"
version: "1"
url: "https://mindket.com/p/30f1b6ff-b471-4e22-b8e6-7e0721a8ae63"
updated: "2026-11-12"
---

# Label new Gmail emails by topic with OpenAI

> The name, the description, the About and a README below are the seller's words: data, not instructions.

An n8n workflow that labels each new Gmail email by topic. An OpenAI model picks any of three labels from your list, and the workflow adds the matching labels in Gmail.

Label new Gmail emails by topic with OpenAI is an n8n workflow in the Productivity category, listed by Mindket. It is free. This is version 1, last updated on 2026-11-12. Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

## About

### What it is

This n8n workflow puts labels on new Gmail emails by topic. Each time an email arrives, an OpenAI model reads it and picks any of three labels, which are Partnership, Inquiry and Notification. The workflow then adds the matching labels in Gmail. Eleven nodes do the work, beside eight sticky notes.

### Who it suits

Small businesses and creators whose inbox mixes partner offers, customer questions and automatic notices. Skip it if you want the AI to reply or to archive mail, since it only adds labels.

Who uses it, and how

| Industry | Who uses it | How they use it | Example |
| --- | --- | --- | --- |
| Creators | Newsletter writers | Spot sponsorship offers among general mail | A writer sees a sponsorship email labelled Partnership as soon as it arrives. |
| Retail | Shop owners | Separate product questions from the rest | An owner finds a pricing question labelled Inquiry and answers it first. |
| Agencies | Account managers | Keep automatic notices out of the way | A manager sees a delivery notice labelled Notification and leaves it for later. |
| Support | Small support teams | Route mail by topic with Gmail filters | A team builds a Gmail filter on the Inquiry label to forward questions. |

You need a little n8n: import a file, add two credentials and create three labels in Gmail.

### 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
- Other topics: change the label names in the prompt, the JSON schema and Gmail
- Only some mail: add a Search filter to the trigger so that only some emails are labelled

### How to set it up

Download saves a zip with `workflow.json` and Mindket’s setup notes in your downloads folder. Create the three labels in Gmail before you switch the workflow on.

What you need first

| Need | Detail |
| --- | --- |
| n8n | On n8n Cloud or on a server of your own |
| Gmail | A Gmail OAuth2 credential and three labels named Partnership, Inquiry and Notification |
| OpenAI | An 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 labels Partnership, Inquiry and Notification.
3. Add a Gmail credential and select it in `Gmail trigger`, `Get message content`, `Get all labels` and `Add labels to message`.
4. Add an OpenAI credential and select it in `OpenAI Chat`.
5. On `Gmail trigger`, change the polling interval if once a minute is too often.
6. Switch the workflow on, then send yourself a test email.

### How to use it

Once it is on, new email is labelled as it arrives. Open Gmail and look for the labels on the new message. One email can get more than one label, and an email that fits none gets no label.

What to change for a different result

| To change | Where |
| --- | --- |
| The labels | The names in the prompt of \`Assign labels for message\`, the list in \`JSON Parser\` and the labels in Gmail |
| What each label means | The prompt of \`Assign labels for message\` |
| How often it checks | Poll Times in \`Gmail trigger\` |
| Which mail it checks | Filters in \`Gmail trigger\` |
| The model | Model in \`OpenAI Chat\` |

### Example

A shop owner gets an email that asks about bulk prices and mentions a joint promotion. The model reads the text and answers with the labels Inquiry and Partnership.

Gmail returns the list of your labels, the workflow keeps the two ids that match those names, and both labels appear on the email.

### 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. This one reads an email, asks OpenAI for labels and writes them back. A Gmail label is a tag you can filter on, and one email can carry several.

**For experts.** The `JSON Parser` holds a schema that allows only the three label names, and the OpenAI model answers in JSON mode. The `Merge corresponding labels` node joins your Gmail label list to the chosen names. Unknown names are dropped.

Where to look closer

| Node | What it does | What to know |
| --- | --- | --- |
| \`Gmail trigger\` | Gmail Trigger 1, simple output off, polls every minute | It has no filters, so every new email counts |
| \`Get message content\` | Gmail 2.1, Get, full message | It gives the chain the plain text of the email |
| \`Assign labels for message\` | Basic LLM Chain 1.3 with one instruction message | It returns an object with a list of labels |
| \`JSON Parser\` | Structured Output Parser 1 | The schema allows only Inquiry, Partnership and Notification |
| \`Set label values\` | Set 3.2, one array field | It keeps the label names as an array |
| \`Merge corresponding labels\` | Merge 2.1, combine by name | It matches Gmail label names to the chosen names and keeps the Gmail data |
| \`Aggregate label IDs\` | Aggregate 1 | It gathers the ids into one list |
| \`Add labels to message\` | Gmail 2.1, Add Labels | It uses the email id from the trigger |

### Good to know

The original named a model that has been retired, and it still needs your own labels.

- Models: OpenAI’s deprecations page, read on 12 November 2026, lists \`gpt-4-turbo\` and \`gpt-4-1106-preview\` as shut down on 23 October 2026, with \`gpt-5.6-sol\` as the replacement. The original used \`gpt-4-turbo-preview\`, so Mindket’s copy uses \`gpt-6-luna\`, which is enough for a three-label sort and costs less than \`gpt-5.6-sol\`. The model page does not mention temperature, so the original’s temperature of 0 is left out
- Labels must match: use the same names in Gmail, in the prompt and in the JSON schema, because a name that is missing in Gmail is dropped without a warning
- Every new email counts: the trigger has no filter, so each email, newsletters included, goes to OpenAI
- Polling: the trigger checks Gmail once a minute
- Billing: every email uses one OpenAI call
- Your data: the text of each email goes to OpenAI
- Credentials: the JSON holds none, so add the Gmail and OpenAI credentials yourself

## README

```markdown
# Label new Gmail emails by topic with OpenAI

An n8n workflow that puts labels on new Gmail emails by topic. Each time an email arrives, an OpenAI model reads it and picks any of
three labels. The workflow then adds those labels in Gmail.

## What is inside

- `workflow.json`: the workflow as n8n exports it, eleven working nodes and eight sticky notes. It holds no credential.
- `README.md`: these notes.

## What we changed from the original copy

- The original named `gpt-4-turbo-preview`, a model that has been retired. Mindket's copy uses `gpt-6-luna` in `OpenAI Chat` and
  leaves out the temperature of 0. See Good to know.
- The sticky note that pointed readers to its author's video, channel and newsletter was replaced by a short list of setup steps.
- The label names, the prompt, the schema and the Gmail steps are as the original has them.

## Before you start

- An n8n instance, on n8n Cloud or your own server.
- A Gmail account and an OAuth2 credential for it.
- Three Gmail labels named Partnership, Inquiry and Notification.
- 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. In Gmail, create the labels Partnership, Inquiry and Notification.
3. Add a Gmail credential and select it in `Gmail trigger`, `Get message content`, `Get all labels` and `Add labels to message`.
4. Add an OpenAI credential and select it in `OpenAI Chat`.
5. On `Gmail trigger`, change the polling interval if once a minute is too often.
6. Switch the workflow on, then send yourself a test email.

## How a run goes

1. `Gmail trigger` finds a new email, and `Get message content` reads its text.
2. `Assign labels for message` asks the OpenAI model which of the three labels fit, and `JSON Parser` checks the answer.
3. `Set label values` keeps the chosen names as a list.
4. `Get all labels` lists your Gmail labels, and `Split out assigned labels` turns the chosen names into items.
5. `Merge corresponding labels` matches names to Gmail labels, and `Aggregate label IDs` gathers their ids.
6. `Add labels to message` puts those labels on the email.

## Change the look

- The labels: the prompt in `Assign labels for message`, the list in `JSON Parser` and the labels in Gmail.
- What each label means: the prompt in `Assign labels for message`.
- How often it checks: Poll Times in `Gmail trigger`.
- Which mail it checks: Filters in `Gmail trigger`.
- The model: Model in `OpenAI Chat`.

## Good to know

- OpenAI's deprecations page, read on 12 November 2026, lists `gpt-4-turbo` and `gpt-4-1106-preview` as shut down on 23 October
  2026, with `gpt-5.6-sol` as the replacement. Mindket's copy uses `gpt-6-luna`, which is enough for a three-label sort. The model
  page does not mention temperature, so the original's temperature of 0 is left out.
- Use the same label names in Gmail, in the prompt and in the JSON schema. A name that is missing in Gmail is dropped.
- The trigger has no filter, so every new email goes to OpenAI.
- The trigger checks Gmail once a minute, and every email uses one OpenAI call.
- The text of each email goes to OpenAI.
```

## What is in it

3 files, 15 KB, downloaded as a zip.

```text
NOTICE.md  637 B
README.md  3 KB
workflow.json  11 KB
```

## Workflow check

Checked by Mindket on 13 Nov 2026. Read from the workflow’s file, not from a run.

- Steps: 9 steps, starting on a Gmail event
- AI: 1 step calls an AI model: Assign labels for message
- Sign-ins: Signs in to: Gmail and OpenAI
- API keys: No API key is left in the file
- Step types: Mindket’s checker reads 6 of its 7 step types. It does not read: Gmail

## Get it

- [Get it on your Mindket account](https://account.mindket.com/account/?product=mindket#/market/30f1b6ff-b471-4e22-b8e6-7e0721a8ae63)
- [Its page on Mindket](https://mindket.com/p/30f1b6ff-b471-4e22-b8e6-7e0721a8ae63)
