8
n8n 中文网amn8n.com

自动生成和交付工资单

高级

这是一个HR领域的自动化工作流,包含 18 个节点。主要使用 Set, Code, Html, Gmail, Filter 等节点。 使用Gmail从Google Sheets生成并邮件发送PDF工资单

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "a6j2K4btAzegz8SD",
  "meta": {
    "instanceId": "c2650793f644091dc80fb900fe63448ad1f4b774008de9608064d67294f8307c",
    "templateCredsSetupCompleted": true
  },
  "name": "自动生成和交付工资单",
  "tags": [],
  "nodes": [
    {
      "id": "c4cfd869-eec5-49c9-b866-48fa3bd39119",
      "name": "手动触发器",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2560,
        368
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e326b4a7-be63-4ad9-ac69-96068c8db253",
      "name": "公司配置",
      "type": "n8n-nodes-base.set",
      "position": [
        -2352,
        368
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "a8a21d06-1edc-400f-9c26-7373fb8da0c1",
      "name": "获取工资数据",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -2128,
        368
      ],
      "parameters": {},
      "typeVersion": 4.7
    },
    {
      "id": "da81de85-ad5b-499b-9334-c4368dcd8c28",
      "name": "迭代工资单行",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1680,
        304
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "750961aa-cf88-4c19-b510-cfac9769be1f",
      "name": "准备工资单数据",
      "type": "n8n-nodes-base.code",
      "position": [
        -1456,
        288
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "2e0c5829-2360-43d4-a527-a2518d75ff22",
      "name": "检查邮件未发送",
      "type": "n8n-nodes-base.filter",
      "position": [
        -1904,
        368
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "4482e304-38a7-40e1-a826-9af818a95f67",
      "name": "生成工资单 HTML",
      "type": "n8n-nodes-base.html",
      "position": [
        -1232,
        288
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "53df5b3b-2bb1-4db0-a051-fd4325ded35b",
      "name": "生成工资单 PDF",
      "type": "n8n-nodes-puppeteer.puppeteer",
      "position": [
        -1008,
        288
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2df79e27-95c0-457e-bc29-e3e97ce20aca",
      "name": "创建 PDF 文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -784,
        288
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "5f081a5d-2db0-4336-a936-9982bd41f0e0",
      "name": "发送工资单邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -560,
        288
      ],
      "webhookId": "e77852a1-96a4-4a96-848d-3cd545ab8583",
      "parameters": {},
      "typeVersion": 2.1
    },
    {
      "id": "42f8dc37-3f3f-4cf9-8adc-944164ed425d",
      "name": "在表格中标记邮件已发送",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -352,
        288
      ],
      "parameters": {},
      "typeVersion": 4.7
    },
    {
      "id": "28642d8e-dcff-4bac-be8d-79f61e49310c",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1936,
        528
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "cb040c93-1945-4be2-a9c3-13f38ae5d5dd",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2560,
        528
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "db9843d7-7562-4554-a05c-595a4c8aeea7",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1408,
        528
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "052fe0ea-ab42-4326-8f6a-c5ada8c5d292",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        528
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "fdab71ad-e026-43e6-ade7-0ea39e2dffdd",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        528
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "79284cac-77fd-4bbc-9db8-390b26d9584f",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2560,
        896
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "175f2dfd-c839-48b9-8ce3-d4e705eade39",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3424,
        -80
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "42dff9cd-0477-4e64-9a15-5ecbb257c8a1",
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Company Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create PDF File": {
      "main": [
        [
          {
            "node": "Send Payslip Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Payroll Data": {
      "main": [
        [
          {
            "node": "Check Email Not Sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Payslip Email": {
      "main": [
        [
          {
            "node": "Mark Email Sent in Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Email Not Sent": {
      "main": [
        [
          {
            "node": "Iterate Payslip Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Payslip PDF": {
      "main": [
        [
          {
            "node": "Create PDF File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Iterate Payslip Rows": {
      "main": [
        [],
        [
          {
            "node": "Prepare Payslip Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Payslip Data": {
      "main": [
        [
          {
            "node": "Generate Payslip HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Company Configuration": {
      "main": [
        [
          {
            "node": "Fetch Payroll Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Payslip HTML": {
      "main": [
        [
          {
            "node": "Generate Payslip PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark Email Sent in Sheet": {
      "main": [
        [
          {
            "node": "Iterate Payslip Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 人力资源

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流