Automatic Outlook Email Categorization using GPT-4o - n8n Workflow

Use this powerful n8n workflow to automatically fetch Outlook emails, categorize their intent (Red, Yellow, Green) using GPT-4o intelligence, and update the color categories instantly. Integrate AI easily with this n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Busy Professionals: Individuals overwhelmed by high email volumes needing automatic triage.
Automation Specialists: Users seeking advanced examples of integrating LLMs with email clients in an n8n workflow.
Project Managers: Teams who use color categories in Outlook (Red, Yellow, Green) to signify priority or action required.
Technical Users: Anyone looking to implement a LangChain AI agent using a structured output parser within an n8n node framework.

Overview

Managing a high volume of emails often requires manual categorization, which is time-consuming and error-prone. This specialized n8n workflow solves this by introducing a layer of artificial intelligence into your email management routine.

This n8n templates solution connects Microsoft Outlook directly to OpenAI's powerful GPT-4o model. The workflow fetches the latest emails, passes the subject and body to the AI for analysis, and receives a strict, structured categorization (e.g., Red Category, Yellow Category, or Green Category). The final step uses an Outlook n8n node to instantly update the message with the correct color category. This automation saves significant time, ensuring that critical emails are categorized immediately, enhancing productivity using the power of n8n.

How it Works

This automation is initiated by a manual n8n trigger, allowing the user to control execution time, though it could easily be adapted into a time-based n8n trigger. The n8n workflow follows these sequential steps:


  1. Trigger and Fetch: The process starts via the manual n8n trigger. The next n8n node, Get Messages from Outlook, fetches the latest 5 emails from the user's inbox.

  2. Data Preparation: The Set Fields from Email n8n node extracts the essential data points for AI processing: subject, body preview, and, critically, the unique Message ID of the Outlook email.

  3. Item Looping: A subsequent node ensures each email item is processed individually through the AI chain.

  4. AI Categorization Agent: The core logic resides in the LangChain-based Categorizing Agent n8n node. This agent takes the email content and uses the connected OpenAI Chat Model1 (set to use gpt-4o) and the Structured Output Parser to determine the appropriate category (Red, Yellow, or Green).

  5. Output Mapping: The Set Category and ID n8n node takes the JSON output from the AI agent and the original Message ID (fetched earlier) and maps them into a simple structure ready for the update action.

  6. Final Update: The final Update Category n8n node, using the Outlook credentials, applies the AI-determined category to the corresponding email in Outlook, completing the n8n workflow.

Installation Guide

To deploy this expert n8n workflow and start automating your Outlook categorization, follow these steps:


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

  2. Set Up Microsoft Outlook Credentials:

Go to Credentials in n8n and create a new Microsoft Outlook OAuth2 API credential.
Connect your Outlook account and grant the necessary permissions.
Attach this credential to both the Get Messages from Outlook and Update Category n8n node instances.

  1. Set Up OpenAI Credentials:

Create or locate your OpenAI API key from the OpenAI platform.
In n8n, create a new OpenAI API credential and input your key.
Attach this credential to the OpenAI Chat Model1 n8n node.

  1. Configuration Check: Ensure the limit parameter on the Get Messages from Outlook n8n node is set to your preferred number of emails to process (default is 5).

  2. Execution: Run the n8n workflow by clicking the 'Execute workflow' n8n trigger.

Node Details

When clicking ‘Execute workflow’ (Manual Trigger): The starting point for this specific n8n workflow, allowing manual testing and execution. This serves as the initial n8n trigger.
Get Messages from Outlook (Microsoft Outlook n8n node): Fetches recent messages from your Outlook mailbox.
Key Configuration: Operation is getAll, and the limit is set to 5 messages.
Set Fields from Email (Set n8n node): Extracts and standardizes key email fields (subject, bodyPreview, and the unique Message ID) necessary for AI processing and later updating the message.
OpenAI Chat Model1 (LangChain LM Chat OpenAI n8n node): Provides the language model used by the agent.
Key Configuration: Uses the powerful gpt-4o model for advanced reasoning and categorization accuracy.
Structured Output Parser (LangChain Output Parser n8n node): Enforces a strict JSON structure for the AI's response, ensuring reliability.
Key Configuration: Specifies the required output format {"category": "Red Category, Yellow Category, or Green Category"}.
Categorizing Agent (LangChain Agent n8n node): The core intelligence component. It feeds the email content into GPT-4o and utilizes the structured parser to return the determined category. This intelligent n8n node defines the system prompt for categorization.
Update Category (Microsoft Outlook n8n node): The final action node. It targets the email using the Message ID and updates the message's categories field with the AI-generated color category, completing the n8n workflow.

Related n8n Workflows

Free

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

Professional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.

Featured*