Outlook
工作流概述
这是一个包含9个节点的复杂工作流,主要用于自动化处理各种任务。
工作流源代码
{
"id": "mqindLlOy0A0e5aA",
"meta": {
"instanceId": "aae6cde6c06a77e3bf2445b060051b4c63107a8258d59cb57184495848d659de",
"templateCredsSetupCompleted": true
},
"name": "Outlook",
"tags": [],
"nodes": [
{
"id": "b2e6066f-a4c7-486c-aa0d-06a4c92aa745",
"name": "Connect Outlook & Set Filter",
"type": "n8n-nodes-base.microsoftOutlookTrigger",
"position": [
-240,
-260
],
"parameters": {
"output": "raw",
"filters": {
"sender": "sales@yourcompany.com"
},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"microsoftOutlookOAuth2Api": {
"id": "nRYwUzhHrSBFtcSS",
"name": "Microsoft Outlook account 2"
}
},
"typeVersion": 1
},
{
"id": "98f20649-4842-44b8-86c3-a153cd7f4ce2",
"name": "Add OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
140,
100
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "sXujPvtyB7ZEzKZs",
"name": "OpenAi account 2"
}
},
"typeVersion": 1.2
},
{
"id": "bf4cb647-91c6-4f3d-a685-ed928b431ef5",
"name": "Add AI Agent Instructions",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
140,
-120
],
"parameters": {
"text": "=Write a reply to the following email, then save it as a draft to the email thread:
<email>
ID: {{ $json.id }}
From: {{ $json.from.emailAddress.address }}
Subject: {{ $json.subject }}
Message: {{ $json.body.content }}
</email>",
"options": {
"systemMessage": "#role
You are an AI assistant specializing in replying to incoming emails to [YOUR NAME] Outlook inbox.
#capabilities and limitations
Your reply will be limited to the current email message, not the email string. Do not hallucinate.
#response
Reply in a casual, modern, professional, concise writing style. You should sound like [YOUR NAME HERE]. Here are examples of [YOUR NAME HERE] voice:
<example>
[COPY & PASTE REPLY SAMPLES FROM YOUR EMAIL]
</example>
<example>
[COPY & PASTE REPLY SAMPLES FROM YOUR EMAIL]
</example>
<example>
[ADD A VARIETY OF REPLY SAMPLES SO THE AGENT UNDERSTANDS YOUR TONE & STYLE]
</example>"
},
"promptType": "define"
},
"typeVersion": 1.7
},
{
"id": "8432a5b8-db95-4e1a-b573-6d4f6a026659",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-60,
-320
],
"parameters": {
"color": 5,
"content": "Trigger Action
1) Connect a Microsoft email account you can authenticate
2) Trigger is set to \"message received\" and the output \"raw\"
3) Add the email address(es) you want the AI agent to handle"
},
"typeVersion": 1
},
{
"id": "72b652a4-cebe-48d6-81ad-d078f0655041",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-300,
-80
],
"parameters": {
"color": 5,
"width": 340,
"height": 440,
"content": "Agent Instructions
#role
You are an AI assistant specializing in replying to incoming emails to [YOUR NAME] Outlook inbox.
#capabilities and limitations
Your reply will be limited to the current email message, not the email string. Do not hallucinate.
#response
Reply in a casual, modern, professional, concise writing style. You should sound like [YOUR NAME HERE]. Here are examples of [YOUR NAME HERE] voice:
<example>
[COPY & PASTE REPLY SAMPLES FROM YOUR EMAIL]
</example>
<example>
[COPY & PASTE REPLY SAMPLES FROM YOUR EMAIL]
</example>
<example>
[ADD A VARIETY OF REPLY SAMPLES SO THE AGENT UNDERSTANDS YOUR TONE & STYLE]
</example>"
},
"typeVersion": 1
},
{
"id": "e2e761a3-9744-439c-9764-ab4c68621c69",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
60,
260
],
"parameters": {
"color": 5,
"height": 100,
"content": "Add AI Model
1) OpenAI Account Credentials Required
2) Select model (ie. gpt-4o-mini)"
},
"typeVersion": 1
},
{
"id": "555f37e2-a8fe-4cd4-9a55-758c07b6a4c4",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
320,
180
],
"parameters": {
"color": 5,
"height": 180,
"content": "Reply Settings
1) Manually set the resource, operation, and message
2) Toggle switch to reply only to sender
3) Let the AI model define the \"message\"
4) Additional fields for the \"reply to\" and \"subject\""
},
"typeVersion": 1
},
{
"id": "9b1a5b51-e502-42f4-80ad-03d050a3c7cb",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
580,
120
],
"parameters": {
"height": 140,
"content": "Draft a Reply
1. Follows all the same \"Reply to Email\" settings EXCEPT the email reply is saved in your DRAFTS folder
2. This setting is great if you want a human checkpoint before sending"
},
"typeVersion": 1
},
{
"id": "46f4b974-4da7-471b-ba49-3737685d123e",
"name": "Reply to Email",
"type": "n8n-nodes-base.microsoftOutlookTool",
"position": [
400,
40
],
"webhookId": "6d01cb74-0463-4042-8917-acd2f552d4b5",
"parameters": {
"message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
"options": {},
"messageId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"operation": "reply",
"descriptionType": "manual",
"additionalFields": {
"replyTo": "={{ $json.sender.emailAddress.address }}",
"subject": "={{ $json.subject }}"
},
"replyToSenderOnly": true
},
"credentials": {
"microsoftOutlookOAuth2Api": {
"id": "nRYwUzhHrSBFtcSS",
"name": "Microsoft Outlook"
}
},
"typeVersion": 2
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "fcd52e16-512c-4655-ae18-1a4b87190e0d",
"connections": {
"Reply to Email": {
"ai_tool": [
[
{
"node": "Add AI Agent Instructions",
"type": "ai_tool",
"index": 0
}
]
]
},
"Add OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Add AI Agent Instructions",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Draft a Reply [optional]": {
"ai_tool": [
[
{
"node": "Add AI Agent Instructions",
"type": "ai_tool",
"index": 0
}
]
]
},
"Connect Outlook & Set Filter": {
"main": [
[
{
"node": "Add AI Agent Instructions",
"type": "main",
"index": 0
}
]
]
}
}
}
功能特点
- 自动检测新邮件
- AI智能内容分析
- 自定义分类规则
- 批量处理能力
- 详细的处理日志
技术分析
节点类型及作用
- Microsoftoutlooktrigger
- @N8N/N8N Nodes Langchain.Lmchatopenai
- @N8N/N8N Nodes Langchain.Agent
- Stickynote
- Microsoftoutlooktool
复杂度评估
配置难度:
维护难度:
扩展性:
实施指南
前置条件
- 有效的Gmail账户
- n8n平台访问权限
- Google API凭证
- AI分类服务订阅
配置步骤
- 在n8n中导入工作流JSON文件
- 配置Gmail节点的认证信息
- 设置AI分类器的API密钥
- 自定义分类规则和标签映射
- 测试工作流执行
- 配置定时触发器(可选)
关键参数
| 参数名称 | 默认值 | 说明 |
|---|---|---|
| maxEmails | 50 | 单次处理的最大邮件数量 |
| confidenceThreshold | 0.8 | 分类置信度阈值 |
| autoLabel | true | 是否自动添加标签 |
最佳实践
优化建议
- 定期更新AI分类模型以提高准确性
- 根据邮件量调整处理批次大小
- 设置合理的分类置信度阈值
- 定期清理过期的分类规则
安全注意事项
- 妥善保管API密钥和认证信息
- 限制工作流的访问权限
- 定期审查处理日志
- 启用双因素认证保护Gmail账户
性能优化
- 使用增量处理减少重复工作
- 缓存频繁访问的数据
- 并行处理多个邮件分类任务
- 监控系统资源使用情况
故障排除
常见问题
邮件未被正确分类
检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。
Gmail认证失败
确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。
调试技巧
- 启用详细日志记录查看每个步骤的执行情况
- 使用测试邮件验证分类逻辑
- 检查网络连接和API服务状态
- 逐步执行工作流定位问题节点
错误处理
工作流包含以下错误处理机制:
- 网络超时自动重试(最多3次)
- API错误记录和告警
- 处理失败邮件的隔离机制
- 异常情况下的回滚操作