8
n8n 中文网amn8n.com

使用Google Sheets跟踪的QuickBooks新客户欢迎邮件自动化

高级

这是一个Social Media领域的自动化工作流,包含 19 个节点。主要使用 Code, EmailSend, Quickbooks, GoogleSheets, CompareDatasets 等节点。 使用Google Sheets跟踪的QuickBooks客户欢迎邮件

前置要求
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "uWv6ijZPkfz6ayIP",
  "meta": {
    "instanceId": "e727f992f69a44655d3d4d5a1d4a30ca3ec1573139240bc4d84b17b8f66642c8",
    "templateCredsSetupCompleted": true
  },
  "name": "使用Google Sheets跟踪的自动化QuickBooks新客户欢迎邮件",
  "tags": [],
  "nodes": [
    {
      "id": "b49dda17-46e1-48f3-bc0b-7b97d3af1c12",
      "name": "获取多个客户",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        400,
        -64
      ],
      "parameters": {
        "limit": 1000,
        "filters": {},
        "operation": "getAll"
      },
      "credentials": {
        "quickBooksOAuth2Api": {
          "id": "r3A6wRAzyp859vQL",
          "name": "QuickBooks Online account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c8b9d669-e0a5-4419-a756-d0e750e18be4",
      "name": "启动两个分支",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -64,
        160
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "fc1ffeb4-2126-493d-80ac-a2ae848f744b",
      "name": "读取老客户",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        400,
        336
      ],
      "parameters": {
        "options": {
          "dataLocationOnSheet": {
            "values": {
              "range": "A:A",
              "rangeDefinition": "specifyRangeA1"
            }
          }
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1M4AoRTj6XuBiNC1O901ctC5k1b2w0vxwh-nO5WOS7zM/edit#gid=0",
          "cachedResultName": "Processed IDs"
        },
        "documentId": {
          "__rl": true,
          "mode": "",
          "value": "1M4AoRTj6XuBiNC1O901ctC5k1b2w0vxwh-nO5WOS7zM"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "950xCiKdYVCxu8WS",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "83a2cc67-11c9-46c8-b71a-3aa545ddbc4a",
      "name": "调度器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -368,
        160
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "dec9b8cc-c192-45eb-a992-737a161927d9",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 358,
        "height": 368,
        "content": "## 设置您的计划节点"
      },
      "typeVersion": 1
    },
    {
      "id": "1b5d3b55-68fa-49aa-9e28-9243a79b6c21",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1696,
        -880
      ],
      "parameters": {
        "color": 5,
        "width": 992,
        "height": 1952,
        "content": "# 自动化QuickBooks新客户欢迎邮件"
      },
      "typeVersion": 1
    },
    {
      "id": "bb12eadd-a78d-4006-a719-61e71869a508",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -288
      ],
      "parameters": {
        "color": 5,
        "width": 352,
        "height": 384,
        "content": "## 获取多个客户节点"
      },
      "typeVersion": 1
    },
    {
      "id": "bd8a6285-05f0-4e95-a46c-a49d20116b4f",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        320
      ],
      "parameters": {
        "color": 5,
        "width": 352,
        "height": 432,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "a7c263f3-8ac8-4a17-b6ac-4e1abf6313e7",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        -144
      ],
      "parameters": {
        "color": 5,
        "width": 352,
        "height": 432,
        "content": "## 查找新客户节点"
      },
      "typeVersion": 1
    },
    {
      "id": "6384837d-a8b1-4921-938a-d8791097962e",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1312,
        -176
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 432,
        "content": "## 记录新客户详情节点"
      },
      "typeVersion": 1
    },
    {
      "id": "8dec0230-fcf7-4991-884d-d84bccc5003a",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1328,
        304
      ],
      "parameters": {
        "color": 5,
        "width": 384,
        "height": 512,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "a741a432-1c7a-4ddd-bef8-17eb6d673f8e",
      "name": "邮件模板",
      "type": "n8n-nodes-base.code",
      "position": [
        1984,
        64
      ],
      "parameters": {
        "jsCode": "// This code works when \"Execute Once\" is ON.\n// 'items' is an array of all customers from the previous node.\n\nfor (const item of items) {\n  const customer = item.json;\n\n  // --- 1. Dynamic Personalization Logic ---\n  const greeting = customer.GivenName ? `Hello ${customer.GivenName},` : `Hello ${customer.DisplayName},`;\n  let openingLine = `We are absolutely thrilled to welcome you to our family!`;\n  if (customer.CompanyName) {\n    openingLine = `We are absolutely thrilled to welcome <strong>${customer.CompanyName}</strong> to our family!`;\n  }\n  const detailsConfirmation = `\n    <div style=\"background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin-top: 15px; border: 1px solid #dee2e6;\">\n      <strong>Display Name:</strong> ${customer.DisplayName}<br>\n      <strong>Email:</strong> ${customer.PrimaryEmailAddr.Address}\n      ${customer.BillAddr && customer.BillAddr.City ? `<br><strong>Location:</strong> ${customer.BillAddr.City}, ${customer.BillAddr.CountrySubDivisionCode}` : ''}\n    </div>\n  `;\n\n  // --- 2. Construct the HTML Email Body ---\n  const emailHtml = `\n  <!DOCTYPE html>\n  <html>\n  <head>\n    <title>A Warm Welcome!</title>\n  </head>\n  <body style=\"margin: 0; padding: 0; background-color: #f4f4f4; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\">\n    <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n      <tr>\n        <td style=\"padding: 20px 0;\">\n          <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\" style=\"border-collapse: collapse; background-color: #ffffff; max-width: 600px;\">\n            <tr>\n              <td align=\"center\" style=\"padding: 30px; background-color: #00466a;\">\n                <img src=\"https://yourdomain.com/images/logo.png\" alt=\"Company Logo\" style=\"display: block; width: 150px;\">\n              </td>\n            </tr>\n            <tr>\n              <td style=\"padding: 40px 30px;\">\n                <h1 style=\"font-size: 24px; font-weight: bold; color: #153643;\">${greeting}</h1>\n                <p style=\"font-size: 16px; line-height: 1.5; color: #333333;\">${openingLine}</p>\n                <p style=\"font-size: 16px; line-height: 1.5; color: #333333;\">\n                  To ensure everything is perfect from the start, we've listed the primary details we have on file for you:\n                </p>\n                ${detailsConfirmation}\n                <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n                  <tr>\n                    <td align=\"center\" style=\"padding: 20px 0;\">\n                      <a href=\"https://yourdomain.com/\" style=\"background-color: #ff7f50; color: #ffffff; padding: 15px 25px; text-decoration: none; border-radius: 5px; font-size: 16px; display: inline-block;\">Explore Your Dashboard</a>\n                    </td>\n                  </tr>\n                </table>\n              </td>\n            </tr>\n            <tr>\n              <td style=\"padding: 30px; background-color: #eeeeee; color: #555555; font-size: 14px; text-align: center;\">\n                  <p style=\"margin: 0;\">Questions? Just reply to this email or <a href=\"mailto:info@yourdomain.com\" style=\"color: #00466a;\">contact our support team</a>.</p>\n                  <p style=\"margin: 10px 0 0 0;\">© 2025 [Your Company Name], All rights reserved.</p>\n              </td>\n            </tr>\n          </table>\n        </td>\n      </tr>\n    </table>\n  </body>\n  </html>\n  `;\n\n  // --- 3. Add the generated HTML to the current item ---\n  item.json.emailHtml = emailHtml;\n}\n\n// --- 4. Return all the modified items for the next node ---\nreturn items;"
      },
      "typeVersion": 2
    },
    {
      "id": "6c08ace4-0df2-46c2-af96-53b0c54ad8df",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1824,
        -224
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 432,
        "content": "## 邮件模板节点"
      },
      "typeVersion": 1
    },
    {
      "id": "fc810d73-c33f-4489-8de9-116dab8470f9",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2304,
        -224
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 480,
        "content": "## 发送个性化欢迎邮件节点"
      },
      "typeVersion": 1
    },
    {
      "id": "881a2221-432d-4a6e-896d-4233f4f6b9cc",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1696,
        1120
      ],
      "parameters": {
        "color": 2,
        "width": 976,
        "height": 240,
        "content": "# 需要更多帮助"
      },
      "typeVersion": 1
    },
    {
      "id": "6f53a5d6-982b-4f15-9496-b4ce1c744496",
      "name": "查找新客户",
      "type": "n8n-nodes-base.compareDatasets",
      "position": [
        880,
        80
      ],
      "parameters": {
        "options": {},
        "mergeByFields": {
          "values": [
            {
              "field1": "Id",
              "field2": "CustomerIds"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "de5d511e-25c2-4672-9994-8080815de004",
      "name": "记录新客户详情",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1456,
        64
      ],
      "parameters": {
        "options": {},
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "Customer_Name",
              "fieldValue": "={{ $json.GivenName }}"
            },
            {
              "fieldId": "Company_Name",
              "fieldValue": "={{ $json.CompanyName }}"
            },
            {
              "fieldId": "Email_ID",
              "fieldValue": "={{ $json.PrimaryEmailAddr.Address }}"
            },
            {
              "fieldId": "Phone_No",
              "fieldValue": "={{ $json.PrimaryPhone.FreeFormNumber }}"
            },
            {
              "fieldId": "Customer_ID",
              "fieldValue": "={{ $json.Id }}"
            }
          ]
        },
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1652724254,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1M4AoRTj6XuBiNC1O901ctC5k1b2w0vxwh-nO5WOS7zM/edit#gid=1652724254",
          "cachedResultName": "New Customer Logs"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1M4AoRTj6XuBiNC1O901ctC5k1b2w0vxwh-nO5WOS7zM"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "950xCiKdYVCxu8WS",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "4b757337-eebd-407f-aad8-abaa6823337d",
      "name": "记录新客户ID以进行跟踪",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1456,
        336
      ],
      "parameters": {
        "options": {},
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "CustomerIds",
              "fieldValue": "={{ $json.Id }}"
            }
          ]
        },
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1M4AoRTj6XuBiNC1O901ctC5k1b2w0vxwh-nO5WOS7zM/edit#gid=0",
          "cachedResultName": "Processed IDs"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1M4AoRTj6XuBiNC1O901ctC5k1b2w0vxwh-nO5WOS7zM"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "950xCiKdYVCxu8WS",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "8b348312-b1b8-4e87-96a8-9657e002d6e1",
      "name": "发送个性化欢迎邮件",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2448,
        64
      ],
      "webhookId": "0bd83eff-7028-4841-ba18-2981c22b869b",
      "parameters": {
        "html": "={{ $json.emailHtml }}",
        "options": {},
        "subject": "=A Warm Welcome to [Your Company Name], {{$json.DisplayName}}!",
        "toEmail": "={{ $json.PrimaryEmailAddr.Address }}",
        "fromEmail": "company.ebtech@gmail.com"
      },
      "credentials": {
        "smtp": {
          "id": "ZSjtbi8UmObTzmbO",
          "name": "SMTP account"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d881dde4-93e3-44db-b6a3-c11ccd7bdcec",
  "connections": {
    "Scheduler": {
      "main": [
        [
          {
            "node": "Start Both Branches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Template": {
      "main": [
        [
          {
            "node": "Send Personalized Welcome Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find New Customers": {
      "main": [
        [
          {
            "node": "Log New Customer Details",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log New Customer ID for Tracking",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many customers": {
      "main": [
        [
          {
            "node": "Find New Customers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Old Customers": {
      "main": [
        [
          {
            "node": "Find New Customers",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Start Both Branches": {
      "main": [
        [
          {
            "node": "Get many customers",
            "type": "main",
            "index": 0
          },
          {
            "node": "Read Old Customers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log New Customer Details": {
      "main": [
        [
          {
            "node": "Email Template",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 社交媒体

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流