8
n8n 中文网amn8n.com

使用随机模板和Google Sheets追踪的自动冷邮件营销活动

高级

这是一个Lead Nurturing领域的自动化工作流,包含 20 个节点。主要使用 If, Set, Code, Wait, Merge 等节点。 使用随机模板和Google Sheets追踪的自动冷邮件营销活动

前置要求
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "db31bea69a53eada00777682bd2f0392fe4ec4364a135252e7113d3d2d2c1eb4",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "1606155a-a552-43b6-9f21-c2dd1d450b5a",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -336,
        240
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 436315764,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1EP82H05QzVy4JPHVvz06pO09p-V7M8_6-6O1jRAigN0/edit#gid=436315764",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1EP82H05QzVy4JPHVvz06pO09p-V7M8_6-6O1jRAigN0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1EP82H05QzVy4JPHVvz06pO09p-V7M8_6-6O1jRAigN0/edit?usp=drivesdk",
          "cachedResultName": "Leadsss"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "sPZTi75OujS3qDy2",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "3f8db0ae-4627-496b-bebb-bb3984c65994",
      "name": "条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        -112,
        240
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fdc40194-662b-402b-b731-6405ce91259e",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json[\"Send Status\"] }}",
              "rightValue": "SENT"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e1f635be-60c4-4512-bcb3-497f2323fa26",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        112,
        224
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "d6540ff3-3e6a-46bd-96a0-bede2040ac0c",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        336,
        48
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1056380010,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1EP82H05QzVy4JPHVvz06pO09p-V7M8_6-6O1jRAigN0/edit#gid=1056380010",
          "cachedResultName": "Sheet2"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1EP82H05QzVy4JPHVvz06pO09p-V7M8_6-6O1jRAigN0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1EP82H05QzVy4JPHVvz06pO09p-V7M8_6-6O1jRAigN0/edit?usp=drivesdk",
          "cachedResultName": "Leadsss"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "sPZTi75OujS3qDy2",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "34c31c92-aa2f-41f0-9147-059dbb1e70e5",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        560,
        48
      ],
      "parameters": {
        "jsCode": "// Get templates from previous node\nconst templates = items.map(item => item.json);\n\n// Check if templates exist\nif (!templates || templates.length === 0) {\n  throw new Error('No templates found');\n}\n\n// Pick a random template\nconst index = Math.floor(Math.random() * templates.length);\nconst template = templates[index];\n\n// Convert body to HTML\nconst bodyHtml = template.Body.replace(/\\n/g, '<br>');\n\n// Return in n8n-compatible format\nreturn [\n  {\n    json: {\n      subject: template.Subject,\n      body: bodyHtml\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "a30f39bf-bac7-4d22-87be-6dad2d1c84d8",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        784,
        128
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.1
    },
    {
      "id": "7b4e39b8-66f2-4417-80db-d18111a62cde",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        992,
        128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f6a6ba02-422b-4e7c-a73e-03901cc2db0c",
              "name": "subject",
              "type": "string",
              "value": "={{ $json.subject.replace(\"[Name]\", $json.Name || \"there\") }}\n"
            },
            {
              "id": "1b0ed009-ead8-491a-bb47-1fb79e12ab1c",
              "name": "body",
              "type": "string",
              "value": "={{ $json.body.replace(\"[Name]\", $json.Name || \"there\") }}"
            }
          ]
        },
        "includeOtherFields": "={{ true }}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "04d53785-08f3-45cd-a4ed-ff947c700347",
      "name": "合并1",
      "type": "n8n-nodes-base.merge",
      "position": [
        1440,
        64
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.1
    },
    {
      "id": "56c14e56-5840-4303-9c26-444a4a1a8915",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        1440,
        320
      ],
      "webhookId": "59d0e464-9eef-4147-9d07-e283193ed822",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "2071518d-7fa2-4113-bb49-4f5b24d1a1f8",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        128
      ],
      "parameters": {
        "width": 380,
        "height": 320,
        "content": "## 从 Google Sheet 获取潜在客户数据"
      },
      "typeVersion": 1
    },
    {
      "id": "97ecc536-451c-4c81-a045-5eb84d4561c3",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -80
      ],
      "parameters": {
        "width": 420,
        "height": 300,
        "content": "## 从 Google Sheet 获取邮件模板"
      },
      "typeVersion": 1
    },
    {
      "id": "4c935042-6c50-4e0d-987c-7ceadf4bf44d",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        -16
      ],
      "parameters": {
        "width": 300,
        "height": 280,
        "content": "## 记录状态"
      },
      "typeVersion": 1
    },
    {
      "id": "a55b3460-d3f9-48f4-aec2-634ad83144fa",
      "name": "点击“测试工作流”时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -544,
        240
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "0164e396-5f37-4257-851c-c5909769ae7e",
      "name": "Google Sheets6",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1728,
        64
      ],
      "parameters": {
        "columns": {
          "value": {
            "Time": "={{ new Date().toLocaleTimeString(\"en-GB\", { timeZone: \"Africa/casablanca\", hour12: false }) }}",
            "Email": "={{ $json.Email }}",
            "Send Status": "={{ $json.labelIds[0] }}"
          },
          "schema": [
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Send Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Send Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Time",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 436315764,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1EP82H05QzVy4JPHVvz06pO09p-V7M8_6-6O1jRAigN0/edit#gid=436315764",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1EP82H05QzVy4JPHVvz06pO09p-V7M8_6-6O1jRAigN0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1EP82H05QzVy4JPHVvz06pO09p-V7M8_6-6O1jRAigN0/edit?usp=drivesdk",
          "cachedResultName": "Leadsss"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "sPZTi75OujS3qDy2",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "19fe6e1b-828f-4ef8-b172-26b17467d1ce",
      "name": "发送邮件",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1184,
        208
      ],
      "webhookId": "5639edcb-93af-4a72-afd8-df5eb8a7e8db",
      "parameters": {
        "html": "={{ $json.body }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.subject }}",
        "toEmail": "={{ $json.Email }}",
        "fromEmail": "anir@agramprojects.com"
      },
      "credentials": {
        "smtp": {
          "id": "XWbszNJxA8doYVEu",
          "name": "SMTP account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "d00d7894-2f25-4ec1-92d4-424838da86c7",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        -320
      ],
      "parameters": {
        "color": 5,
        "width": 480,
        "height": 240,
        "content": "## ⚙️ 设置检查清单"
      },
      "typeVersion": 1
    },
    {
      "id": "e056f235-7ca6-4afb-bbd7-eeed07124bd9",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        640
      ],
      "parameters": {
        "color": 3,
        "width": 544,
        "height": 288,
        "content": "## 常见首次使用问题"
      },
      "typeVersion": 1
    },
    {
      "id": "ef4cb653-45cf-454e-9b57-0122da54cdf0",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        640
      ],
      "parameters": {
        "color": 4,
        "width": 512,
        "height": 224,
        "content": "## 运行活动前测试内容"
      },
      "typeVersion": 1
    },
    {
      "id": "845ec9dd-da56-4d32-a2aa-846974e11654",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        -320
      ],
      "parameters": {
        "color": 7,
        "width": 848,
        "height": 1376,
        "content": "# 分步设置指南"
      },
      "typeVersion": 1
    },
    {
      "id": "e9e9a45d-56e7-429a-a4ac-65dea168f180",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2064,
        -192
      ],
      "parameters": {
        "color": 2,
        "width": 768,
        "height": 656,
        "content": "# 🚫 GMAIL SMTP 无法使用!"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Google Sheets6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send email": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets1": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 客户培育

需要付费吗?

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

工作流信息
难度等级
高级
节点数量20
分类1
节点类型10
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Anir Agram

Anir Agram

@not0lucky

Automation freelancer solving business challenges with n8n. From email sequences to API integrations and workflow optimization. I build solutions that save time and boost productivity. Let's connect. 🔧

外部链接
在 n8n.io 查看

分享此工作流