使用 OpenAI 自动检测需处理邮件并通过 Flow 在 Teams 发送提醒
中级
这是一个Personal Productivity, Multimodal AI领域的自动化工作流,包含 11 个节点。主要使用 If, Set, Code, HttpRequest, EmailReadImap 等节点。 使用 OpenAI 自动检测需处理邮件并通过 Flow 在 Teams 发送提醒消息
前置要求
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "370dd47843c5d81fb49ae779f8a08c791d722f165741db5d7b2cea44ada08d1e",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "bb003676-b07c-4658-a5e4-4efcda44a567",
"name": "OpenAI",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
140,
-100
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "GPT-4.1-MINI"
},
"options": {},
"messages": {
"values": [
{
"role": "system",
"content": "=You are my Personal Email Evaluator. When I provide you with an email's subject, body, and associated details, your task is to determine if the email is Actionable or Non-Actionable based on its content.\n\n\n\n### Criteria for Actionable Emails:\nAn email is deemed Actionable if it meets any of the following criteria and clearly suggests that immediate attention or response is required:\n\n\n\n1. **Inquiry**: Contains a meaningful question or request for significant information.\n2. **Proposal**: Includes a serious business offer or collaboration opportunity that needs review or reply.\n3. **Action Required**: Specifies urgent requests needing action, such as deadlines, bookings, or confirmations.\n4. **Follow-up Reminder**: Serves as a reminder related to a previous important discussion or commitment.\n5. **Task**: Clearly outlines a priority task or step that needs to be taken.\n6. **Urgent**: Signals critical issues or time-sensitive decisions requiring immediate attention.\n7. **Event Invite**: Represents a formal invitation that requires an RSVP for an important event.\n8. **Subscription Renewal**: Notifies about the need to renew vital services or licenses.\n9. **System Notification**: Alerts about technical issues or important status changes.\n10. **Bank Notifications**: Issues regarding financial alerts or suspicious activities needing verification.\n\n\n\n**Exclusions**: Do not classify generic, routine, or low-priority requests as actionable.\n\n\n\n**Response Format**: Return your assessment in a JSON format that includes the following:\n\n\n\n- **date**: The date the email was received.\n- **subject**: The subject line of the email.\n- **sender**: The sender's information.\n\n- **recipientEmail**: The receiver's information.\n- **actionable**: A determined status of either 'Actionable' or 'Non-Actionable'.\n\n\n\n**Example Output**:\n```json\n{\n \"date\": \"date_value\",\n \"subject\": \"subject_value\",\n \"from\": \"from_value\",\n\n \"to\":\"to_value\"\n \"actionable\": \"Actionable/Non-Actionable\"\n}\n```\n\n\n\n### Input:\nHere is the email details:\nFrom: {{ $json.from }} \n\nto: {{ $json.to }}\nOn date: {{ $json.date }} \nSubject line: {{ $json.subject }} \nEmail Body: {{ $json.textPlain }} \n\n\n\nEvaluate the provided email details and return the appropriate JSON object with your findings."
},
{
"content": "=Here are the email details:\nFrom: {{ $json.from }}\nto: {{ $json.to }}\non date :{{ $json.date }}\nSubject line: {{ $json.subject }}\nEmail Body: {{ $json.textPlain }}\n\n"
}
]
},
"simplify": false,
"jsonOutput": true
},
"credentials": {
"openAiApi": {
"id": "5Z0CvWzOY5DhkHX3",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "cebd6f73-b100-40f2-9f4c-ed30c1bd4708",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-160,
-300
],
"parameters": {
"width": 260,
"height": 400,
"content": "## 收到电子邮件时触发"
},
"typeVersion": 1
},
{
"id": "7a3ad55d-ae03-43f6-b49c-fdec7fa10a5e",
"name": "Email Trigger (IMAP)",
"type": "n8n-nodes-base.emailReadImap",
"notes": "Listen for new mail ",
"position": [
-80,
-100
],
"parameters": {
"options": {},
"postProcessAction": "nothing"
},
"credentials": {
"imap": {
"id": "mlGxULMgNsjBaHwB",
"name": "IMAP Gmail account"
}
},
"notesInFlow": true,
"typeVersion": 2
},
{
"id": "93987fdc-2914-4a37-b6a3-aedf86b09d8d",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
120,
-300
],
"parameters": {
"width": 500,
"height": 400,
"content": "## 分析电子邮件内容并提取字段"
},
"typeVersion": 1
},
{
"id": "49ac28cf-0c2f-4638-a40e-e3a6de0febb4",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
640,
-300
],
"parameters": {
"height": 400,
"content": "## 检查电子邮件是否可操作?"
},
"typeVersion": 1
},
{
"id": "be84addc-9633-40b4-8c7e-a52a0413095a",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
900,
-300
],
"parameters": {
"width": 460,
"height": 400,
"content": "## 发送警报至MS Teams"
},
"typeVersion": 1
},
{
"id": "5de0a008-cbe1-4a9e-a3c3-a6ca429f7f6d",
"name": "提取邮件详情",
"type": "n8n-nodes-base.set",
"position": [
460,
-100
],
"parameters": {
"include": "selected",
"options": {},
"includeFields": "choices[0].message.content.date, choices[0].message.content.subject, choices[0].message.content.from, choices[0].message.content.actionable, choices[0].message.content.to",
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "13a7a0cc-3b3f-4806-b22a-5708d9452609",
"name": "构建Gmail搜索URL",
"type": "n8n-nodes-base.code",
"position": [
960,
-100
],
"parameters": {
"jsCode": "for (const item of $input.all()) {\n const subject = item.json.subject;\n const encodedSubject = encodeURIComponent(subject).replace(/%20/g, '+');\n const searchLink = `https://mail.google.com/mail/u/0/#search/${encodedSubject}`;\n \n item.json.searchLink = searchLink;\n}\n\nreturn $input.all();"
},
"typeVersion": 2
},
{
"id": "935332f0-544d-4dd0-a01e-29a0500a0327",
"name": "邮件是否可操作",
"type": "n8n-nodes-base.if",
"position": [
700,
-100
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "b51ec706-74a8-4f4c-8ae9-dc9e19523e7b",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.actionable }}",
"rightValue": "Actionable"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "d6d170ed-5ca4-480d-9e42-d0723d831e6e",
"name": "发送警报至MS团队",
"type": "n8n-nodes-base.httpRequest",
"position": [
1200,
-100
],
"parameters": {
"method": "POST",
"options": {},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "date",
"value": "={{ $json.date }}"
},
{
"name": "=subject",
"value": "={{ $json.subject }}"
},
{
"name": "sender",
"value": "={{ $json.from.replace('<', '(').replace('>', ')') }}"
},
{
"name": "=recipientEmail",
"value": "={{ $json.to }}"
},
{
"name": "=searchLink",
"value": "={{ $json.searchLink }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "ed5cfd2a-5eda-47bf-9eb3-c9852d64e1df",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-160,
180
],
"parameters": {
"color": 5,
"width": 840,
"height": 480,
"content": "## Power Automate流程,用于在Teams中发送消息"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"OpenAI": {
"main": [
[
{
"node": "Extract mail details",
"type": "main",
"index": 0
}
]
]
},
"Is mail actionable": {
"main": [
[
{
"node": "Build gmail search URL",
"type": "main",
"index": 0
}
]
]
},
"Email Trigger (IMAP)": {
"main": [
[
{
"node": "OpenAI",
"type": "main",
"index": 0
}
]
]
},
"Extract mail details": {
"main": [
[
{
"node": "Is mail actionable",
"type": "main",
"index": 0
}
]
]
},
"Build gmail search URL": {
"main": [
[
{
"node": "Send alert to MS team",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 个人效率, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
导出 n8n
使用LINE和OpenAI Vision从图片记录食物卡路里到Google Sheets
If
Set
Code
+9
17 节点kote2
个人效率
语音翻译桥接 (Telegram → Slack),集成GPT-4o-mini和Whisper
语音翻译桥接 (Telegram → Slack),集成GPT-4o-mini和Whisper
If
Set
Code
+5
24 节点Tomohiro Goto
个人效率
每日WhatsApp摘要与群组级别控制
WhatsApp群组摘要工作流
If
Set
Code
+13
39 节点Luís Philipe Trindade
个人效率
来自多个招聘网站的求职自动化
使用 5 个招聘平台和 AI 简历生成器自动化求职与申请
If
Set
Code
+14
34 节点Gerald Denor
个人效率
使用AI求职信自动搜索职位
使用 Google Jobs、RemoteOK 和 GPT-3.5 自动化带AI求职信的职位搜索
If
Set
Code
+7
17 节点Shelly-Ann Davy
个人效率
{模板} ATS优化简历和求职信生成器
使用Gemini AI和PDF.co优化简历并生成求职信
If
Set
Code
+10
23 节点Paul Abraham
个人效率