Use this powerful n8n workflow to automatically categorize and label existing emails in your Gmail inbox using the GPT-4o mini AI model and structured output.
Download this n8n workflow template and start using it instantly.
This powerful n8n workflow provides an efficient solution for tackling existing, unlabeled emails in your Gmail inbox in bulk. Instead of manually sifting through messages, this n8n automation template leverages the power of GPT-4o mini to analyze the content (subject and body) of each email. It uses a manual n8n trigger, making it ideal for scheduled or on-demand inbox cleanups. The workflow ensures only unlabeled emails are processed by a dedicated Filter n8n node, maximizing efficiency and minimizing API costs. By utilizing structured output and dedicated routing, the n8n workflow accurately assigns and applies the correct Gmail label to categorize your communications automatically.
The process begins with the Manual Trigger n8n node, initiated by clicking 'Execute workflow.'
{"emaillabel": "Shopping"}). emaillabel from the AI output and routes the email data down the corresponding path (e.g., the 'Finance' route).To deploy this n8n template, follow these steps:
When clicking ‘Execute workflow’ (Manual Trigger): This n8n trigger starts the process on demand, enabling bulk execution for existing email cleanup.
Get many messages (Gmail n8n node):
Function: Fetches a batch of emails for processing.
Key Configuration: Operation is getAll (fetches many messages).
Label Checker Filter (Filter n8n node):
Function: Filters out emails that already have a label attached, ensuring the AI only processes unlabeled messages.
Key Configuration: Checks if labelIds[0] does not contain "Label".
OpenAI Chat Model (n8n node):
Function: Provides the language model backend for the AI Agent.
Key Configuration: Uses the gpt-4o-mini model.
Structured Output Parser (n8n node):
Function: Enforces that the AI output adheres to a strict JSON schema ({"emaillabel": "..."}), crucial for reliable routing.
Give a Label AI Agent (n8n node):
Function: Analyzes the email subject and description using the predefined system prompt to determine the correct category.
Key Configuration: System prompt defines 7 distinct categories that must match the Gmail labels.
Switch (n8n node):
Function: Routes the workflow based on the emaillabel extracted by the AI, creating separate branches for each category.
Gmail Label Nodes (e.g., 'Work', 'Finance'):
Function: Applies the specific category label to the corresponding email message ID.
Key Configuration: Operation is addLabels; uses the message ID retrieved by the initial n8n trigger data.
Use this comprehensive n8n workflow template to receive instant, detailed alerts on Telegram whenever a WooCommerce order status changes to processing. Ideal for e-commerce operations.

Leverage this powerful n8n workflow to automatically parse complex EDI messages received via Gmail and log the extracted order details into Google Sheets, streamlining B2B data entry.

Automate logistics damage reporting using an n8n workflow. Operators send photos via Telegram, GPT-4o generates structured reports and extracts barcodes, and the final document is emailed via Gmail. Use this efficient n8n template today.

Automate EU news monitoring using this powerful n8n workflow. It filters RSS feeds with GPT-4o-mini, creates HTML email digests via Gmail, and generates a 30-second voice summary using ElevenLabs and Telegram.

👋 Hi! I'm Arlin - a QA Engineer with 2 years of experience and a background in Dart & Flutter for mobile app development. ⚙️ I'm passionate about automation and love building efficient workflows using n8n. 📬 Reach out for any help with custom workflows







































