8
n8n 中文网amn8n.com

AI Gmail外出自动回复器

中级

这是一个Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 If, Set, Gmail, SplitInBatches, Agent 等节点。 基于GPT-4o-mini的智能Gmail外出自动回复

前置要求
  • Google 账号和 Gmail API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移

无法加载工作流预览

导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "name": "AI Gmail 外出自动回复器",
  "tags": [],
  "nodes": [
    {
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1632,
        160
      ],
      "parameters": {
        "text": "=You are an Out of Office assistant. Output JSON only.\n\nInputs:\n- from_header: {{ $json.From }}\n- subject: {{ $json.Subject }}\n- snippet: {{ $json.snippet }}\n- return_start: {{ $('Define OOO Dates and Contact').item.json.ooo_start }}\n- return_end: {{ $('Define OOO Dates and Contact').item.json.ooo_end }}\n- timezone: {{ $('Define OOO Dates and Contact').item.json.timezone }}\n- alt_contact_name: {{ $('Define OOO Dates and Contact').item.json.alt_contact_name }}\n- alt_contact_email: {{ $('Define OOO Dates and Contact').item.json.alt_contact_email }}\n- id: {{ $json.id }}\n\nGoal:\nWrite a concise, warm reply that sounds like a real person and helps the sender move forward while I am away.\n\nStyle and language:\n- Use Spanish English.\n- Mirror the sender’s language if subject or snippet is clearly another language.\n- Be friendly and clear. No corporate clichés. No em dashes.\n- Max 100 words.\n\nPersonalisation:\n- Extract the sender’s first name from from_header if possible. If not, use a neutral greeting like “Hi there”.\n- If subject indicates a meeting or request, acknowledge it directly.\n\nDecision rules:\n1) If this appears to be a newsletter, marketing blast, receipt, OTP, calendar bot, or any automated system message, set \"should_reply\": false.\n2) Else set \"should_reply\": true.\n3) For internal colleagues (same domain as mine), keep tone casual-professional and suggest a simple next step.\n4) For clients or external senders, keep tone professional-warm and include a specific next step or alternate contact.\n\nContent rules when replying:\n- State clearly when I will be back using local dates based on timezone.\n- Offer a useful next step. Examples: email {{ $('Define OOO Dates and Contact').item.json.alt_contact_email }} for urgent items, propose they send any decisions or files so I can review on return, or suggest booking time after the return date if appropriate.\n- Do not promise action while away. No images, signatures, or links other than the alternate contact email.\n- Keep paragraphs short. Use simple <p> paragraphs in body_html.\n\nOutput JSON only in this schema:\n{\n  \"should_reply\": boolean,\n  \"subject\": \"string\",\n  \"body_html\": \"string\",\n  \"id\": \"string\"\n}\n\nSubject rule:\n- If replying, subject should usually be \"Re: {{ $json.Subject }}\". If the original subject already contains Re:, keep it as is.\n\nBody quality checklist before finalising:\n- Friendly opener like “Thanks for reaching out” or “Appreciate the note”.\n- One clear sentence stating I am away and the return date.\n- One sentence with the next step or alternate contact ({{ $('Define OOO Dates and Contact').item.json.alt_contact_name }} at {{ $('Define OOO Dates and Contact').item.json.alt_contact_email }}).\n- Optional brief reassurance line like “I’ll get back to you after I return.”\n- Convert new lines to <p> blocks in body_html.",
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1648,
        384
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        }
      },
      "typeVersion": 1.2
    },
    {
      "name": "编辑字段",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1776,
        384
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"title\": \"AI Out of Office Reply\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"should_reply\": {\n      \"type\": \"boolean\"\n    },\n    \"subject\": {\n      \"type\": \"string\"\n    },\n    \"body_html\": {\n      \"type\": \"string\"\n    },\n    \"id\": {\n      \"type\": \"string\"\n    }\n  },\n  \"required\": [\"should_reply\", \"subject\", \"body_html\", \"id\"],\n  \"additionalProperties\": false\n}"
      },
      "typeVersion": 1.3
    },
    {
      "name": "按计划检查邮件",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        288,
        288
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "name": "定义外出日期和联系人",
      "type": "n8n-nodes-base.set",
      "position": [
        512,
        288
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "ooo_start",
              "value": "2025-08-19T07:00:00+02:00"
            },
            {
              "name": "ooo_end",
              "value": "2025-08-27T18:00:00+02:00"
            },
            {
              "name": "timezone",
              "value": "Europe/Madrid"
            },
            {
              "name": "alt_contact_name",
              "value": "Your teammate"
            },
            {
              "name": "alt_contact_email",
              "value": "teammate@example.com"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "name": "检查当前是否外出",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        288
      ],
      "parameters": {
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "dateTime",
                "operation": "after"
              },
              "leftValue": "={{$now.toISO()}}",
              "rightValue": "={{$json.ooo_start}}"
            },
            {
              "operator": {
                "type": "dateTime",
                "operation": "before"
              },
              "leftValue": "={{$now.toISO()}}",
              "rightValue": "={{$json.ooo_end}}"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "name": "获取未读邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        960,
        288
      ],
      "parameters": {
        "filters": {
          "readStatus": "unread"
        },
        "operation": "getAll"
      },
      "typeVersion": 2.1
    },
    {
      "name": "处理每封邮件",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1184,
        288
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "name": "获取邮件内容",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1408,
        160
      ],
      "parameters": {
        "messageId": "={{$json.id}}",
        "operation": "get"
      },
      "typeVersion": 2.1
    },
    {
      "name": "决定是否需要回复",
      "type": "n8n-nodes-base.if",
      "position": [
        1984,
        160
      ],
      "parameters": {
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.output.should_reply }}"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "name": "发送 AI 驱动的自动回复",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2208,
        160
      ],
      "parameters": {
        "message": "={{ $json.output.body_html }}",
        "messageId": "={{ $json.output.id }}",
        "operation": "reply"
      },
      "typeVersion": 2.1
    },
    {
      "name": "标记已回复的邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2432,
        288
      ],
      "parameters": {
        "labelIds": [
          "Label_Replace_With_Your_Label_ID"
        ],
        "messageId": "={{$json.id}}",
        "operation": "addLabels"
      },
      "typeVersion": 2
    },
    {
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        32
      ],
      "parameters": {
        "color": 5,
        "width": 256,
        "height": 512,
        "content": "### 🗓️ 设置您的外出日期和联系信息"
      },
      "typeVersion": 1
    },
    {
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2368,
        48
      ],
      "parameters": {
        "color": 5,
        "width": 304,
        "height": 448,
        "content": "### 🏷️ 用您自己的 Gmail 标签 ID 替换"
      },
      "typeVersion": 1
    },
    {
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        112,
        32
      ],
      "parameters": {
        "color": 5,
        "width": 304,
        "height": 512,
        "content": "### 🔁 调整工作流运行频率"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Decide If Reply Is Needed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Unread Emails": {
      "main": [
        [
          {
            "node": "Process Each Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Process Each Email": {
      "main": [
        [
          {
            "node": "Fetch Email Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tag Replied Emails": {
      "main": [
        [
          {
            "node": "Process Each Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Email Content": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Currently OOO": {
      "main": [
        [
          {
            "node": "Get Unread Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Email on Schedule": {
      "main": [
        [
          {
            "node": "Define OOO Dates and Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Decide If Reply Is Needed": {
      "main": [
        [
          {
            "node": "Send AI-Powered Auto-Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send AI-Powered Auto-Reply": {
      "main": [
        [
          {
            "node": "Tag Replied Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Define OOO Dates and Contact": {
      "main": [
        [
          {
            "node": "Check If Currently OOO",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 多模态 AI

需要付费吗?

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

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

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

作者
Matt Chong | n8n Creator

Matt Chong | n8n Creator

@mattxchong

Automation nerd fueled by good coffee, deep curiosity, and clean flows.

外部链接
在 n8n.io 查看

分享此工作流