Smart Gmail Classifier and Auto-Labeler using GPT-4o-mini - n8n Workflow

Automate Gmail organization using an n8n workflow leveraging GPT-4o-mini. Classify emails (Job, Application Status, Enquiries) and apply custom Gmail labels automatically using this powerful n8n template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Job Seekers and Recruiters: Automatically categorize application statuses and job opportunities.
Busy Professionals: Anyone receiving high volumes of email needing automated organization.
n8n Users: Users looking for advanced n8n templates integrating AI for core logic.
Automation Specialists: Those building sophisticated n8n workflow solutions for email management.

Overview

The provided n8n workflow template solves the chronic problem of manual email triage and organization. Instead of spending time manually labeling incoming messages, this powerful n8n automation leverages the intelligence of the GPT-4o-mini model to accurately categorize emails into specific buckets (Job Opportunity, Application Status, Enquiries, Others).

This sophisticated n8n node setup ensures that your inbox remains clean and organized daily. This is a prime example of how effective n8n templates can transform routine administrative tasks, establishing an efficient, AI-driven email management system directly within your n8n infrastructure. Utilizing the core capabilities of the n8n platform, this solution enhances productivity by ensuring critical communications are correctly filed immediately.

How it Works

The entire process is initiated by the Daily Email Check n8n trigger, which is configured as a scheduled Cron n8n node running once per day (at 23:00) for batch processing.


  1. Fetch Messages: The subsequent Fetch New Emails n8n node uses the Gmail connector to retrieve a defined number (up to 10) of the newest emails.

  2. AI Classification Setup: The workflow utilizes the OpenAI Chat Model n8n node, configured to use the high-speed gpt-4o-mini model, providing the necessary intelligence.

  3. Classification: The Email Classifier n8n node takes the text content of each fetched email. It instructs the large language model via a system prompt to strictly classify the email into one of the four predefined categories (Job Opportunity, Application Status, Others, Enquiries) and output the result in a strict JSON format.

  4. Labeling: Based on the output category from the classification step, the n8n workflow routes the execution path to one of the four final Gmail n8n nodes (Job Opportunity, Application Status, Others, or Enquiries). Each of these nodes executes the addLabels operation, applying the appropriate, pre-configured Gmail label ID to the original message ID.

Installation Guide

To deploy this n8n workflow, follow these steps:


  1. Import: Copy the entire JSON code and paste it into your n8n instance via the 'New' menu > 'Import from JSON'.

  2. Credentials: You will need two types of credentials:

OpenAI API Key: Set up credentials for the OpenAI Chat Model n8n node. Ensure your account is authorized to use gpt-4o-mini.
Gmail OAuth2: Configure OAuth2 credentials for the Gmail n8n nodes, ensuring they have the necessary scope to read, modify, and apply labels to your inbox.

  1. Label IDs: Crucial Step: Manually update the labelIds parameters in the four Gmail nodes (Job Opportunity, Application Status, Others, Enquiries) to match the actual, custom Gmail label IDs you wish to use. These IDs are often long strings (e.g., Label_123456789...) and must be correct for the n8n workflow to function.

  2. Activation: Once credentials and label IDs are updated, activate the n8n workflow.

Node Details

Daily Email Check (Cron n8n trigger):
Function: Serves as the schedule n8n trigger, initiating the n8n workflow once daily.
Key Configuration: Runs daily at 23:00.
Fetch New Emails (Gmail n8n node):
Function: Retrieves up to 10 new emails from the mailbox to be processed by the AI.
Key Configuration: Operation set to getAll; limited to 10 messages.
OpenAI Chat Model (LangChain n8n node):
Function: Provides the language model backend required for complex classification logic.
Key Configuration: Uses the high-efficiency gpt-4o-mini model.
Email Classifier (LangChain Text Classifier n8n node):
Function: Analyzes the email body and subject to determine the appropriate category.
Key Configuration: Defines four specific categories (Job Opportunity, Application Status, Others, Enquiries) and uses a system prompt demanding strict JSON output for reliable parsing by the n8n workflow.
Job Opportunity / Application Status / Others / Enquiries (Gmail n8n nodes):
Function: The final action in the n8n workflow, applying the predefined custom label to the email message ID retrieved in the initial step.
* Key Configuration: Operation set to addLabels; requires the specific, unique Gmail Label ID for accurate labeling.

Related n8n Workflows

Paid

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by

Hi, I’m Ashish — an automation architect and AI enthusiast helping people work smarter. I build AI-powered workflows that save time, boost productivity, and create real-world impact. Passionate about no-code, startups, and smart systems that scale. Let’s automate success, one workflow at a time! 🚀

Featured*