workflows.fit
Back to n8n workflows
n8n templateFreeBy AlexAutomates

Automated inbox organization for Outlook using GPT-4.1 agent

Auto-Categorize Outlook Emails with AI in n8n How It Works 1. Trigger: The workflow starts with the Microsoft Outlook Trigger node, polling your inbox every minute for new emails. 2. Extract & Clean Email Content: The...

DevelopmentCore NodesAILangchainCommunicationMicrosoft Outlook TriggerAgentMicrosoft Outlook Tool
Loading interactive preview...

Template notes

Auto-Categorize Outlook Emails with AI in n8n

How It Works

1. Trigger: The workflow starts with the Microsoft Outlook Trigger node, polling your inbox every minute for new emails. 2. Extract & Clean Email Content: The email’s key fields (from, subject, isRead, body) are extracted. The body is converted from HTML to Markdown, then sanitized to plain text for reliable AI processing.

Node Setup Details:

- Microsoft Outlook Trigger - Resource: Message - Operation: Trigger on new email - Fields to Output: from, subject, isRead(optional), body - Folders to Include: (Set to your Inbox or specific folder IDs) - Markdown Node - Input: {{$json["body"]["content"]}} (HTML email body) - Output Key: Email Body Markdown - Purpose: Converts HTML to Markdown for easier downstream processing. - Sanitize Node (Code Node) - Input: Email Body Markdown from previous node - Purpose: Cleans up Markdown, strips images, links, HTML tags, table formatting, and truncates to 4000 characters. - Sample JS Code: javascript // Get the markdown content from the previous node const markdownContent = $input.item.json["Email Body Markdown"];

3. Setup AI tools - Move message and Get Folders Outlook tools are required, get contacts is optional. - Set each field in the tools to "defined automatically by the model" and describe each field so the model understands how to use it. - OpenRouter or other LLM models tool: You can use any client for this, but make sure to use a model that does well with tool calls (Claude, GPT-4.1, Gemini 2.5 Pro, etc.).

---

Best Practices & Notes