Smart AI Gmail Manager: Classification and Draft Generation - n8n Workflow

Use this powerful n8n workflow to automatically classify incoming Gmail messages using Gemini AI, apply custom labels, and safely generate reply drafts for review. Leverage smart n8n node tools for context.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Highly beneficial for:
Busy executives or professionals drowning in email.
Users looking for advanced AI-driven inbox management.
Automation specialists who want to leverage the power of n8n templates integrating LLMs and Google services.
Anyone seeking a structured n8n workflow solution to triage email without sending automated replies.

Overview

Managing a high volume of emails can be a significant time drain. This advanced n8n workflow solves this by acting as an intelligent pre-sorter and draft assistant. When a new email arrives, this n8n automation first cleans up existing category labels and then hands the content, thread history, and sender data to the Gemini AI model.

The AI determines the email’s category (e.g., Sales, Vendor, Important, or DELETE) and decides if a response is required. This specific n8n workflow ensures safety: if the label is 'SAVE,' the appropriate label is applied; if the email needs a response, the AI generates a draft that includes calendar availability checks. The draft is saved securely in Gmail—it is never sent automatically, giving the user full control. This is a powerful use case for n8n templates focused on personal productivity.

How it Works

This intelligent Gmail n8n workflow operates in three primary phases: Trigger & Triage, Classification, and Action/Drafting.


  1. Gmail Trigger: The entire process begins with the Gmail n8n trigger, which monitors the inbox for new, incoming messages every minute. When a new email is detected, the workflow activates.

  2. Label Removal: The first step uses a Gmail n8n node to remove general category labels (like INBOX, IMPORTANT, SOCIAL) to prepare the message for specific AI classification.

  3. AI Email Classifier: This n8n node, utilizing Gemini via the LangChain Agent, reads the email. It intelligently uses auxiliary Gmail tools (GetThread and CheckSent) to gather full conversation history and check past interactions with the sender. It outputs structured JSON containing the required label, its ID, and a boolean flag indicating if a reply is necessary (requiresResponse).

  4. Conditional Labeling (IF Delete): An IF n8n node checks the AI's output. If the recommended label is 'DELETE', the email is trashed using the Gmail n8n node. Otherwise, the specified custom label is applied.

  5. Conditional Drafting (IF Response): After labeling, another IF n8n node checks the requiresResponse flag. If true, the workflow proceeds to draft creation.

  6. AI Draft Maker: This second AI n8n node takes over. It uses the GetThread1 tool for context and, crucially, the CheckCalendar Google Calendar tool. This allows the AI to suggest real, available time slots if the sender is requesting a meeting. It outputs the draft text and internal notes.

  7. Create a Draft: The final Gmail n8n node uses the AI-generated text to create a draft reply, linking it to the original thread, ready for the user to review and send.

Installation Guide

To deploy this comprehensive n8n workflow, follow these steps:


  1. Import the n8n template: Copy the provided JSON and import it directly into your n8n instance.

  2. Set up Credentials: You will need to configure three primary credentials:

Gmail OAuth2: Used by the Gmail Trigger, Remove Label, Add Label, Trash Message, Create a Draft, and all Gmail Tool nodes. This requires permissions to read, modify, and manage Gmail.
Google Calendar OAuth2: Used by the CheckCalendar n8n node for scheduling availability checks.
* Gemini API Key: Required for the AI Email Classifier and AI Draft Maker nodes to access the large language model.

  1. Customize the Prompting Nodes: Edit the AI Email Classifier and AI Draft Maker nodes. Replace all bracketed placeholder text (e.g., [INPUT YOUR EMAIL HERE], [INPUT LABEL 1], [YOUR OWN TIMEZONE HERE]) with your specific labels, IDs, rules, and timezone information. This is critical for the n8n workflow to classify correctly.

  2. Activate the n8n trigger: Once credentials and customization are complete, activate the Gmail Trigger to start monitoring your inbox.

Node Details

This n8n workflow leverages several specialized n8n node types:

Gmail Trigger: The fundamental starting point (n8n trigger). Function: Monitors the specified Gmail account for new emails every minute.
Gmail (RemoveLabel / AddLabel / TrashMessage / Create a draft): These standard Gmail n8n node operations handle the manipulation of the email, applying or removing labels, and creating the final draft reply.
AI Email Classifier (LangChain Agent n8n node): Function: The core classification engine. It directs Gemini to analyze the email, use Gmail tools for context (GetThread, CheckSent), and classify it into custom labels, determining if a response is needed.
Structured Output Parser (n8n node): Function: Ensures the AI classification output is strictly formatted as JSON, allowing downstream n8n nodes (like the IF logic) to easily access variables like labelID and requiresResponse.
IF (n8n node): Function: Provides flow control, branching the n8n workflow based on the AI's classification (e.g., is the message to be DELETED? Is a RESPONSE required?).
AI Draft Maker (LangChain Agent n8n node): Function: Generates the reply draft text. It utilizes the powerful CheckCalendar n8n tool to embed accurate availability into its suggestions, vastly improving the quality of the automated draft.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by
Salvador
Salvador

Business Analyst passionate about automation. I help teams and productivity enthusiasts streamline workflows, eliminate manual tasks, and scale their operations using n8n and smart process design.

Featured*