# Smart email manager with Gmail and OpenAI: n8n workflow

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

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

[Automation library](https://millionrounds.com/workflows) · [Chat assistants](https://millionrounds.com/workflows?category=Chat+assistants#library)

# Smart email manager with Gmail and OpenAI

Started by an arriving email, and works across Gmail, Google Drive and Telegram. It hands the judgement calls to OpenAI. 26 steps, 4 branches, 1 loop or waits: 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%2Fsmart-email-manager-with-gmail-and-openai)

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

**4** Branches: places the flow splits

**1** Loop or waits

**3** Services it connects to

## The flow

Starts it 1 Model 5 Logic 11 Service 9

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

- 1 **Structured Output Parser** Output Parser Structured *Model*
- 2 **Email_Trigger** Gmail trigger *Starts it*
- 3 **AI Language Model** Lm Chat Open Ai *Model*
- 4 **Get Specific File Types** Function *Logic*
- 5 **Auto-fixing Output Parser** Output Parser Autofixing *Model*
- 6 **Process One by One** Split In Batches *Logic*
- 7 **AI Email Classifier** Chain Llm *Model*
- 8 **AI Response Generator** Chain Llm *Model*
- 9 **Get Conversation Thread** Gmail *Service*
- 10 **Smart Action Router** Switch *Logic*
- 11 **Create Draft Response** Gmail *Service*
- 12 **Get Latest Message ID** Limit *Logic*
- 13 **Check for Attachments** If *Logic*
- 14 **Send Urgent Alert** Telegram *Service*
- 15 **Aggregate Label IDs** Aggregate *Logic*
- 16 **Get Latest Message Content** Gmail *Service*
- 17 **Get All Attachments** Function *Logic*
- 18 **Mark as Processed** Gmail *Service*
- 19 **Assign Classification Label** Gmail *Service*
- 20 **Get All Gmail Labels** Gmail *Service*
- 21 **Check Existing Attachments** Google Drive *Service*
- 22 **Merge Attachment Data** Merge *Logic*
- 23 **Filter User Labels** If *Logic*
- 24 **Check if File Exists** If *Logic*
- 25 **Upload to Google Drive** Google Drive *Service*
- 26 **Get User Labels** Aggregate *Logic*

## How it's built

- **Starts on:** An arriving email
- **Steps:** 26, with 4 branches, 1 loop or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Gmail, Google Drive, Telegram
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Gmail, Google Drive and Telegram 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 26 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 26 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%2Fsmart-email-manager-with-gmail-and-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 Drive](https://millionrounds.com/workflows?service=Google+Drive#library)[Telegram](https://millionrounds.com/workflows?service=Telegram#library)

## Workflows like it

Also chat assistants, with the same services where possible, closest in size first.

- [**AI-powered credit card recommendation system with OpenAI** 26 steps · calls a model · Google Sheets, Telegram](https://millionrounds.com/workflow/ai-powered-credit-card-recommendation-system-with-openai)
- [**Advanced AI demo (presented at AI Developers #14 meetup)** 26 steps · calls a model · Gmail, Pinecone](https://millionrounds.com/workflow/advanced-ai-demo-presented-at-ai-developers-14-meetup)
- [**Create personalized news digests with OpenAI and SerpAPI** 26 steps · calls a model · Telegram, n8n data table](https://millionrounds.com/workflow/create-personalized-news-digests-with-openai-and-serpapi)
- [**Generate move-out deposit statements with Gmail** 26 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/generate-move-out-deposit-statements-with-gmail)
- [**Manage dental patients with Telegram and OpenAI** 26 steps · calls a model · Google Sheets, Slack](https://millionrounds.com/workflow/manage-dental-patients-with-telegram-and-openai)
- [**Revive quiet client projects with OpenAI and Airtable** 26 steps · calls a model · Airtable, Discord](https://millionrounds.com/workflow/revive-quiet-client-projects-with-openai-and-airtable)
