Intelligent Email Classification and Response Assistant - n8n Workflow

Use this powerful n8n workflow to automate Gmail triage. It leverages OpenAI for intelligent email classification, automatically labels messages, creates draft replies, and sends critical alerts to Slack. Explore advanced n8n templates for efficiency.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

This n8n template is ideal for:

Overview

Managing a high volume of email often leads to delayed responses and organizational chaos. This intelligent n8n workflow solves this by acting as a proactive email assistant. By integrating an AI agent, every incoming email matching the criteria set by the n8n trigger is immediately categorized (e.g., Inquiry, Support, Actionpoint, Newsletter). The value provided by this n8n automation includes instant triage, ensuring critical items trigger immediate Slack alerts, while routine inquiries and support requests have professional draft responses waiting in Gmail. This comprehensive n8n node setup minimizes manual effort and maximizes response speed and accuracy.

How it Works

The process begins with the Gmail n8n trigger, which monitors your inbox for new emails possessing the specific 'AI-Agent' label. Once triggered, the n8n workflow extracts key data points like the sender, subject, and content.


  1. Extraction and AI Input: The Extract Email Data n8n node prepares the content for the AI Agent - Email Classifier. This powerful n8n node uses a detailed system prompt with an OpenAI model to classify the email into one of four categories (Inquiry, Support, Newsletter, Actionpoint).

  2. Parsing and Mapping: The Parse AI Classification custom code n8n node is crucial. It converts the AI's JSON output into usable data, validates the classification, and, most importantly, maps the chosen category to the correct Gmail Label ID defined within the n8n node's code.

  3. Gmail Action: The Add Classification Label n8n node applies the corresponding label (e.g., 'Support', 'Action-Item') to the original email thread.

  4. Routing: The Route by Category switch n8n node directs the flow based on the AI classification:

Inquiry/Support: Routes to the Create Draft Response n8n node, which uses the AI-generated suggestedResponse to instantly create a draft reply in Gmail.
Newsletter: Routes to the Send Newsletter Summary to Slack n8n node, sending the AI-generated summary to a dedicated Slack channel.
* Actionpoint: Routes to the Send Action Item Slack Alert n8n node for immediate notification.

Installation Guide

To deploy this advanced n8n workflow, follow these setup steps:


  1. Import: Import this n8n template JSON into your n8n instance.

  2. Credentials: Configure credentials for the following services:

Gmail OAuth2: Required for the Gmail n8n trigger and subsequent Gmail actions (Draft creation and Labeling).
OpenAI/AI Model: Required for the AI Agent n8n node.
* Slack: Required for sending notifications.

  1. Gmail Labels Setup: Create the following labels in your Gmail account: 'AI-Agent' (for the n8n trigger), 'Inquiry', 'Support', 'Newsletter', and 'Action-Item'.

  2. Update Label IDs: Run the Gmail n8n trigger once to obtain the actual numerical IDs for your newly created labels. Update the labelMapping object inside the Parse AI Classification custom code n8n node with these IDs to ensure correct routing.

  3. Activation: Set the n8n workflow to 'Active' to start monitoring for emails.

Node Details

Gmail Trigger - AI Agent Label (Gmail Trigger n8n node)
Function: Starts the n8n workflow whenever a new email lands in the inbox and is tagged with the primary label ('AI-Agent'). This is the crucial starting n8n trigger.
Key Configuration: Filters set to look for a specific labelId.
Extract Email Data (Set n8n node)
Function: Cleans and standardizes the incoming email data (subject, sender, content) for structured input into the AI Agent n8n node.
Key Configuration: Maps raw output fields ($json.text, $json.subject) to simple fields (content, subject).
AI Agent - Email Classifier (LangChain Agent n8n node)
Function: Executes the core classification logic using OpenAI. It receives the email content and returns a strictly formatted JSON object containing the category, confidence score, and specific actions (draft response/summary).
Key Configuration: System message dictates classification rules (Inquiry, Support, Newsletter, Actionpoint) and enforces a JSON response format.
Parse AI Classification (Code n8n node)
Function: Parses the AI’s string JSON output, handles potential errors, and maps the resulting category to the correct Gmail Label ID necessary for the next Gmail n8n node action.
Key Configuration: Contains the customizable labelMapping object and logic to fetch external data (emailId, subject) from the initial Extract Email Data n8n node.
Add Classification Label (Gmail n8n node)
Function: Applies the AI-determined label (e.g., 'Support') to the original Gmail message, ensuring organization within the inbox.
Key Configuration: Uses the labelId output generated by the Parse AI Classification n8n node.
Route by Category (Switch n8n node)
Function: Routes the n8n workflow based on the AI-determined category field, directing the flow to the appropriate downstream action (Draft or Slack).
Create Draft Response (Gmail n8n node)
Function: Creates a draft reply in the original email thread using the AI-generated suggestedResponse content. This is only triggered for Inquiry and Support emails.
Send Action Item Slack Alert / Send Newsletter Summary to Slack (Slack n8n node)
* Function: Sends tailored notifications to specific Slack channels based on the classification. Uses the AI-generated summary or reasoning for the alert message.

Related n8n Workflows

Free

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

Featured*