使用AI代理自动分类Outlook邮件
中级
这是一个Ticket Management, AI Summarization领域的自动化工作流,包含 9 个节点。主要使用 Code, Markdown, Agent, MicrosoftOutlookTool, MicrosoftOutlookTrigger 等节点。 使用GPT-4.1代理自动整理Outlook收件箱
前置要求
- •无特殊前置要求,导入即可使用
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "2eEiaDecIH2A1L5B",
"meta": {
"instanceId": "57ebb56a6cec4a647aac549d1f247468258466306bf889b902942d504f76d0ec",
"templateId": "2454",
"templateCredsSetupCompleted": true
},
"name": "Auto-Categorize Outlook Emails with AI Agent",
"tags": [
{
"id": "CbUjmxKVzwUyY7rS",
"name": "metamation",
"createdAt": "2025-02-27T02:44:26.211Z",
"updatedAt": "2025-02-27T02:44:26.211Z"
}
],
"nodes": [
{
"id": "3269968d-0373-45a0-9e29-10c4859b6197",
"name": "Microsoft Outlook Trigger",
"type": "n8n-nodes-base.microsoftOutlookTrigger",
"position": [
320,
272
],
"parameters": {
"fields": [
"from",
"subject",
"isRead",
"body"
],
"output": "fields",
"filters": {
"foldersToInclude": [
"AAMkAGRiZDlmMzhhLTRjOTctNGYxZC1iZDNjLTRhNTFkZGMzZTQ5YwAuAAAAAACdE2dovEwhS5uGZMOqP8rcAQCwdsIutyDWQrW17vFEit2HAAAAAAEMAAA="
]
},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"microsoftOutlookOAuth2Api": {
"id": "4KC5nBToT6YWStpV",
"name": "Microsoft Outlook - Alex METAMATION"
}
},
"typeVersion": 1
},
{
"id": "3519328e-d6fa-482d-b2eb-8283d2e06bd7",
"name": "AI Agent - Determine Category",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
960,
272
],
"parameters": {
"text": "=Your goal is to keep the user's Inbox clean, containing ONLY actionable client communication or new inquiries. Categorise the email below by selecting the most appropriate folder ID from the list provided.\n\nEmail Subject: {{ $('Microsoft Outlook Trigger').item.json.subject }}\nSenders Email: {{ $('Microsoft Outlook Trigger').item.json.from.emailAddress.address }}\nSenders Name: {{ $('Microsoft Outlook Trigger').item.json.from.emailAddress.name }}\nEmail Body: {{ $json.sanitizedBody }}\nEmail ID: {{ $('Microsoft Outlook Trigger').item.json.id }}\n\n**Instructions:**\n1. First, determine if this email requires direct user action/reply (e.g., a client message, a new inquiry from a person). If YES, choose the ID for the 'Action' folder.\n2. If NO, determine the best category folder from the list provided (e.g., Junk, Receipt, SaaS, Community, Business, Other) and choose its ID.\n3. If none of the standard folders fit well, choose the ID for the 'Other' folder.\n4. Analyze sender, subject, and body.\n5. Emails that contain an ongoing conversation should not be moved.\n6. Use all tools to retrieve folders, contacts, and the ability to move messages, using ID's. \n7. Only ID of folders are recognized by outlook tools whening moving messages. \n8. Make sure to use the think tool. \n9. If a message is not moved, very briefly explain why. \n\nMessages from saved contacts should not be moved. \n\nIf the from field is an actual human, e.g. not a support@x.com, info@x.com, then do not use the move tool and simply output why it was not moved. You can also interpret this as if there is a persons name in the email.\ne.g. john@metamation.net.",
"options": {
"systemMessage": "You are an expert assistant for Alex helping manage his Outlook Inbox. The PRIMARY GOAL is to move all non-essential emails OUT of the Inbox."
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.6
},
{
"id": "074a81c3-de13-455e-98c4-6b69f69830d0",
"name": "Move Message",
"type": "n8n-nodes-base.microsoftOutlookTool",
"position": [
992,
496
],
"webhookId": "d79de56d-8e0f-47a0-b90a-0d5984cefb8d",
"parameters": {
"folderId": {
"__rl": true,
"mode": "id",
"value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Parent_Folder', `ID of the folder to move the message to`, 'string') }}"
},
"messageId": {
"__rl": true,
"mode": "id",
"value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', `ID of the email`, 'string') }}"
},
"operation": "move"
},
"credentials": {
"microsoftOutlookOAuth2Api": {
"id": "4KC5nBToT6YWStpV",
"name": "Microsoft Outlook - Alex METAMATION"
}
},
"typeVersion": 2
},
{
"id": "a18369cf-6ef2-4f90-ab20-c2d09350a06a",
"name": "Get Folders",
"type": "n8n-nodes-base.microsoftOutlookTool",
"position": [
1120,
496
],
"webhookId": "3ca45b6d-1716-4642-812d-798a18565717",
"parameters": {
"filters": {},
"options": {},
"resource": "folder",
"operation": "getAll",
"returnAll": true,
"descriptionType": "manual",
"toolDescription": "All folders available to move messages to. "
},
"credentials": {
"microsoftOutlookOAuth2Api": {
"id": "4KC5nBToT6YWStpV",
"name": "Microsoft Outlook - Alex METAMATION"
}
},
"typeVersion": 2
},
{
"id": "90c2c14d-5189-4793-9615-b83772185715",
"name": "OpenRouter Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"position": [
864,
496
],
"parameters": {
"model": "openai/gpt-4.1",
"options": {}
},
"credentials": {
"openRouterApi": {
"id": "epNOLCfZGhs7dyQh",
"name": "OpenRouter METAMATION"
}
},
"typeVersion": 1
},
{
"id": "137a6971-7823-4929-9034-2081774793af",
"name": "Get Contacts",
"type": "n8n-nodes-base.microsoftOutlookTool",
"position": [
1248,
496
],
"webhookId": "b17b3911-ff01-423c-80f6-f5419e60925b",
"parameters": {
"filters": {},
"resource": "contact",
"returnAll": true,
"descriptionType": "manual",
"toolDescription": "All saved contacts."
},
"credentials": {
"microsoftOutlookOAuth2Api": {
"id": "4KC5nBToT6YWStpV",
"name": "Microsoft Outlook - Alex METAMATION"
}
},
"typeVersion": 2
},
{
"id": "53a13b8f-1f87-498e-a386-56b0d13ee122",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-944,
-176
],
"parameters": {
"width": 1200,
"height": 1136,
"content": "# Auto-Categorize Outlook Emails with AI in n8n\n\n## **How It Works**\n\n1. **Trigger:** The workflow starts with the **Microsoft Outlook Trigger** node, polling your inbox every minute for new emails.\n2. **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.\n\n **Node Setup Details:**\n\n - **Microsoft Outlook Trigger**\n - **Resource:** Message\n - **Operation:** Trigger on new email\n - **Fields to Output:** from, subject, isRead(optional), body\n - **Folders to Include:** (Set to your Inbox or specific folder IDs)\n \n - **Markdown Node**\n - **Input:** `{{$json[\"body\"][\"content\"]}}` (HTML email body)\n - **Output Key:** `Email Body Markdown`\n - **Purpose:** Converts HTML to Markdown for easier downstream processing.\n \n - **Sanitize Node (Code Node)**\n - **Input:** `Email Body Markdown` from previous node\n - **Purpose:** Cleans up Markdown, strips images, links, HTML tags, table formatting, and truncates to 4000 characters.\n - **Sample JS Code:**\n ```javascript\n // Get the markdown content from the previous node\n const markdownContent = $input.item.json[\"Email Body Markdown\"];\n\n3. **Setup AI tools**\n - Move message and Get Folders Outlook tools are required, get contacts is optional.\n - Set each field in the tools to \"defined automatically by the model\" and describe each field so the model understands how to use it.\n - 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.).\n\n---\n\n## **Best Practices & Notes**\n\n- **AI Prompt Engineering:** The AI is instructed to be conservative—never move emails from real people or saved contacts, and always explain its reasoning if it doesn’t move a message.\n- This automation only works for **NEW** incoming messages.\n- **Inbox Zero:** This system is designed to help you achieve and maintain Inbox Zero by keeping only actionable items in your main inbox.\n- **Customization:** You can adjust the folder logic, add more categories, or tweak the AI prompt for your specific needs.\n- **Privacy:** All processing happens within your n8n instance; no email data is stored outside your environment except for the AI call (which only receives sanitized, minimal content)."
},
"typeVersion": 1
},
{
"id": "b9cf3998-4e0f-4eb3-b7d5-66f0095afdbc",
"name": "Markdown",
"type": "n8n-nodes-base.markdown",
"position": [
544,
272
],
"parameters": {
"html": "={{ $json.body.content }}",
"options": {},
"destinationKey": "Email Body Markdown"
},
"typeVersion": 1
},
{
"id": "1c6e14b7-9d17-4780-8e84-e5f047672366",
"name": "Sanitize Email Body",
"type": "n8n-nodes-base.code",
"position": [
768,
272
],
"parameters": {
"jsCode": "// Get the markdown content from the previous node\nconst markdownContent = $input.item.json[\"Email Body Markdown\"];\n\nlet plainText = markdownContent;\n\n// 1. Remove Markdown images completely\nplainText = plainText.replace(/!\\[.*?\\]\\(.*?\\)/g, '');\n\n// 2. Simplify Markdown links - keep text, replace URL with '[link]'\nplainText = plainText.replace(/\\[(.*?)\\]\\(.*?\\)/g, '$1 [link]');\n// --- OR Remove [link] placeholder entirely if not needed ---\n// plainText = plainText.replace(/\\[(.*?)\\]\\(.*?\\)/g, '$1');\n\n// 3. Remove any remaining HTML-like tags\nplainText = plainText.replace(/<[^>]*>/g, '');\n\n// 4. Remove Markdown table separators and leading/trailing pipes from lines\nplainText = plainText.replace(/^\\||\\|$/gm, ''); // Remove leading/trailing pipes per line\nplainText = plainText.replace(/^\\s*[-|:]+\\s*$/gm, ''); // Remove lines that are just separators\n\n// 5. Normalize and reduce whitespace (run this AFTER other removals)\nplainText = plainText.replace(/(\\s*\\r?\\n\\s*){2,}/g, '\\n\\n'); // Collapse multiple blank lines\nplainText = plainText.split('\\n').map(line => line.trim()).filter(line => line.length > 0).join('\\n'); // Trim lines, remove empty lines\nplainText = plainText.trim(); // Trim whole string\n\n// 6. Truncate (Keep this step last)\nconst MAX_CHARS = 4000; // Or your desired limit\nif (plainText.length > MAX_CHARS) {\n plainText = plainText.substring(0, MAX_CHARS) + \"... (truncated)\";\n}\n\n// Return the more thoroughly sanitized text\nreturn { sanitizedBody: plainText };"
},
"typeVersion": 2
}
],
"active": true,
"pinData": {},
"settings": {},
"versionId": "63068993-f77e-450a-9831-e227bb2637ae",
"connections": {
"b9cf3998-4e0f-4eb3-b7d5-66f0095afdbc": {
"main": [
[
{
"node": "1c6e14b7-9d17-4780-8e84-e5f047672366",
"type": "main",
"index": 0
}
]
]
},
"a18369cf-6ef2-4f90-ab20-c2d09350a06a": {
"ai_tool": [
[
{
"node": "3519328e-d6fa-482d-b2eb-8283d2e06bd7",
"type": "ai_tool",
"index": 0
}
]
]
},
"137a6971-7823-4929-9034-2081774793af": {
"ai_tool": [
[
{
"node": "3519328e-d6fa-482d-b2eb-8283d2e06bd7",
"type": "ai_tool",
"index": 0
}
]
]
},
"074a81c3-de13-455e-98c4-6b69f69830d0": {
"ai_tool": [
[
{
"node": "3519328e-d6fa-482d-b2eb-8283d2e06bd7",
"type": "ai_tool",
"index": 0
}
]
]
},
"1c6e14b7-9d17-4780-8e84-e5f047672366": {
"main": [
[
{
"node": "3519328e-d6fa-482d-b2eb-8283d2e06bd7",
"type": "main",
"index": 0
}
]
]
},
"90c2c14d-5189-4793-9615-b83772185715": {
"ai_languageModel": [
[
{
"node": "3519328e-d6fa-482d-b2eb-8283d2e06bd7",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"3269968d-0373-45a0-9e29-10c4859b6197": {
"main": [
[
{
"node": "b9cf3998-4e0f-4eb3-b7d5-66f0095afdbc",
"type": "main",
"index": 0
}
]
]
},
"3519328e-d6fa-482d-b2eb-8283d2e06bd7": {
"main": [
[]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 工单管理, AI 摘要总结
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用AI全自动分类Outlook邮件
使用Outlook和GPT-4o自动分类和组织邮件
If
Set
Code
+
If
Set
Code
23 节点Can KURT
杂项
财务报告 AI:通过 OpenRouter + Perplexity 生成简洁的 SEC
财务报告 AI:通过 OpenRouter + Perplexity 生成简洁的 SEC 10-K/10-Q 摘要
Set
Code
Markdown
+
Set
Code
Markdown
17 节点Ashish Kumar Swain
市场调研
AI 客户支持分流与摘要系统
使用GPT-4o、Slack和CRM集成自动处理客户支持
If
Set
Code
+
If
Set
Code
32 节点NodeAlchemy
工单管理
使用 Gmail、Groq AI 和 Google Sheets 自动化邮件过滤与 AI
使用 Gmail、Groq AI 和 Google Sheets 自动化邮件过滤与 AI 摘要
If
Code
Gmail Trigger
+
If
Code
Gmail Trigger
14 节点ARRE
工单管理
具有 AI 分类、Gmail 草稿和 Slack 通知的智能电子邮件助手
使用 OpenAI 分类、Gmail 草稿和 Slack 提醒实现邮件管理自动化
Set
Code
Gmail
+
Set
Code
Gmail
16 节点Fabian ZNTL
工单管理
🎧 IT语音支持自动化机器人 – Telegram语音消息转JIRA工单(使用OpenAI Whisper)
通过Whisper和GPT-4.1 Mini将Telegram语音消息自动转换为JIRA工单
If
Set
Code
+
If
Set
Code
25 节点Trung Tran
工单管理
工作流信息
难度等级
中级
节点数量9
分类2
节点类型7
作者
AlexAutomates
@automatoralexI’m Alex De Gracia, founder of METAMATION. I help small and midsize businesses save time and grow by building smart, automated digital ecosystems. With a hands-on, practical approach, I design custom web solutions and integrations that turn manual work into seamless workflows. My goal is to make modern technology easy and valuable for every business I partner with.
外部链接
在 n8n.io 查看 →
分享此工作流