# Triage and reply to email threads with OpenAI and IMAP: n8n workflow

> Started by an arriving email, and works across Email, Gmail and n8n data table. It hands the judgement calls to OpenAI.

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

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

# Triage and reply to email threads with OpenAI and IMAP

Started by an arriving email, and works across Email, Gmail and n8n data table. It hands the judgement calls to OpenAI. 19 steps, 1 branch: a working afternoon to understand properly.

Medium Calls a model: OpenAI

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Ftriage-and-reply-to-email-threads-with-openai-and-imap)

**19 steps** Medium: a working afternoon

**1** Branch: places the flow splits

**0** Loops or waits

**3** Services it connects to

## The flow

Model 1 Logic 5 Service 13

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

- 1 **When Email Received (IMAP)** Email Read Imap *Service*
- 2 **Filter Replied Emails** Filter *Logic*
- 3 **Parse Email Content** Code *Logic*
- 4 **Prepare AI Prompt** Code *Logic*
- 5 **Transfer Execution Data** Execution Data *Service*
- 6 **OpenAI Model Interaction** Open Ai *Model*
- 7 **Normalize AI Response** Code *Logic*
- 8 **Route by Email Status** Switch *Logic*
- 9 **Fetch Email Thread ID 1** Gmail *Service*
- 10 **Fetch Email Thread ID 2** Gmail *Service*
- 11 **Reply to Email - Thread ID 1** Gmail *Service*
- 12 **Reply to Email - Thread ID 2** Gmail *Service*
- 13 **Post to Suppression List API** Http Request *Service*
- 14 **Insert Data to Table 2** Data Table *Service*
- 15 **Insert Data to Table 1** Data Table *Service*
- 16 **Add Label to Email Thread 2** Gmail *Service*
- 17 **Add Label to Email Thread 1** Gmail *Service*
- 18 **Remove Label from Thread 2** Gmail *Service*
- 19 **Remove Label from Thread 1** Gmail *Service*

## How it's built

- **Starts on:** An arriving email
- **Steps:** 19, with 1 branch
- **Size:** Medium: a working afternoon
- **Connects to:** Email, Gmail, n8n data table
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Email and Gmail 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?

Plan an afternoon. 19 steps is enough that you should read each one before running it.

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 19 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%2Ftriage-and-reply-to-email-threads-with-openai-and-imap)
- **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.

[Email](https://millionrounds.com/workflows?service=Email#library)[Gmail](https://millionrounds.com/workflows?service=Gmail#library)[n8n data table](https://millionrounds.com/workflows?service=n8n+data+table#library)

## Workflows like it

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

- [**Find and log GDPR request evidence with Groq and Data Tables** 19 steps · calls a model · n8n data table](https://millionrounds.com/workflow/find-and-log-gdpr-request-evidence-with-groq-and-data-tables)
- [**Score inspection defects and draft repair packets with OpenAI** 19 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/score-inspection-defects-and-draft-repair-packets-with-opena)
- [**AI-powered email forwarding to WhatsApp with Gmail and Outlook** 18 steps · calls a model · Gmail](https://millionrounds.com/workflow/ai-powered-email-forwarding-to-whatsapp-with-gmail-and-outlo)
- [**Draft customer-facing changelogs from merged GitHub PRs** 20 steps · calls a model · GitHub, Gmail](https://millionrounds.com/workflow/draft-customer-facing-changelogs-from-merged-github-prs)
- [**Generate & deploy landing pages with OpenAI and Gemini** 20 steps · calls a model · n8n data table](https://millionrounds.com/workflow/generate-and-deploy-landing-pages-with-openai-and-gemini)
- [**Generate company due diligence PDFs with Gemini and SEC EDGAR** 18 steps · calls a model · Gmail, RSS](https://millionrounds.com/workflow/generate-company-due-diligence-pdfs-with-gemini-and-sec-edga)
