AI邮件助手 - 智能邮件处理与回复
高级
这是一个AI Chatbot, Multimodal AI领域的自动化工作流,包含 36 个节点。主要使用 If, Gmail, Limit, Merge, Switch 等节点。 集成Gmail、GPT-4分类和自动回复的智能邮件管理器
前置要求
- •Google 账号和 Gmail API 凭证
- •Telegram Bot Token
- •Google Drive API 凭证
- •OpenAI API Key
使用的节点 (36)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"name": "AI 邮件助手 - 智能邮件处理与回复",
"tags": [
"ai-assistant",
"email-automation",
"smart-inbox",
"productivity",
"business-automation"
],
"nodes": [
{
"id": "e94f2b5f-32a8-411a-ace4-cb3302ff16d2",
"name": "📋 可选文件过滤",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
0
],
"parameters": {
"color": 3,
"width": 340,
"height": 320,
"content": "## 🎯 文件类型过滤(可选)"
},
"typeVersion": 1
},
{
"id": "321bbe22-fa97-4b15-a511-0dec17ff3b3f",
"name": "📧 邮件处理",
"type": "n8n-nodes-base.stickyNote",
"position": [
-3408,
3312
],
"parameters": {
"color": 7,
"width": 1009,
"height": 306,
"content": "## 📧 邮件处理流程"
},
"typeVersion": 1
},
{
"id": "1300f978-4409-4ab5-92a9-1e2d1a9f8bf2",
"name": "✍️ 回复生成",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1184,
2800
],
"parameters": {
"color": 7,
"width": 583,
"height": 313,
"content": "## ✍️ AI 回复生成"
},
"typeVersion": 1
},
{
"id": "80372ae4-e5f2-4b26-8dba-faba15d93540",
"name": "自动修复输出解析器",
"type": "@n8n/n8n-nodes-langchain.outputParserAutofixing",
"position": [
-1680,
3664
],
"parameters": {
"options": {}
},
"typeVersion": 1
},
{
"id": "eb06df2a-44dc-442e-9aea-e8ed3aafce27",
"name": "🔍 邮件分析",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1840,
3312
],
"parameters": {
"color": 7,
"width": 383,
"height": 313,
"content": "## 🔍 邮件分类"
},
"typeVersion": 1
},
{
"id": "c336e363-4bde-43b3-8e6e-076e70b50757",
"name": "结构化输出解析器",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
-1536,
3904
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"type\": \"object\",\n \"required\": [\"metadata\", \"classification\", \"actions\"],\n \"properties\": {\n \"metadata\": {\n \"type\": \"object\",\n \"required\": [\"sender\", \"subject\", \"receivedDate\"],\n \"properties\": {\n \"sender\": {\n \"type\": \"string\",\n \"format\": \"email\"\n },\n \"subject\": {\n \"type\": \"string\",\n \"minLength\": 1\n },\n \"receivedDate\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n }\n }\n },\n \"classification\": {\n \"type\": \"object\",\n \"required\": [\n \"summary\",\n \"toReply\",\n \"urgent\",\n \"dateRelated\",\n \"attachmentsToUpload\",\n \"requiresFollowUp\",\n \"forwardToTeam\",\n \"priority\",\n \"label_ids\",\n \"label_categories\"\n ],\n \"properties\": {\n \"summaryOfEmail\": {\n \"type\": \"string\"\n },\n \"toReply\": {\n \"type\": \"boolean\"\n },\n \"urgent\": {\n \"type\": \"boolean\"\n },\n \"dateRelated\": {\n \"type\": \"boolean\"\n },\n \"attachmentsToUpload\": {\n \"type\": \"boolean\"\n },\n \"requiresFollowUp\": {\n \"type\": \"boolean\"\n },\n \"forwardToTeam\": {\n \"type\": \"boolean\"\n },\n \"priority\": {\n \"type\": \"string\",\n \"enum\": [\"High\", \"Medium\", \"Low\"]\n },\n \"label_ids\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"minItems\": 1\n },\n \"label_categories\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"minItems\": 1\n }\n }\n },\n \"actions\": {\n \"type\": \"object\",\n \"required\": [\n \"notes\",\n \"dueDate\",\n \"uploadAttachments\",\n \"createTask\",\n \"additionalTasks\"\n ],\n \"properties\": {\n \"notes\": {\n \"type\": \"string\"\n },\n \"dueDate\": {\n \"type\": \"string\",\n \"format\": \"date\"\n },\n \"uploadAttachments\": {\n \"type\": \"boolean\"\n },\n \"createTask\": {\n \"type\": \"boolean\"\n },\n \"additionalTasks\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n }\n },\n \"additionalProperties\": false\n}"
},
"typeVersion": 1.2
},
{
"id": "6f3996c0-bf26-4850-b324-b20253793f48",
"name": "🏷️ 智能标签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1184,
3712
],
"parameters": {
"color": 7,
"width": 463,
"height": 373,
"content": "## 🏷️ 智能标签系统"
},
"typeVersion": 1
},
{
"id": "03c6a77e-abb9-4dc0-a05b-2bd664afd8a6",
"name": "📎 附件处理器",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1184,
3120
],
"parameters": {
"color": 7,
"width": 423,
"height": 273,
"content": "## 📎 附件处理"
},
"typeVersion": 1
},
{
"id": "a98fb400-c660-4bd3-ac33-9483d26d2c10",
"name": "🚨 警报系统",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1184,
3424
],
"parameters": {
"color": 7,
"width": 243,
"height": 253,
"content": "## 🚨 紧急通知"
},
"typeVersion": 1
},
{
"id": "2cba2d61-7944-434c-96ef-2dc74ca5589c",
"name": "检查附件",
"type": "n8n-nodes-base.if",
"position": [
-1168,
3248
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "22f8d83a-b7d1-4b4a-8967-4335c0d1f510",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $('Email_Trigger').item.binary }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "24af5d4a-0543-478f-b484-0706e9e3d893",
"name": "Email_Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-3344,
3424
],
"parameters": {
"simple": false,
"filters": {
"q": "-from:me"
},
"options": {
"downloadAttachments": true
},
"pollTimes": {
"item": [
{
"mode": "everyHour"
}
]
}
},
"typeVersion": 1
},
{
"id": "d84fed31-2e78-43a3-beb1-94e1ad9cf433",
"name": "获取对话线程",
"type": "n8n-nodes-base.gmail",
"position": [
-2880,
3424
],
"webhookId": "669ea381-16ba-4a90-a451-173051a09c18",
"parameters": {
"options": {
"returnOnlyMessages": true
},
"resource": "thread",
"threadId": "={{ $('Email_Trigger').item.json.threadId }}",
"operation": "get"
},
"retryOnFail": true,
"typeVersion": 2.1
},
{
"id": "24ba4c20-2191-4333-86fe-ad07cc870125",
"name": "获取最新消息 ID",
"type": "n8n-nodes-base.limit",
"position": [
-2704,
3424
],
"parameters": {
"keep": "lastItems"
},
"typeVersion": 1
},
{
"id": "d0231c2f-3560-490d-8dfc-e29b251799a3",
"name": "获取最新消息内容",
"type": "n8n-nodes-base.gmail",
"position": [
-2528,
3424
],
"webhookId": "0c1a04d0-b517-42b0-ba9b-c120eae6645e",
"parameters": {
"simple": false,
"options": {},
"messageId": "={{ $('Get Latest Message ID').item.json.id }}",
"operation": "get"
},
"executeOnce": false,
"retryOnFail": true,
"typeVersion": 2.1
},
{
"id": "60f5e786-607b-4007-ac5c-80c7d05d2be4",
"name": "AI 邮件分类器",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
-1760,
3424
],
"parameters": {
"text": "=<message>\n{{ $('Get Latest Message Content').item.json.textAsHtml }} \n</message>\n\n<subject>\n{{ $('Get Latest Message Content').item.json.subject }}\n</subject>\n\n<metadata>\n{{ $('Get Latest Message Content').item.json.headers.from }}\n{{ $('Get Latest Message Content').item.json.headers.date }}\n</metadata>\n\n<attachments>\n{{ $('Email_Trigger').item.binary ? true : false }}\n</attachments>\n\n<categories>\n{{ JSON.stringify($('Get User Labels').all(), null, 2) }}\n</categories>\n\n<current_category_labels>\n{{ $('Email_Trigger').item.json.labelIds }}\n</current_category_labels>\n\n<message_thread>\n{{ $('Email_Trigger').item.json.textAsHtml }}\n</message_thread>",
"messages": {
"messageValues": [
{
"message": "=# Email Assessment Agent\n<role>\nYou are an intelligent email analysis system that evaluates incoming emails to determine their characteristics, priority, and required actions.\n</role>\n\n<scope>\nProcess and analyze email content and metadata to classify messages, determine response requirements, assess urgency, and identify attachment needs.\n</scope>\n\n<command>\nFor each email received, perform the following analysis steps:\n\nStep 1: Analyze the email content and metadata to extract key information\nStep 2: Classify the email using provided labels and categories\nStep 3: Determine response requirements and urgency\nStep 4: Check for attachment handling needs\nStep 5: Generate a comprehensive assessment in the specified JSON output format\n</command>\n\n<inputs>\n- message: The full email body text of the most recent message in the thread\n- subject: Email subject line\n- metadata: Sender information, received date, and any system flags\n- attachments: Boolean indicating presence of attachments\n- categories: List of label categories\n- categories_ids: List of associated label category IDs\n- message_thread: The full context from previous messages in the conversation\n</inputs>\n\n<constraints>\n- Must only use provided categories for classification\n- Classifications must be evidence-based from email content\n- Urgency assessment must align with defined criteria\n- Do not infer information not present in the email\n- Each email can have multiple labels\n- Response requirements must follow specified guidelines\n</constraints> \n\n<format>\nReturn a single JSON object with the following structure:\n```json\n{\n \"metadata\": {\n \"sender\": string,\n \"subject\": string,\n \"receivedDate\": string (ISO 8601)\n },\n \"classification\": {\n \"toReply\": boolean,\n \"urgent\": boolean,\n \"dateRelated\": boolean,\n \"attachmentsToUpload\": boolean,\n \"requiresFollowUp\": boolean,\n \"forwardToTeam\": boolean,\n \"priority\": \"High\" | \"Medium\" | \"Low\",\n \"label_ids\": string[],\n \"label_categories\": string[]\n },\n \"actions\": {\n \"notes\": string,\n \"dueDate\": string,\n \"uploadAttachments\": boolean,\n \"createTask\": boolean,\n \"additionalTasks\": string[]\n }\n}\n```\n\n<categorization_rules>\nAll categorization elements should be considered independent but related:\n\n**Response Required (toReply):**\n- Direct questions or requests\n- Time-sensitive matters requiring confirmation\n- Approval requests\n- RSVP requirements\n\n**Urgent Classification:**\n- Immediate business impact\n- System/security incidents\n- Time-critical deadlines\n- Crisis situations\n- Keywords: URGENT, EMERGENCY, CRITICAL, ASAP\n\n**Priority Levels:**\n- High: Urgent matters requiring immediate attention\n- Medium: Important but not time-critical\n- Low: Routine or informational messages\n\n**Follow-up Requirements:**\n- Multi-step processes\n- Future deadlines\n- Progress monitoring needs\n- Ongoing projects\n\n**Team Forwarding:**\n- Cross-departmental impact\n- Shared responsibilities\n- Knowledge sharing requirements\n- Collaborative projects\n</categorization_rules>"
}
]
},
"promptType": "define",
"hasOutputParser": true
},
"executeOnce": true,
"retryOnFail": true,
"typeVersion": 1.5
},
{
"id": "99c5bb8c-e0d0-4963-9b9c-6bbdc0be243b",
"name": "智能操作路由器",
"type": "n8n-nodes-base.switch",
"position": [
-1424,
3408
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "RESPONSE",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "6d9939fa-0ddd-4b1b-b607-e4a521384c71",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.output.classification.toReply }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "ATTACHMENTS",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "cb7c3b89-b19b-4e32-987b-7f462bc221cd",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.output.classification.attachmentsToUpload }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "ALERT",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "ca803c7f-8884-4e40-b818-03c46d545ada",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.output.classification.urgent }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "LABEL",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "bd20b778-b44f-4927-a337-f6cfae3ef590",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "=",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {
"allMatchingOutputs": true
}
},
"retryOnFail": true,
"typeVersion": 3.2
},
{
"id": "48decbca-dbf9-4494-9190-f48248c0c461",
"name": "聚合标签 ID",
"type": "n8n-nodes-base.aggregate",
"position": [
-1120,
3872
],
"parameters": {
"options": {},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"renameField": true,
"outputFieldName": "label_ids",
"fieldToAggregate": "output.classification.label_ids"
}
]
}
},
"typeVersion": 1
},
{
"id": "fbbba2ef-bea1-4814-abcd-f0f41288aeaa",
"name": "AI 回复生成器",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
-1136,
2912
],
"parameters": {
"text": "=Subject: {{ $('Email_Trigger').item.json.subject }}\nMessage: {{ $('Email_Trigger').item.json.textAsHtml }}",
"messages": {
"messageValues": [
{
"message": "=# Professional Email Response Generator\n\n<guidelines>\n**Tone & Style:**\n- Use business casual tone, warm but professional\n- Be concise and direct\n- Mirror the formality level of the incoming email\n- Match the language and urgency of the incoming email\n\n**Structure:**\n- Start with \"Hi [Name]\"\n- For multi-point emails, use short paragraphs (2-3 sentences each)\n- End with \"Best Regards,\\n[YOUR NAME]\"\n\n**Response Types:**\nFor yes/no questions, provide two alternatives:\n[AFFIRMATIVE RESPONSE]\nOR - - - - - - -\n[NEGATIVE RESPONSE]\n\n**Content Guidelines:**\n- Never invent information\n- Use \"[PLACEHOLDER]\" for missing information \n- For SALES inquiries: Include next steps (call booking, demo scheduling)\n- For COMPLAINTS: Express understanding, provide clear resolution steps\n- Plain text only, no formatting\n- Keep sentences concise but informative\n\n**Key Response Principles:**\n- Address the specific issue/request\n- Provide clear next steps\n- Request any missing information\n- Set clear expectations\n- Maintain professional and warm tone\n- Include follow-up plan when needed\n\n**Customization Notes:**\n- Replace [YOUR NAME] with your actual name\n- Adjust tone to match your business style\n- Add company-specific information as needed\n</guidelines>"
}
]
},
"promptType": "define"
},
"typeVersion": 1.4
},
{
"id": "5bd3feb3-ccdb-4cc4-a3c8-ff161926bc78",
"name": "上传到Google Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
-240,
3424
],
"parameters": {
"name": "={{ \n$('AI Email Classifier').item.json.output.metadata.receivedDate.toDateTime().format('yyyy.MM.dd')\n+ \" - \"\n+ $('Email_Trigger').item.json.from.value[0].address \n+ ' - ' \n+ $('Get All Attachments').item.json.fileName.split(\".\")[0] \n+ \".\" + $('Get All Attachments').item.json.fileName.split(\".\")[1]}}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "id",
"value": "YOUR_GOOGLE_DRIVE_FOLDER_ID"
}
},
"notesInFlow": true,
"retryOnFail": true,
"typeVersion": 3
},
{
"id": "3ce26cee-92d4-47fd-bb29-d7a7e25db396",
"name": "创建草稿回复",
"type": "n8n-nodes-base.gmail",
"position": [
-800,
2912
],
"webhookId": "ef19ee4d-876e-4cfb-a284-227e013d57dc",
"parameters": {
"message": "={{ $('AI Response Generator').item.json.text.replace(/\\n/g, \"<br />\\n\") }}",
"options": {
"sendTo": "={{ $('Email_Trigger').item.json.headers.from }}",
"threadId": "={{ $('Email_Trigger').item.json.threadId }}"
},
"subject": "={{ $('Email_Trigger').item.json.headers.subject }}",
"resource": "draft",
"emailType": "html"
},
"retryOnFail": true,
"typeVersion": 2.1
},
{
"id": "d28fff76-9f61-4e8a-895c-719836c4d3e4",
"name": "分配分类标签",
"type": "n8n-nodes-base.gmail",
"position": [
-944,
3792
],
"webhookId": "ef966666-b459-4cba-8858-3952dfd9e16d",
"parameters": {
"labelIds": "={{ $('Aggregate Label IDs').item.json.label_ids[0] }}",
"messageId": "={{ $('Email_Trigger').item.json.id }}",
"operation": "addLabels"
},
"notesInFlow": true,
"retryOnFail": true,
"typeVersion": 2.1
},
{
"id": "18d309f1-9b49-4d40-9fe3-fa553429520c",
"name": "标记为已处理",
"type": "n8n-nodes-base.gmail",
"onError": "continueErrorOutput",
"position": [
-944,
3952
],
"webhookId": "ef966666-b459-4cba-8858-3952dfd9e16d",
"parameters": {
"labelIds": [
"YOUR_PROCESSED_LABEL_ID"
],
"messageId": "={{ $('Email_Trigger').item.json.id }}",
"operation": "addLabels"
},
"notesInFlow": true,
"retryOnFail": true,
"typeVersion": 2.1
},
{
"id": "53c5c777-b382-4833-b306-8553c6750e83",
"name": "发送紧急警报",
"type": "n8n-nodes-base.telegram",
"position": [
-1136,
3504
],
"webhookId": "5b7d79c3-64e2-4bf2-8622-9cd7ac221425",
"parameters": {
"text": "=🚨 URGENT EMAIL ALERT\n\n👤 From: {{ $('Email_Trigger').item.json.from.value[0].name }}\n📧 Subject: {{ $('Email_Trigger').item.json.subject }}\n📋 Summary: {{ $('AI Email Classifier').item.json.output.classification.summaryOfEmail }}\n🔗 Link: https://mail.google.com/mail/u/0/#inbox/{{ $('Email_Trigger').item.json.id }}",
"chatId": "YOUR_TELEGRAM_CHAT_ID",
"additionalFields": {
"appendAttribution": false
}
},
"typeVersion": 1.2
},
{
"id": "62efbada-38a3-4af7-9da2-7845bc77f7d2",
"name": "检查现有附件",
"type": "n8n-nodes-base.googleDrive",
"onError": "continueErrorOutput",
"position": [
-720,
3248
],
"parameters": {
"filter": {
"folderId": {
"__rl": true,
"mode": "id",
"value": "YOUR_GOOGLE_DRIVE_FOLDER_ID"
}
},
"options": {},
"resource": "fileFolder",
"returnAll": true,
"queryString": "={{ \n$('AI Email Classifier').item.json.output.metadata.receivedDate.toDateTime().format('yyyy.MM.dd')\n+ \" - \"\n+ $('Email_Trigger').item.json.from.value[0].address \n+ ' - ' \n+ $('Get All Attachments').item.json.fileName.split(\".\")[0] \n+ \".\" + $('Get All Attachments').item.json.fileName.split(\".\")[1]}}"
},
"notesInFlow": true,
"retryOnFail": true,
"typeVersion": 3,
"alwaysOutputData": true
},
{
"id": "5cb3e686-2d64-499c-ab44-b944b003ed28",
"name": "检查文件是否存在",
"type": "n8n-nodes-base.if",
"position": [
-560,
3248
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "44944380-9ba0-4cf7-abbb-aba711fb0b9a",
"operator": {
"type": "object",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $('Check Existing Attachments').item.json }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "caa13ad4-5365-4317-b41a-5616ee1d0229",
"name": "合并附件数据",
"type": "n8n-nodes-base.merge",
"position": [
-400,
3424
],
"parameters": {
"mode": "chooseBranch",
"useDataOfInput": 2
},
"typeVersion": 3
},
{
"id": "1e5c5994-beb9-49e4-bdec-294b402bfb6b",
"name": "☁️ 文件管理",
"type": "n8n-nodes-base.stickyNote",
"position": [
-736,
3152
],
"parameters": {
"color": 7,
"width": 663,
"height": 453,
"content": "## ☁️ 智能文件管理"
},
"typeVersion": 1
},
{
"id": "66d06be7-f7bd-454d-a58a-1259fd3b9adc",
"name": "🤖 主要功能",
"type": "n8n-nodes-base.stickyNote",
"position": [
-3408,
3104
],
"parameters": {
"color": 6,
"width": 360,
"height": 180,
"content": "## 🤖 AI 邮件助手功能"
},
"typeVersion": 1
},
{
"id": "df00bd54-36e1-4246-b29c-d4250365f423",
"name": "逐个处理",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-3120,
3424
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "b9fdba24-4f13-4e1c-be82-794952ac47ff",
"name": "获取所有 Gmail 标签",
"type": "n8n-nodes-base.gmail",
"position": [
-2368,
3424
],
"webhookId": "f3241a25-93a8-4629-945d-2e35869e43e3",
"parameters": {
"resource": "label",
"returnAll": true
},
"typeVersion": 2.1
},
{
"id": "53facca0-81ec-4abe-9659-1faed1b6b901",
"name": "过滤用户标签",
"type": "n8n-nodes-base.if",
"position": [
-2224,
3424
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2ae0a220-4198-41ed-9ee5-78ae7b774ef6",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('Get All Gmail Labels').item.json.type }}",
"rightValue": "user"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "d4dd372d-6f65-4ed9-86a1-a0c6cd68f216",
"name": "获取用户标签",
"type": "n8n-nodes-base.aggregate",
"position": [
-2000,
3424
],
"parameters": {
"options": {
"mergeLists": true
},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "id"
},
{
"fieldToAggregate": "name"
}
]
}
},
"typeVersion": 1
},
{
"id": "ebd400dc-2c39-4758-8112-1cf61dd1f97f",
"name": "AI 语言模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-1904,
3760
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"typeVersion": 1.2
},
{
"id": "53e9d481-ab4e-48f1-a893-f10c040e48f2",
"name": "🔄 标签同步",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2384,
3312
],
"parameters": {
"color": 7,
"width": 509,
"height": 306,
"content": "## 🔄 动态标签管理"
},
"typeVersion": 1
},
{
"id": "e17c366f-c3ad-4ed7-a1ca-c860e629cb9c",
"name": "获取特定文件类型",
"type": "n8n-nodes-base.function",
"position": [
-944,
2560
],
"parameters": {
"functionCode": "let results = [];\nconst emailData = $('Email_Trigger').item;\n\nif (emailData.binary) {\n for (const key of Object.keys(emailData.binary)) {\n const attachment = emailData.binary[key];\n const mimeType = attachment.mimeType;\n \n // Filter for specific file types (PDF, XML, JPG)\n if (mimeType === 'application/pdf' || \n mimeType === 'text/xml' || \n mimeType === 'application/xml' ||\n mimeType === 'image/jpeg') {\n results.push({\n json: {\n fileName: attachment.fileName,\n mimeType: attachment.mimeType\n },\n binary: {\n data: attachment\n }\n });\n }\n }\n}\n\nreturn results;"
},
"typeVersion": 1
},
{
"id": "07615955-7e0c-4c0c-af70-76633de51eb6",
"name": "获取所有附件",
"type": "n8n-nodes-base.function",
"position": [
-896,
3248
],
"parameters": {
"functionCode": "let results = [];\nconst emailData = $('Email_Trigger').item;\n\nif (emailData.binary) {\n for (const key of Object.keys(emailData.binary)) {\n const attachment = emailData.binary[key];\n results.push({\n json: {\n fileName: attachment.fileName,\n mimeType: attachment.mimeType\n },\n binary: {\n data: attachment\n }\n });\n }\n}\n\nreturn results;"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"connections": {
"Email_Trigger": {
"main": [
[
{
"node": "Process One by One",
"type": "main",
"index": 0
}
]
]
},
"Get User Labels": {
"main": [
[
{
"node": "AI Email Classifier",
"type": "main",
"index": 0
}
]
]
},
"AI Language Model": {
"ai_languageModel": [
[
{
"node": "AI Email Classifier",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Auto-fixing Output Parser",
"type": "ai_languageModel",
"index": 0
},
{
"node": "AI Response Generator",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Mark as Processed": {
"main": [
[
{
"node": "Process One by One",
"type": "main",
"index": 0
}
]
]
},
"Filter User Labels": {
"main": [
[
{
"node": "Get User Labels",
"type": "main",
"index": 0
}
]
]
},
"Process One by One": {
"main": [
[],
[
{
"node": "Get Conversation Thread",
"type": "main",
"index": 0
}
]
]
},
"AI Email Classifier": {
"main": [
[
{
"node": "Smart Action Router",
"type": "main",
"index": 0
}
]
]
},
"Aggregate Label IDs": {
"main": [
[
{
"node": "Mark as Processed",
"type": "main",
"index": 0
},
{
"node": "Assign Classification Label",
"type": "main",
"index": 0
}
]
]
},
"Get All Attachments": {
"main": [
[
{
"node": "Check Existing Attachments",
"type": "main",
"index": 0
},
{
"node": "Merge Attachment Data",
"type": "main",
"index": 1
}
]
]
},
"Smart Action Router": {
"main": [
[
{
"node": "AI Response Generator",
"type": "main",
"index": 0
}
],
[
{
"node": "Check for Attachments",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Urgent Alert",
"type": "main",
"index": 0
}
],
[
{
"node": "Aggregate Label IDs",
"type": "main",
"index": 0
}
]
]
},
"Check if File Exists": {
"main": [
[],
[
{
"node": "Merge Attachment Data",
"type": "main",
"index": 0
}
]
]
},
"Get All Gmail Labels": {
"main": [
[
{
"node": "Filter User Labels",
"type": "main",
"index": 0
}
]
]
},
"AI Response Generator": {
"main": [
[
{
"node": "Create Draft Response",
"type": "main",
"index": 0
}
]
]
},
"Check for Attachments": {
"main": [
[
{
"node": "Get All Attachments",
"type": "main",
"index": 0
}
]
]
},
"Get Latest Message ID": {
"main": [
[
{
"node": "Get Latest Message Content",
"type": "main",
"index": 0
}
]
]
},
"Merge Attachment Data": {
"main": [
[
{
"node": "Upload to Google Drive",
"type": "main",
"index": 0
}
]
]
},
"Get Conversation Thread": {
"main": [
[
{
"node": "Get Latest Message ID",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Auto-fixing Output Parser",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Auto-fixing Output Parser": {
"ai_outputParser": [
[
{
"node": "AI Email Classifier",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Check Existing Attachments": {
"main": [
[
{
"node": "Check if File Exists",
"type": "main",
"index": 0
}
]
]
},
"Get Latest Message Content": {
"main": [
[
{
"node": "Get All Gmail Labels",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - AI 聊天机器人, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
WordPress博客自动化专业版(深度研究)v2.1市场
使用GPT-4o、Perplexity AI和多语言支持自动化SEO优化的博客创建
If
Set
Xml
+27
125 节点Daniel Ng
内容创作
完整的 B2B 销售流程:Apollo 潜在客户生成、Mailgun 外展和 AI 回复管理
完整的 B2B 销售流程:Apollo 潜在客户生成、Mailgun 外展和 AI 回复管理
If
Set
Code
+26
116 节点Paul
内容创作
AIAuto - 带深度研究的终极人机回环内容v2
WordPress博客自动化,集成Airtable界面、人工审核和AI研究v2
If
Set
Xml
+23
228 节点Daniel Ng
内容创作
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
使用 OpenAI、QuickChart 和 Google Drive 将电子表格数据转换为智能图表
使用 OpenAI、QuickChart 和 Google Drive 将电子表格数据转换为智能图表
If
Set
Code
+18
82 节点LeeWei
内容创作
AI邮件分诊与GPT-4警报系统及Telegram通知
AI邮件分诊与GPT-4警报系统及Telegram通知
If
Set
Gmail
+22
104 节点Peter Joslyn
客户支持
工作流信息
难度等级
高级
节点数量36
分类2
节点类型16
作者
Ronnie Craig
@ronnie-craig-2025Hi, I’m Ronnie! I scaled an eCommerce biz to $14K/month in under a year, grew a YouTube channel to 1K subs in 30 days, booked 28 daycare appointments in 6 days, and built automations for nurses to track clients. I help you create content, repurpose high-performing posts, schedule with ease, monitor trends, and automate marketing—so you stay visible and consistent without burning out.
外部链接
在 n8n.io 查看 →
分享此工作流