Templates / Categorize and label incoming Gmail emails automatically with GPT-4o mini

Categorize and label incoming Gmail emails automatically with GPT-4o mini

Needs changes

by Arlin Perez βœ“ Β· 5,873 views Β· created 2025-07-02 Β· Ticket Management, AI Summarization

Needs changes. This template uses 1 thing(s) that n8n 3.0 removes: AI Agent v1 (old agent modes). 1 breaking item(s) found. Static check, last run 2026-10-19.

What to replace before upgrading

Removed in 3.0Replace with
AI Agent v1 (old agent modes)
Give a Label AI Agent (v1.8)
Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.

Worth a look

Nodes used (7)

GmailOpenAI Chat ModelStructured Output ParserAI Agent

What it does

Sort New Gmail messages by category with AI πŸ‘₯ Who's it for This workflow is perfect for individuals or teams who receive a high volume of emails πŸ“₯ and want to automatically organize them into Gmail labels 🏷️ using AI. No coding required! For sorting existing emails messages in your gmail inbox, please use this free workflow: Categorize and Label Existing Gmail Emails Automatically with GPT-4o mini. πŸ€– What it does It automatically processes new Gmail emails, skips those that already have labels, sends the content to an AI Agent powered by GPT-4o mini 🧠, and applies a relevant label based on the content. All labels must exist in Gmail beforehand. βš™οΈ How it works 1. πŸ“¬ Gmail Trigger – Activates on new email received. 2. 🚫 Filter – Skips emails that already have a label. 3. 🧠 AI Agent (GPT-4o mini) – Analyzes the message and decides which label fits best. 4. 🧾 Structured Output Parser – Formats the AI output into a clean JSON. 5. πŸ”€ Switch Node – Routes each email to the correct label path based on the AI result. 6. 🏷️ Gmail Nodes – Assign the Gmail label to the original email. πŸ“‹ Requirements - Gmail account connected to n8n - Pre-created labels in Gmail matching the AI categories - OpenAI credentials with GPT-4o mini access - n8n's AI Agent & Structured Output Parser nodes πŸ› οΈ How to set up 1. Open the workflow and adjust the trigger interval (e.g., every minute, hours or Custom using Cron ⏱️) 2. Check that the Filter skips emails with existing labels 3. Define your categories in the AI Agent prompt and make sure they match the Gmail labels 4. Configure the Switch Node conditions for each category 5. Ensure each Gmail Label Node applies the correct label 6. Save and activate the workflow βœ… 🎨 How to customize the workflow - Add or remove categories in the AI prompt & Switch Node - Fine-tune prompt instructions to match your specific use case

View the original on n8n.io β†’ Check your own copy

Get the weekly β€œwhat broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.