8
n8n 中文网amn8n.com

雇佣后留存跟踪

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 19 个节点。主要使用 If, Code, Gmail, Merge, GoogleSheets 等节点。 使用GPT-4o和Gmail摘要生成员工留存分析报告

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "T8iqiPFY6WdVtlC0",
  "meta": {
    "instanceId": "8443f10082278c46aa5cf3acf8ff0f70061a2c58bce76efac814b16290845177"
  },
  "name": "雇佣后留存跟踪",
  "tags": [],
  "nodes": [
    {
      "id": "c315357f-e9ad-43c8-89f3-e0a030fb6308",
      "name": "当点击“执行工作流”时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -544,
        -32
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5703baf8-53a0-46a7-b8fe-1bddb3da80a5",
      "name": "候选人数据获取",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -256,
        64
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1454922719,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y/edit#gid=1454922719",
          "cachedResultName": "Retention Summary)"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y/edit?usp=drivesdk",
          "cachedResultName": "Interviewer Brief Pack "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "kpPEOLCGn963qpoh",
          "name": "automations@techdome.ai"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "76e5ed93-981c-402f-ba97-0f6c07b4642e",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        464
      ],
      "parameters": {
        "height": 384,
        "content": "## ⚠️ 错误处理逻辑 (Google Sheets – 错误日志)"
      },
      "typeVersion": 1
    },
    {
      "id": "d48ac595-d48e-401d-88bd-a31c3cd596d4",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        176
      ],
      "parameters": {
        "height": 448,
        "content": "## ✅ 数据验证"
      },
      "typeVersion": 1
    },
    {
      "id": "bddb3bf5-c3bb-4899-b6ff-aa22b953b366",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        -496
      ],
      "parameters": {
        "width": 304,
        "height": 464,
        "content": "## 🧮 候选人评分与数据标准化 (代码节点)"
      },
      "typeVersion": 1
    },
    {
      "id": "549cdd14-5514-4413-9e91-ec3ddd9aa771",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        192
      ],
      "parameters": {
        "width": 272,
        "height": 384,
        "content": "## 🔀 合并候选人 + 特质数据"
      },
      "typeVersion": 1
    },
    {
      "id": "b9f7939e-a01f-400f-b5b1-45b9202f6bc4",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        -576
      ],
      "parameters": {
        "width": 288,
        "height": 400,
        "content": "## 📑 特质摘要获取 (Google Sheets – 留存摘要)"
      },
      "typeVersion": 1
    },
    {
      "id": "a5260ee9-3a6a-4cc1-ae50-426cb4e7d372",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -336,
        240
      ],
      "parameters": {
        "width": 272,
        "height": 416,
        "content": "## 📑 候选人数据获取 (Google Sheets – 雇佣跟踪)"
      },
      "typeVersion": 1
    },
    {
      "id": "5b4a9840-0dd7-4fcc-b6d1-a2ca015d5daf",
      "name": "### 需要帮助?",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        192
      ],
      "parameters": {
        "height": 384,
        "content": "## 🧠 AI 处理后端 (Azure OpenAI 节点)"
      },
      "typeVersion": 1
    },
    {
      "id": "94d3d781-c9a4-4778-8029-440612132c7f",
      "name": "## 试试看!",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        -512
      ],
      "parameters": {
        "width": 368,
        "height": 464,
        "content": "## 🤖 留存摘要生成器 (LLM Chain)"
      },
      "typeVersion": 1
    },
    {
      "id": "b6bf37e0-ebfd-48d4-a47b-66d6bbaa2991",
      "name": "GET 模型",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1504,
        -496
      ],
      "parameters": {
        "height": 432,
        "content": "## 📧 邮件发送 (Gmail – 发送摘要)"
      },
      "typeVersion": 1
    },
    {
      "id": "82cb57ca-7214-4789-ba0e-c49871938f13",
      "name": "特质摘要获取",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -256,
        -144
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 834845387,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y/edit#gid=834845387",
          "cachedResultName": "Hires Tracking"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y/edit?usp=drivesdk",
          "cachedResultName": "Interviewer Brief Pack "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "kpPEOLCGn963qpoh",
          "name": "automations@techdome.ai"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "41c489c1-9aa2-4ea7-a000-c57e0cd237f0",
      "name": "合并候选人 + 特质数据",
      "type": "n8n-nodes-base.merge",
      "position": [
        128,
        0
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "88119bb1-b48a-4d71-95da-6f012e87830e",
      "name": "候选人评分与数据标准化",
      "type": "n8n-nodes-base.code",
      "position": [
        416,
        0
      ],
      "parameters": {
        "jsCode": "// ---- STEP 1: Separate inputs ----\nconst allRows = $input.all();\n\n// Identify rows with candidate info (Hire Tracking) vs traits (Retention Summary)\nconst candidateRaw = allRows.filter(r => r.json[\"Candidate \"] || r.json.Candidate);\nconst traitsRaw = allRows.filter(r => r.json.Trait);\n\n// ---- STEP 2: Normalize Candidate Data ----\nconst candidates = candidateRaw.map(c => {\n  return {\n    row_number: c.json.row_number,\n    Candidate: (c.json[\"Candidate \"] || c.json.Candidate || \"\").trim(),\n    Role: (c.json[\"Role              \"] || c.json.Role || \"\").trim(),\n    Traits: (c.json[\"Traits                   \"] || c.json.Traits || \"\").trim(),\n    Start_Date: c.json[\"Start Date\"] || null,\n    Status: (c.json[\"Status   \"] || c.json.Status || \"\").trim(),\n    Retention_30: c.json[\"Retention_30 \"] ?? c.json.Retention_30 ?? null,\n    Retention_90: c.json[\"Retention_90\"] ?? null,\n    Candidate_Score: c.json[\"Candidate_Score\"] || 0\n  };\n});\n\n// ---- STEP 3: Normalize Traits Summary ----\nconst traits = traitsRaw.map(t => {\n  return {\n    Trait: t.json.Trait,\n    Total_Hires: parseInt(t.json.Total_Hires, 10) || 0,\n    Stayed_90: parseInt(t.json.Stayed_90, 10) || 0,\n    Left_90: parseInt(t.json.Left_90, 10) || 0,\n    \"Retention_%\": parseFloat(t.json[\"Retention_%\"]) || 0,\n    Weight_Adjust: parseInt(t.json.Weight_Adjust, 10) || 0,\n    Candidate_Score: t.json.Candidate_Score || 0\n  };\n});\n\n// ---- STEP 4: Build Trait Weight Lookup ----\nconst weightMap = {};\nfor (const t of traits) {\n  weightMap[t.Trait] = t.Weight_Adjust;\n}\n\n// ---- STEP 5: Calculate Candidate Scores ----\nfor (const c of candidates) {\n  let score = 0;\n  const candidateTraits = (c.Traits || \"\").split(\",\").map(t => t.trim());\n  candidateTraits.forEach(trait => {\n    score += weightMap[trait] ?? 0;\n  });\n  c.Candidate_Score = score;\n}\n\n// ---- STEP 6: Final Combined Output ----\nreturn [\n  {\n    json: {\n      candidates,\n      traits\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "b563b0b1-393d-48a3-8f8f-d8c55fa1d8b7",
      "name": "数据验证",
      "type": "n8n-nodes-base.if",
      "position": [
        672,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "01f729d5-7169-4f69-89cc-90bc194d11b5",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.candidates.length }}",
              "rightValue": 0
            },
            {
              "id": "ef01e17b-4779-4819-a879-742246d8a3f4",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.traits.length }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "71be08e3-2031-416a-851f-9833953b1e25",
      "name": "错误处理逻辑",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        928,
        304
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "error_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "error_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "error",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "error",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "error_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1338537721,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y/edit#gid=1338537721",
          "cachedResultName": "error log sheet"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y/edit?usp=drivesdk",
          "cachedResultName": "Interviewer Brief Pack "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "kpPEOLCGn963qpoh",
          "name": "automations@techdome.ai"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "62e4914b-c97a-46b7-bd66-1fc1cbd4d0df",
      "name": "留存摘要生成器",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1104,
        -16
      ],
      "parameters": {
        "text": "=Here is the retention dataset:\n\n{{ JSON.stringify($json, null, 2) }}\n\nGenerate one **Retention Digest** email using this dataset. \nThe HTML should include the following sections:\n\n1. **TL;DR Summary** – one short paragraph summarizing retention insights.  \n2. **Top Traits (Strong Retention + Positive Weights)** – list traits with Retention_% = 1 and Weight_Adjust > 0.  \n3. **Weak Traits (Poor Retention + Negative Weights)** – list traits with Retention_% = 0 or Weight_Adjust < 0.  \n4. **Candidate Highlights** – list each candidate, their traits, retention status, and Candidate_Score (positive/negative).  \n5. **Actionable Tips** – provide 3 practical JD refinement recommendations based only on this dataset.  \n\n📌 **Formatting requirements**:  \n- Blue header bar (#0073e6) with white bold title “Retention Insights Digest”.  \n- White card-style container with light shadow + rounded corners.  \n- Section headings:  \n   • Blue (#0073e6) for TL;DR and Top Traits  \n   • Red (#d9534f) for Weak Traits  \n   • Green (#28a745) for Actionable Tips  \n- Candidate list in a table (Name, Traits, Score, Retention_90).  \n- Green CTA button (#28a745) at the bottom labeled “View Full Report”.  \n- Output only valid HTML, no markdown or code fences.  \n",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "You are an HR Analytics Assistant.  STRICT RULES:  - Use ONLY the traits and candidate data from the provided dataset.  - Do not invent or hallucinate new traits, values, or candidates.  - Always echo the exact Retention_% and Weight_Adjust values.  - Show candidate scores exactly as calculated.  - Output must be valid, production-ready HTML email with inline CSS styling (email-safe). - Do not include markdown or code fences (no ```html)."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "9fc86f99-9bc5-4161-9145-9cce505d808c",
      "name": "AI 处理后端",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        1072,
        160
      ],
      "parameters": {
        "model": "gpt-4o-mini",
        "options": {}
      },
      "credentials": {
        "azureOpenAiApi": {
          "id": "C3WzT18XqF8OdVM6",
          "name": "Azure Open AI account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "489d85e3-e51c-4db9-ab20-e466db61aa1e",
      "name": "邮件发送",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1552,
        -16
      ],
      "parameters": {
        "toList": [
          "newscctv22@gmail.com"
        ],
        "message": " Weekly Update",
        "subject": "=Retention Analysis Digest - Weekly Update\n",
        "resource": "message",
        "htmlMessage": "={{ $json.text }}",
        "includeHtml": true,
        "additionalFields": {
          "ccList": []
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "gEIaWCTvGfYjMSb3",
          "name": "Gmail credentials"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1c0b5bac-8ce0-4e48-a2e1-b9bf0868d16a",
  "connections": {
    " Data Validation": {
      "main": [
        [
          {
            "node": " Retention Digest Generator",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": " Error Handling Logic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Candidate Data Fetch": {
      "main": [
        [
          {
            "node": "Merge Candidate + Trait Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    " Trait Summary Fetch ": {
      "main": [
        [
          {
            "node": "Merge Candidate + Trait Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    " AI Processing Backend ": {
      "ai_languageModel": [
        [
          {
            "node": " Retention Digest Generator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    " Retention Digest Generator": {
      "main": [
        [
          {
            "node": "Email Delivery",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Candidate + Trait Data": {
      "main": [
        [
          {
            "node": "Candidate Scoring & Data Normalization",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Candidate Data Fetch",
            "type": "main",
            "index": 0
          },
          {
            "node": " Trait Summary Fetch ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Candidate Scoring & Data Normalization": {
      "main": [
        [
          {
            "node": " Data Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 内容创作, 多模态 AI

需要付费吗?

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

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

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

作者
Rahul Joshi

Rahul Joshi

@rahul08

Rahul Joshi is a seasoned technology leader specializing in the n8n automation tool and AI-driven workflow automation. With deep expertise in building open-source workflow automation and self-hosted automation platforms, he helps organizations eliminate manual processes through intelligent n8n ai agent automation solutions.

外部链接
在 n8n.io 查看

分享此工作流