# Automated Gmail classification and labeling with OpenAI: n8n workflow

> Started by an arriving email, and works across Gmail, Google Sheets and Slack. It hands the judgement calls to OpenAI.

Source: https://millionrounds.com/workflow/automated-gmail-classification-and-labeling-with-openai (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Alerts and monitoring](https://millionrounds.com/workflows?category=Alerts+and+monitoring#library)

# Automated Gmail classification and labeling with OpenAI

Started by an arriving email, and works across Gmail, Google Sheets and Slack. It hands the judgement calls to OpenAI. 21 steps, 3 branches: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fautomated-gmail-classification-and-labeling-with-openai)

**21 steps** Large: read it before trusting it with anything live

**3** Branches: places the flow splits

**0** Loops or waits

**3** Services it connects to

## The flow

Starts it 1 Model 3 Logic 5 Service 12

The steps in the order they run, from what starts it.

- 1 **OpenAI Chat Model** Lm Chat Open Ai *Model*
- 2 **Structured Output Parser** Output Parser Structured *Model*
- 3 **Gmail Check Every 2 Min** Gmail trigger *Starts it*
- 4 **Classify and Extract Entities** Agent *Model*
- 5 **Extract and Clean Email Content** Code *Logic*
- 6 **Parse and Validate AI Response** Code *Logic*
- 7 **Check Classification Success** If *Logic*
- 8 **Check if High Priority or Urgent** If *Logic*
- 9 **Route by Category** Switch *Logic*
- 10 **Log Classification Errors** Google Sheets *Service*
- 11 **Send Urgent Email Alert** Slack *Service*
- 12 **Label: Inquiry** Gmail *Service*
- 13 **Label: Support Request** Gmail *Service*
- 14 **Label: Newsletter** Gmail *Service*
- 15 **Label: Marketing** Gmail *Service*
- 16 **Label: Personal** Gmail *Service*
- 17 **Label: Urgent** Gmail *Service*
- 18 **Label: Spam** Gmail *Service*
- 19 **Label: Invoice/Receipt** Gmail *Service*
- 20 **Label: Meeting Request** Gmail *Service*
- 21 **Log All Emails** Google Sheets *Service*

## How it's built

- **Starts on:** An arriving email
- **Steps:** 21, with 3 branches
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Gmail, Google Sheets, Slack
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Gmail, Google Sheets and Slack accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an arriving email.

Does it use AI?

Yes. It calls OpenAI. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 21 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 21 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fautomated-gmail-classification-and-labeling-with-openai)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Gmail](https://millionrounds.com/workflows?service=Gmail#library)[Google Sheets](https://millionrounds.com/workflows?service=Google+Sheets#library)[Slack](https://millionrounds.com/workflows?service=Slack#library)

## Workflows like it

Also alerts and monitoring, with the same services where possible, closest in size first.

- [**Automated n8n error monitoring alerts - Telegram, Slack & email** 21 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/automated-n8n-error-monitoring-alerts-telegram-slack-and-ema)
- [**Monitor and score new real estate listings with BrowserAct** 21 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/monitor-and-score-new-real-estate-listings-with-browseract)
- [**Monitor asset health and predict maintenance with Claude** 21 steps · calls a model · Email, Slack](https://millionrounds.com/workflow/monitor-asset-health-and-predict-maintenance-with-claude)
- [**Monitor supply chain risks and disruptions with OpenAI** 21 steps · calls a model · Email, Slack](https://millionrounds.com/workflow/monitor-supply-chain-risks-and-disruptions-with-openai)
- [**Monitor viral competitor Instagram posts with Apify and Groq** 21 steps · calls a model · Google Sheets, Slack](https://millionrounds.com/workflow/monitor-viral-competitor-instagram-posts-with-apify-and-groq)
- [**Outlook inbox tamer: GPT-4.1 powered categorization, auto** 21 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/outlook-inbox-tamer-gpt-4-1-powered-categorization-auto)
