8
n8n 中文网amn8n.com

智能邮件自动回复器

中级

这是一个AI领域的自动化工作流,包含 14 个节点。主要使用 If, Code, Gmail, EmailSend, GmailTrigger 等节点,结合人工智能技术实现智能自动化。 基于AI的智能邮件自动回复工作流

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "1RHsJldA8GlWFp1E",
  "meta": {
    "instanceId": "c3caf872897344ae9095ede706e2c19a32f712f120ab7f143e26125462303491",
    "templateId": "3277",
    "templateCredsSetupCompleted": true
  },
  "name": "智能邮件自动回复器",
  "tags": [],
  "nodes": [
    {
      "id": "e485ab21-6c33-4cb1-9bd1-3fea3a1d431a",
      "name": "Gmail 触发器",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        1480,
        220
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "labelIds": [
            "Label_43975351283257832"
          ]
        },
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyHour"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "cvHi0AAN9bE3lcij",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d52b02ce-95aa-495f-a6b4-d5dd791f2808",
      "name": "文本分类器",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        1820,
        400
      ],
      "parameters": {
        "options": {},
        "inputText": "={{ $('Gmail Trigger').item.json.subject }}\n{{ $('Gmail Trigger').item.json.text }}",
        "categories": {
          "categories": [
            {
              "category": "Questions",
              "description": "Use this category when the email is asking for information about our company, products, processes, pricing, timelines, legal terms or any other general inquiry that expects a factual explanation or guidance."
            },
            {
              "category": "Project Update",
              "description": "Choose this category when the sender is notifying us about progress or changes: signing the agreement, submitting or revising scripts, updating requirements, sharing evaluation results, or any status report that moves an ongoing project forward"
            },
            {
              "category": "Feedback",
              "description": "Select this category when the email contains compliments, complaints, suggestions, or any qualitative feedback about our service, product, communication or overall experience"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "adfca78f-9ce5-4345-baaa-017538e433be",
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1840,
        680
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-exp"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "vNACKKKe3OF1uS3Y",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e7c91741-20d6-4c54-8dd5-efec164c29b3",
      "name": "YouTube 视频咨询",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2260,
        580
      ],
      "webhookId": "120f4cfb-cfd3-4792-b5f5-146e9f495f73",
      "parameters": {
        "html": "=<!DOCTYPE html>\n<html>\n<head>\n  <style>\n    body{font-family:Arial,sans-serif;line-height:1.6;color:#333;margin:0;padding:0;}\n    .container{width:100%;max-width:600px;margin:0 auto;padding:20px;}\n    .header{background:#f4f4f4;padding:10px 20px;text-align:center;border-bottom:1px solid #ddd;}\n    .header h1{margin:0;color:#555;}\n    .content{padding:20px;}\n    .content h2{color:#555;font-size:18px;margin:20px 0 10px;}\n    .content p{margin-bottom:15px;}\n    .content ul{list-style:disc;padding-left:20px;}\n    .content ul li{margin-bottom:10px;}\n    .content a{color:#007BFF;text-decoration:none;}\n    .content a:hover{text-decoration:underline;}\n    .footer{text-align:center;font-size:12px;color:#888;margin-top:20px;}\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"header\">\n      <h1>Project Update Acknowledgement</h1>\n    </div>\n\n    <div class=\"content\">\n      <p>\n        Hi {{ $json.from.value[0].name || $('Gmail Trigger').item.json.headers.from.split('<')[0].trim() || 'there' }},\n      </p>\n\n      <p>\n        Thank you for your recent update on the project. We’ve reviewed the information you provided and have logged it in our system.\n      </p>\n\n      <h2>What we received:</h2>\n      <ul>\n        <li>Signed agreement / contract confirmation.</li>\n        <li>Revised requirements or scope changes.</li>\n        <li>Draft scripts or other deliverables for review.</li>\n        <li>Evaluation results or performance reports.</li>\n      </ul>\n\n      <h2>Next steps:</h2>\n      <ul>\n        <li>Our team will review the materials and integrate any changes within <strong>2–3 business days</strong>.</li>\n        <li>If clarifications are needed, we’ll reach out via email or schedule a quick call.</li>\n        <li>You’ll receive the updated project timeline once the review is complete.</li>\n      </ul>\n\n      <p>\n        If you have additional files or questions, feel free to reply directly to this email.\n      </p>\n\n      <p>\n        We appreciate your prompt communication and look forward to moving the project ahead smoothly.\n      </p>\n\n      <p>\n        Best regards,<br>\n        <strong>Sophia Mitchell</strong><br>\n        Project Coordinator | <a href=\"https://syncbricks.com\" target=\"_blank\">syncbricks.com</a><br>\n        WhatsApp: +1 &nbsp;\n      </p>\n    </div>\n\n    <div class=\"footer\">\n      © 2025 SyncBricks. All rights reserved.\n    </div>\n  </div>\n</body>\n</html>\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "=Re: {{ $('Gmail Trigger').item.json.subject }}",
        "toEmail": "={{ $json.from.value[0].name }} <{{ $json.from.value[0].address }}>",
        "fromEmail": "kulankur.work@gmail.com"
      },
      "credentials": {
        "smtp": {
          "id": "rSVeHz6kjwDIBOZ7",
          "name": "SMTP account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "61243957-40d1-4fb2-ad0a-6f923587c4db",
      "name": "发送邮件",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2260,
        760
      ],
      "webhookId": "700cb9ed-bd54-4e96-8121-98a5dcffeebf",
      "parameters": {
        "html": "=<!DOCTYPE html>\n<html>\n<head>\n  <style>\n    body{font-family:Arial,sans-serif;line-height:1.6;color:#333;margin:0;padding:0;}\n    .container{width:100%;max-width:600px;margin:0 auto;padding:20px;}\n    .header{background:#f4f4f4;padding:10px 20px;text-align:center;border-bottom:1px solid #ddd;}\n    .header h1{margin:0;color:#555;}\n    .content{padding:20px;}\n    .content h2{color:#555;font-size:18px;margin:20px 0 10px;}\n    .content p{margin-bottom:15px;}\n    .content ul{list-style:disc;padding-left:20px;}\n    .content ul li{margin-bottom:10px;}\n    .content a{color:#007BFF;text-decoration:none;}\n    .content a:hover{text-decoration:underline;}\n    .footer{text-align:center;font-size:12px;color:#888;margin-top:20px;}\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"header\">\n      <h1>Thank You for Your Feedback</h1>\n    </div>\n\n    <div class=\"content\">\n      <p>\n        Hi {{ $json.from.value?.[0]?.name || $('Gmail Trigger').item.json.headers.from.split('<')[0].trim() || 'there' }},\n      </p>\n\n      <p>\n        Thank you for taking the time to share your feedback about SyncBricks. We truly value every comment—whether a\n        compliment, suggestion, or concern—because it helps us improve.\n      </p>\n\n      <h2>What happens next:</h2>\n      <ul>\n        <li>Your message has been logged in our system&nbsp;(<strong>Reference ID:</strong>\n          {{ $json.id.slice(-6) }}).</li>\n        <li>Our team will review it within <strong>1 business day</strong>.</li>\n        <li>If an action is required, the appropriate team member will follow up directly with you.</li>\n      </ul>\n\n      <p>\n        If you need to add more details, simply reply to this email—your message wil\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "=Re:  {{ $('Gmail Trigger').item.json.Subject }}",
        "toEmail": "={{ $json.from.value[0].name }} <{{ $json.from.value[0].address }}>",
        "fromEmail": "kulankur.work@gmail.com"
      },
      "credentials": {
        "smtp": {
          "id": "rSVeHz6kjwDIBOZ7",
          "name": "SMTP account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a2542d02-4018-45e5-a8f2-875e669c77a3",
      "name": "标记为已读",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2780,
        460
      ],
      "webhookId": "a5bea8d3-719e-4b2b-a43d-4c6248796267",
      "parameters": {
        "messageId": "={{ $('Gmail Trigger').all()[0].json.id }}\n",
        "operation": "markAsRead"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "cvHi0AAN9bE3lcij",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "0a1d79a3-91cf-4bf6-93bb-1482549a74dd",
      "name": "应用标签",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2960,
        460
      ],
      "webhookId": "c3a2fc4e-d90c-463a-a356-db530e1b91b0",
      "parameters": {
        "labelIds": [
          "CATEGORY_UPDATES"
        ],
        "messageId": "={{ $('Gmail Trigger').all()[0].json.id }}\n",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "cvHi0AAN9bE3lcij",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "28467e9f-a730-4545-89cb-7d2c629edd71",
      "name": "来自现有合同的邮件",
      "type": "n8n-nodes-base.if",
      "position": [
        1640,
        220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "7cffe101-333d-4ec2-a822-181fe421745b",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.headers.from }}",
              "rightValue": "@syncbricks.com"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b150ab4d-dcbb-4ae6-9503-5914e39f41ac",
      "name": "回复",
      "type": "n8n-nodes-base.if",
      "position": [
        1640,
        460
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "07a6d5e2-ffc5-41d8-b69a-abd6860879c0",
              "operator": {
                "type": "string",
                "operation": "notStartsWith"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Re:"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "1f043246-cbd0-466d-bbfd-b13131a66f03",
      "name": "问题回复",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2720,
        160
      ],
      "webhookId": "ed01c3d4-1fad-4098-b431-4bc3d5e05434",
      "parameters": {
        "html": "=<p>\n  Hi {{ $json.senderName }} <{{ $json.senderEmail }}>,\n</p>\n\n<p>Thanks for reaching out with your questions. I’d love to cover everything face-to-face.</p>\n\n<p><strong>Location:</strong><br>\n123 Main St<br>\nLos Angeles, CA 90089\n</p>\n\n<p>We just sent you three calendar invitations for these time slots:</p>\n\n<ul>\n  {{ $json.slotTimes.map(t => `<li>${t}</li>`).join('') }}\n</ul>\n\n<p>\n  Click <em>Yes</em> on the invite that works best for you.  \n  Google will reserve that slot automatically; the other two will stay open.\n</p>\n\n<p>\n  If none of the times work, reply with a couple of alternatives and I’ll find something that fits.\n</p>\n\n<p>Looking forward to meeting you!<br>— Corvin</p>\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "=Re: {{ $json.originalSub }}",
        "toEmail": "={{ $json.senderName }} <{{ $json.senderEmail }}>",
        "fromEmail": "kulankur.work@gmail.com"
      },
      "credentials": {
        "smtp": {
          "id": "rSVeHz6kjwDIBOZ7",
          "name": "SMTP account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "60d50fdc-4e7f-4ab1-a240-1be4c8ae7520",
      "name": "Google Calendar",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        2100,
        160
      ],
      "parameters": {
        "limit": 3,
        "options": {
          "query": "Available – Office Visit",
          "orderBy": "startTime",
          "recurringEventHandling": "expand"
        },
        "timeMax": "=",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "37f51d1c36997a7dacbba1d1470fe5f0213699c4d926e7a3104c35f1cb79cb75@group.calendar.google.com",
          "cachedResultName": "Meeting slots"
        },
        "operation": "getAll"
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "De5XvcvX90kFuzvb",
          "name": "Google Calendar account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "48a8b613-54e3-4002-8830-1726a23d24aa",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        2280,
        160
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "de676780-43c8-476d-ab8a-a692ffe4e65f",
      "name": "Google Calendar1",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        2520,
        300
      ],
      "parameters": {
        "eventId": "={{$json.id}}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "37f51d1c36997a7dacbba1d1470fe5f0213699c4d926e7a3104c35f1cb79cb75@group.calendar.google.com",
          "cachedResultName": "Meeting slots"
        },
        "operation": "update",
        "updateFields": {
          "attendeesUi": {
            "values": {
              "attendees": [
                "={{ $(\"Gmail Trigger\").item.json.from.value[0].address }}\n"
              ]
            }
          },
          "sendUpdates": "all"
        }
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "De5XvcvX90kFuzvb",
          "name": "Google Calendar account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "df5552fc-910b-4b13-81fa-0c9d98ce82d7",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        2520,
        140
      ],
      "parameters": {
        "jsCode": "const triggerJson = $('Gmail Trigger').item.json;\nconst headersFrom  = triggerJson.headers.from;      // \"Name <addr@example.com>\"\n\n// Split into name and address\nconst namePart = headersFrom.split('<')[0].replace(/^From:\\s*/i, '').trim();\nconst emailPart = headersFrom.match(/<([^>]+)>/)?.[1] || headersFrom;\n\nconst slotTimes = items.map(i =>\n  new Date(i.json.start.dateTime || i.json.start.date).toLocaleString(\n    'en-US',\n    { weekday:'short', month:'short', day:'numeric', hour:'numeric',\n      minute:'2-digit', hour12:true }\n  )\n);\n\nreturn [{\n  json: {\n    slotTimes,\n    senderName:  namePart,\n    senderEmail: emailPart,\n    originalSub: triggerJson.subject               // pass the subject along\n  }\n}];\n"
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2b74a94c-8a92-4a15-b0a4-5590afba0f39",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "QuestionsReply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply": {
      "main": [
        [
          {
            "node": "Text Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email": {
      "main": [
        [
          {
            "node": "Mark as Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark as Read": {
      "main": [
        [
          {
            "node": "Apply Label",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Emails from Existing Contracts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "QuestionsReply": {
      "main": [
        [
          {
            "node": "Mark as Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Google Calendar1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text Classifier": {
      "main": [
        [
          {
            "node": "Google Calendar",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Youtube Video Inquiry",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Youtube Video Inquiry": {
      "main": [
        [
          {
            "node": "Mark as Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Text Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Emails from Existing Contracts": {
      "main": [
        [],
        [
          {
            "node": "Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量14
分类1
节点类型9
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
外部链接
在 n8n.io 查看

分享此工作流