AI-Powered Gmail Email Categorization and Priority Slack Alerts - n8n Workflow

Use this powerful n8n workflow to automatically categorize incoming Gmail emails using GPT-4o-mini, assign priority, and route urgent alerts to dedicated Slack channels. Enhance efficiency with these n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Customer Support Managers needing rapid triage of incoming support requests.
Operations teams looking to automate internal routing of customer communications.
Developers building robust AI automation pipelines using the n8n node system.
Users seeking advanced n8n templates for integrating AI and messaging platforms.

Overview

Managing high volumes of inbound email across multiple departments (Sales, Support, Billing) requires swift categorization and routing. This robust n8n workflow solves this by leveraging the power of gpt-4o-mini via the n8n Langchain Agent node. Instead of manual triage, every new, unread email detected by the n8n trigger is analyzed against strict criteria (sales, technical support, billing, or complaint). The AI assigns a priority level (low, normal, high, urgent), and the system automatically routes the detailed alert to the correct Slack channel ID. This specific n8n workflow significantly reduces response times for high-priority complaints and ensures that all communications land with the right team instantly, transforming your email handling process using smart n8n node configurations.

How it Works

This automation operates in a precise sequence initiated by an n8n trigger:


  1. Trigger: The n8n workflow starts using the Trigger on Unread Email (Gmail Trigger n8n node), polling for new, unread messages every minute.

  2. Retrieval: The Get Email n8n node retrieves the full email body and metadata based on the triggered ID.

  3. AI Analysis: The AI Agent n8n node receives the email content. It uses a detailed system prompt and connects to the OpenAI Chat Model (using gpt-4o-mini) to classify the email based on preset categories and priorities.

  4. Data Structure Enforcement: The Structured Output Parser enforces a strict JSON schema, guaranteeing reliable extraction of category, priority, summary, and other required fields from the AI response, a crucial step in this n8n workflow.

  5. Routing Logic: The Routing Map (Set n8n node) reads the AI-assigned category and maps it dynamically to an internal department label (e.g., 'Sales') and the corresponding destination Slack Channel ID.

  6. Alert: Finally, the Send Notification to Slack n8n node uses the mapped channel ID to send a high-context notification detailing the email’s priority, summary, and the AI's reason for categorization, completing this highly efficient n8n workflow.

Installation Guide

To deploy this powerful n8n workflow using these n8n templates, follow these steps:


  1. Import: Copy the provided JSON data and paste it into your n8n canvas using the 'New' -> 'Import from JSON' option.

  2. Gmail Credentials: Click on the Trigger on Unread Email n8n trigger node and the Get Email n8n node. Set up or select your Gmail account credentials for both.

  3. OpenAI Credentials: Click on the OpenAI Chat Model n8n node and provide your OpenAI API credentials. Ensure the connection is valid.

  4. Slack Credentials: Click the Send Notification to Slack n8n node. Configure your Slack OAuth2 credentials, ensuring the scope allows sending messages to the target channels.

  5. Channel IDs: Review the Routing Map n8n node. You must replace the placeholder Slack channel IDs (e.g., C09B7HS98GN) with the actual IDs of your Sales, Support, Billing, and Complaint Slack channels.

  6. Activation: Once all credentials are set, activate the n8n workflow by toggling the 'Active' switch.

Node Details

Trigger on Unread Email (n8n trigger):
Function: The starting point of the n8n workflow. It continuously checks the linked Gmail inbox.
Key Configuration: Configured to poll every minute and specifically filters only for unread emails.
Get Email (n8n node):
Function: Fetches the complete content, including the plain text body, necessary for the AI analysis.
Key Configuration: Retrieves the message using the ID provided by the initial n8n trigger output ({{ $json.id }}).
AI Agent (n8n node):
Function: Acts as the orchestrator, defining the routing task and passing the email content to the Language Model.
Key Configuration: Uses a complex prompt to define four strict classification categories and requires minified JSON output.
OpenAI Chat Model (n8n node):
Function: Provides the machine learning inference capability for this n8n workflow.
Key Configuration: Utilizes the cost-effective and fast gpt-4o-mini model.
Structured Output Parser (n8n node):
Function: Guarantees that the AI response adheres to a strict JSON schema, ensuring reliable downstream routing.
Key Configuration: Defines specific properties (category, priority, summary) and requires certain fields to be present.
Routing Map (Set n8n node):
Function: Translates the AI's categorized output into actionable internal metadata (label and channel ID).
Key Configuration: Contains conditional expressions (=if...) to dynamically assign the slackChannel ID based on the AI-determined category.
Send Notification to Slack (n8n node):
Function: The final action of this n8n workflow, sending the high-priority alert.
* Key Configuration: Dynamically sets the destination channel using the {{ $json.slackChannel }} variable defined in the previous n8n node and formats a concise alert message.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by
Matt Chong | n8n Creator
Matt Chong | n8n Creator

Automation nerd fueled by good coffee, deep curiosity, and clean flows.

Featured*