๐ŸŽซ Automatic email categorization and organization with Outlook and GPT-4o

โšก 2,304 views ยท ๐ŸŽซ Ticket Management & Triage

Description

n8n โ€“ Outlook AI Categorization & Labeling (Fully Automated)

> Zero manual mapping. The workflow automatically discovers your Outlook folders, understands the context, assigns the correct category, and moves the email into the right folder. It uses the original Microsoft Outlook nodes plus an AI Agent. You can connect OpenAI or any other LLM provider.


โœจ Features


๐Ÿš€ Setup (5 Steps)

  1. Connect Outlook
    In n8n โ†’ Credentials โ†’ Microsoft Outlook, grant at least Mail.ReadWrite.

  2. Connect AI
    In n8n โ†’ Credentials, set up OpenAI (or another model). Works best with GPT-4.x or GPT-4o.

  3. Import the Workflow
    n8n โ†’ Workflows โ†’ Import from File/Clipboard and paste the provided JSON.

  4. Enable Trigger
    Adjust the Schedule Trigger (e.g., every 5 minutes).

  5. Run & Verify
    Test run and watch emails get categorized and moved automatically.


๐Ÿง  How It Works

  1. Schedule Trigger pulls new emails
  2. Loop Over Items processes them one by one
  3. Markdown / varEmail cleans the content
  4. Get Many Folders fetches Outlook categories and folders
  5. Summarize + Code prepare category IDs
  6. AI Agent applies deep categorization logic
  7. Update Category applies the Outlook category
  8. Move Folder places the email in the right folder
  9. Error Handling ensures workflow stability

๐Ÿงฉ System Prompt Example

You are an advanced AI email categorization system. Your mission is to intelligently analyze and categorize emails with maximum accuracy and context awareness.

INTELLIGENT CATEGORIZATION ENGINE:

- Parse all available categories: {{ $json.category }}
- Multi-layer analysis: Sender, Subject, Body, Links, Attachments
- Prioritize: Security threats, Action Required, Business Context
- Specialized: SaaS, Hosting, E-commerce, Finance, Support, Corporate
- Anti-Spam: Pattern detection, spoofing, red-flag subjects
- Dual Logic: Primary + Secondary categories when applicable

OUTPUT FORMAT (JSON only):
{
  "subject": "EXACT_EMAIL_SUBJECT",
  "category": "PRIMARY_CATEGORY_FROM_AVAILABLE_LIST",
  "subCategory": "SECONDARY_CATEGORY_IF_APPLICABLE",
  "analysis": "Reasoning",
  "confidence": "HIGH/MEDIUM/LOW"
}

Available Categories: {{ $json.category }}

โš™๏ธ Parameters & Notes


๐Ÿ›ก๏ธ Security


๐Ÿ“„ License & Sharing


โœ… Summary

Connect โ†’ Import โ†’ Run.
No manual mapping. AI-powered categorization that labels and organizes your Outlook mailbox automatically.

๐Ÿ”— Nodes Used

Microsoft Outlook, Markdown, Schedule Trigger, Filter, AI Agent, Summarize

๐Ÿ“ฅ Import

Download workflow.json and import into n8n: Workflow menu โ†’ Import from File

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup