8
n8n 中文网amn8n.com

从数据库到Saleshandy的用户入职自动化

高级

这是一个Lead Nurturing领域的自动化工作流,包含 16 个节点。主要使用 Code, HttpRequest, GoogleSheets, ManualTrigger 等节点。 通过Google表格跟踪从数据库到Saleshandy的用户入职自动化

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "5f48daf3a0baf541941ac99dac87a58469ec38ada0698ec3f47e71ef7e50b0ff"
  },
  "nodes": [
    {
      "id": "9c9c4619-6e83-4a31-b783-c1250540b6ff",
      "name": "获取昨日日期",
      "type": "n8n-nodes-base.code",
      "position": [
        380,
        480
      ],
      "parameters": {
        "jsCode": "function formatToSupabaseTimestamp(date) {\n  const iso = date.toISOString();\n  const [datePart, ms = \"000\"] = iso.split('.')[1]?.split('Z') || [\"000\"];\n  const paddedMicro = (ms + \"000000\").slice(0, 6);\n  return iso.replace(/\\.\\d+Z/, `.${paddedMicro}+00:00`);\n}\n\nconst now = new Date();\n\nconst yesterday = new Date(now);\nyesterday.setDate(now.getDate() - 1);\nyesterday.setHours(0, 0, 0, 0);\n\nconst start = new Date(yesterday);\nconst end = new Date(yesterday);\nend.setHours(23, 59, 59, 999);\n\nreturn [\n  {\n    json: {\n      isoStart: formatToSupabaseTimestamp(start),\n      isoEnd: formatToSupabaseTimestamp(end)\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "381fac0c-25bc-4322-980d-009012378923",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        320
      ],
      "parameters": {
        "width": 360,
        "height": 340,
        "content": "## 获取所有用户"
      },
      "typeVersion": 1
    },
    {
      "id": "d216b2d6-ae67-451f-923d-5bd07f847b00",
      "name": "为半合格用户添加行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1560,
        120
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $('Date Filtered Users').item.json.id }}",
            "Name ": "={{ $('Date Filtered Users').item.json.first_name }}",
            "Email ": "={{ $('Date Filtered Users').item.json.email }}",
            "created_at": "={{ $('Date Filtered Users').item.json.created_at}}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Name ",
              "type": "string",
              "display": true,
              "removed": false,
              "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": "created_at",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "created_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "payload",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "payload",
              "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/1ZfV7CLtXKzNtiQcF_9XgHUwyVn467hpYrwFaQ3Hfhmc/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ZfV7CLtXKzNtiQcF_9XgHUwyVn467hpYrwFaQ3Hfhmc",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZfV7CLtXKzNtiQcF_9XgHUwyVn467hpYrwFaQ3Hfhmc/edit?usp=drivesdk",
          "cachedResultName": "database fetch "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "RWziWEBHK0Fgyt1r",
          "name": "Google Sheets account 5"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "dbb1cba5-658e-4065-b8d7-5d7dc0d994aa",
      "name": "从数据库获取所有用户",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        680,
        120
      ],
      "parameters": {
        "url": "ADD YOUR DATABASE URL",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "ADD YOUR DATABASE ANON KEY"
            },
            {
              "name": "Authorization",
              "value": "ADD YOUR SERVICE ROLE KEY (ADD bearer BEFORE SR KEY)"
            }
          ]
        }
      },
      "typeVersion": 4
    },
    {
      "id": "1281e124-bf06-4dae-a232-2142d566fb20",
      "name": "按日期筛选的用户",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        120
      ],
      "parameters": {
        "jsCode": "const isoStart = $items(\"Get yesterday dates\")[0].json.isoStart;\nconst isoEnd = $items(\"Get yesterday dates\")[0].json.isoEnd;\n\nreturn items\n  .filter(item => {\n    const createdAt = new Date(item.json.created_at);\n    const start = new Date(isoStart);\n    const end = new Date(isoEnd);\n    return createdAt >= start && createdAt <= end;\n  })\n  .map(item => {\n    const [first_name, ...rest] = item.json.full_name.split(' ');\n    const last_name = rest.join(' ') || '';\n    return {\n      json: {\n        id: item.json.id,\n        first_name: first_name,\n        last_name: last_name,\n        email: item.json.email,\n        created_at: item.json.created_at\n      }\n    };\n  });\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f54a17c0-b64c-4da7-b9d6-4e52768db0a9",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 1820,
        "height": 700,
        "content": "## **OnboardTrigger:从注册到 Saleshandy 序列**"
      },
      "typeVersion": 1
    },
    {
      "id": "79afa502-655d-4431-8fca-f32ec7abdb51",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        280
      ],
      "parameters": {
        "height": 320,
        "content": "## 触发此工作流以触达每个新注册用户 —> 每日。"
      },
      "typeVersion": 1
    },
    {
      "id": "266fdde0-d952-4a11-bc7f-8bc52b5845ec",
      "name": "每日触发",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        100,
        120
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "4b47add8-1967-4769-a355-58b88151d147",
      "name": "将新注册用户添加到 Saleshandy 序列",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1200,
        520
      ],
      "parameters": {
        "url": "https://open-api.saleshandy.com/v1/sequences/prospects/import-with-field-name",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"prospectList\": [\n    {\n      \"First Name\": \"{{ $json['first_name']}}\",\n      \"Email\": \"{{ $json['email']}}\"\n    }\n  ],\n  \"stepId\": \"ADD YOUR SALESHANDY SEQUENCE ID\",\n  \"verifyProspects\": false,\n  \"conflictAction\": \"overwrite\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "ADD YOUR SALESHANDY API KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "dae2032f-b0f1-4d41-ad01-d01748e12fad",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        120
      ],
      "parameters": {
        "height": 200,
        "content": "## 日期生成器"
      },
      "typeVersion": 1
    },
    {
      "id": "06b5b4d0-a5cb-4fd8-84b2-5462a91d70bd",
      "name": "便签说明5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        100
      ],
      "parameters": {
        "width": 320,
        "height": 400,
        "content": "## 连接到 Saleshandy 序列"
      },
      "typeVersion": 1
    },
    {
      "id": "76700793-0958-495d-8d6d-d4d2b98bd976",
      "name": "便签说明4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        440
      ],
      "parameters": {
        "color": 3,
        "width": 320,
        "height": 200,
        "content": "## 您需要更新的内容:"
      },
      "typeVersion": 1
    },
    {
      "id": "a10100f0-5c60-4320-bcb7-b07dfd7fb153",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        340,
        340
      ],
      "parameters": {
        "color": 3,
        "width": 180,
        "height": 80,
        "content": "默认设置为昨日日期"
      },
      "typeVersion": 1
    },
    {
      "id": "c7b44a55-ec88-4ba3-94b5-dcbd5be785ba",
      "name": "便签 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        280
      ],
      "parameters": {
        "color": 3,
        "width": 280,
        "height": 200,
        "content": "## 您需要更新的内容:"
      },
      "typeVersion": 1
    },
    {
      "id": "a7dec1af-92fb-4a1b-8576-8fedb3fe5fdf",
      "name": "## 为什么选择 4o 模型?👆",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1480,
        300
      ],
      "parameters": {
        "width": 320,
        "height": 340,
        "content": "## 追加到 Google Sheets"
      },
      "typeVersion": 1
    },
    {
      "id": "21032964-c416-4a79-8169-b1ae8a437b51",
      "name": "便签 9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1500,
        420
      ],
      "parameters": {
        "color": 3,
        "width": 280,
        "height": 200,
        "content": "## 您需要更新的内容:"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Trigger Everyday": {
      "main": [
        [
          {
            "node": "Get yesterday dates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date Filtered Users": {
      "main": [
        [
          {
            "node": "Add new signup to Saleshandy's Sequence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get yesterday dates": {
      "main": [
        [
          {
            "node": "Fetch all users from database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch all users from database": {
      "main": [
        [
          {
            "node": "Date Filtered Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add new signup to Saleshandy's Sequence": {
      "main": [
        [
          {
            "node": "Append row for semi-qualified",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 客户培育

需要付费吗?

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

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

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

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

分享此工作流