8
n8n 中文网amn8n.com

自动记录新Gmail邮件到Google Sheets

中级

这是一个CRM, Multimodal AI领域的自动化工作流,包含 11 个节点。主要使用 Code, Gmail, Merge, Summarize, GoogleSheets 等节点。 自动将新Gmail邮件记录到Google Sheets

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "ad0113c344ee237399e44e9f11798b05baeb83a6196d514a9ae9d2ad71c3b5c9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "ab1b7d2d-7eac-45eb-9e0a-36f14c56df14",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -592,
        -944
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "be31a0f1-8b41-48ea-b80b-cf3de29df733",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1088,
        -1536
      ],
      "parameters": {
        "width": 400,
        "height": 1056,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "1d6e32b0-92fe-4473-a207-e895e66b79e2",
      "name": "便签52",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        -1296
      ],
      "parameters": {
        "color": 3,
        "width": 224,
        "height": 336,
        "content": "### 1️⃣ 连接 Gmail"
      },
      "typeVersion": 1
    },
    {
      "id": "4f9c9dd4-6a32-4175-bde4-59224486c5ac",
      "name": "便签50",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -1536
      ],
      "parameters": {
        "color": 7,
        "width": 1392,
        "height": 1056,
        "content": "# 📋 使用自动记录在 Google Sheets 中跟踪 Gmail 消息"
      },
      "typeVersion": 1
    },
    {
      "id": "0ba209c5-f532-4a98-a60d-2c3867b7890f",
      "name": "便签54",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -992
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 368,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "89e5ccfd-b798-427d-a3fb-e1c71e408076",
      "name": "添加邮件到表格",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        544,
        -752
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "={{ $json.id }}",
            "snippet": "={{ $('Get Current Emails').item.json.snippet }}",
            "datetime": "={{ $('Get Todays Date').item.json.date }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "snippet",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "snippet",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "datetime",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "datetime",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1t5VXtbo9g7SvGDPmeZok4HG1K-WI1PS0DNBylzmhVwg/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1t5VXtbo9g7SvGDPmeZok4HG1K-WI1PS0DNBylzmhVwg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1t5VXtbo9g7SvGDPmeZok4HG1K-WI1PS0DNBylzmhVwg/edit?usp=drivesdk",
          "cachedResultName": "Emails"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HlBW2puZbuCCq8jJ",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "7fed2ca3-3b0e-4cd9-89e1-364e21e1e67d",
      "name": "获取今日日期",
      "type": "n8n-nodes-base.code",
      "position": [
        -176,
        -848
      ],
      "parameters": {
        "jsCode": "// n8n Code node (JavaScript) - ISO UTC format\nconst now = new Date();\n\n// Output as ISO string (e.g., 2025-08-25T21:07:22Z)\nconst formatted = now.toISOString().replace(/\\.\\d{3}Z$/, 'Z');\n\nreturn [{ date: formatted }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "57a1dc13-b00a-496c-b121-1b56444fc878",
      "name": "获取当前邮件",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -416,
        -1104
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1t5VXtbo9g7SvGDPmeZok4HG1K-WI1PS0DNBylzmhVwg/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1t5VXtbo9g7SvGDPmeZok4HG1K-WI1PS0DNBylzmhVwg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1t5VXtbo9g7SvGDPmeZok4HG1K-WI1PS0DNBylzmhVwg/edit?usp=drivesdk",
          "cachedResultName": "Emails"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HlBW2puZbuCCq8jJ",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "7a474f8f-7ca2-4c91-aff3-b69ecce19677",
      "name": "获取最大日期",
      "type": "n8n-nodes-base.summarize",
      "position": [
        -96,
        -1216
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "datetime",
              "aggregation": "max"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "0a1d33af-d580-4753-af4c-aba65f7c623f",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        272,
        -1264
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.2
    },
    {
      "id": "2bc48807-0c03-4cac-ad18-60b99e7dc6aa",
      "name": "获取新消息",
      "type": "n8n-nodes-base.gmail",
      "position": [
        272,
        -976
      ],
      "webhookId": "65ed2723-9363-4e24-a4a6-f3aba4e2c69d",
      "parameters": {
        "simple": false,
        "filters": {
          "receivedAfter": "={{ $json.max_datetime }}"
        },
        "options": {},
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "Kk42lZeRBQx5U4HR",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "pinData": {},
  "connections": {
    "Combine": {
      "main": [
        [
          {
            "node": "Get new messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Max Date": {
      "main": [
        [
          {
            "node": "Combine",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Todays Date": {
      "main": [
        [
          {
            "node": "Combine",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Get new messages": {
      "main": [
        [
          {
            "node": "Add Emails to Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Current Emails": {
      "main": [
        [
          {
            "node": "Get Max Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Emails to Sheets": {
      "main": [
        []
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Get Todays Date",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Current Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 客户关系管理, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
中级
节点数量11
分类2
节点类型7
难度说明

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

作者
Robert Breen

Robert Breen

@rbreen

Professional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.

外部链接
在 n8n.io 查看

分享此工作流