8
n8n 中文网amn8n.com

将Jamf智能组成员关系导出为可查看的CSV报告到Slack

高级

这是一个DevOps领域的自动化工作流,包含 21 个节点。主要使用 Set, Code, Slack, Webhook, SplitOut 等节点。 将Jamf智能组成员关系导出为可查看的CSV报告到Slack

前置要求
  • Slack Bot Token 或 Webhook URL
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "894b3446666dc2807d20dfad165e2f6f3696905c2f8c352081f4fd666cdd7b1c"
  },
  "nodes": [
    {
      "id": "5fa718ad-f53d-4a5a-8106-f1f1aef44d47",
      "name": "点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1780,
        820
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c137c6b0-1b24-43e4-b6a6-6ed59270d87d",
      "name": "遍历群组",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -840,
        680
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3,
      "alwaysOutputData": false
    },
    {
      "id": "09fe9c6e-aefd-491a-b888-339311577ef7",
      "name": "获取群组成员",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -640,
        660
      ],
      "parameters": {
        "url": "=https://{{ $('Jamf Server').item.json.server }}.jamfcloud.com/api/v2/computer-groups/smart-group-membership/{{ $json.value }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api"
      },
      "credentials": {
        "oAuth2Api": {
          "id": "SRjYS4PQ8cCMgZLK",
          "name": "Unnamed credential"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d79584bf-5dbb-42a2-a84d-03bc7f2b0672",
      "name": "拆分成员",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -440,
        660
      ],
      "parameters": {
        "include": "selectedOtherFields",
        "options": {},
        "fieldToSplitOut": "members",
        "fieldsToInclude": "={{ $('Split groups').item.json.key }}"
      },
      "typeVersion": 1
    },
    {
      "id": "1db7afe2-6a80-40ee-a2e5-5d595689aeb2",
      "name": "拆分群组",
      "type": "n8n-nodes-base.code",
      "position": [
        -1080,
        740
      ],
      "parameters": {
        "jsCode": "const input = items[0].json;\nconst result = [];\n\nfor (const key in input) {\n  result.push({\n    json: {\n      key,\n      value: input[key]\n    }\n  });\n}\n\nreturn result;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "198f7370-f57b-42f7-ad89-5ce85ffda239",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1780,
        620
      ],
      "webhookId": "d0baf32a-ccec-43dc-9d68-5ffd536b8a1c",
      "parameters": {
        "path": "d0baf32a-ccec-43dc-9d68-5ffd536b8a1c",
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "a7f64b31-e442-4478-809b-c11c4684fb44",
      "name": "转换为 csv",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        160,
        660
      ],
      "parameters": {
        "options": {
          "fileName": "=_",
          "headerRow": true
        },
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1.1
    },
    {
      "id": "a3c00893-c871-4988-a2fd-dab9d655add4",
      "name": "Jamf Server",
      "type": "n8n-nodes-base.set",
      "position": [
        -1540,
        740
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ff1f57d8-399e-4b4d-89a6-b3ac44f40923",
              "name": "server",
              "type": "string",
              "value": "yourSercer"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f91f4654-9d36-4ccd-91df-7489aeced998",
      "name": "CSV 表头",
      "type": "n8n-nodes-base.set",
      "position": [
        -40,
        660
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1cf47bfc-0457-4b6a-ac61-d439bff50691",
              "name": "Device Name",
              "type": "string",
              "value": "={{ $json.general.name }}"
            },
            {
              "id": "3af207c9-eb53-4eec-a5aa-7a125af3c76e",
              "name": "Last contact",
              "type": "string",
              "value": "={{ $json.general.lastContactTime.substring(0,10) }}"
            },
            {
              "id": "d9a77e89-2bee-44e6-9220-06fac550a604",
              "name": "S/N",
              "type": "string",
              "value": "={{ $json.hardware.serialNumber }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ca2d2077-4ed4-4952-8365-e790480b2166",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1620,
        520
      ],
      "parameters": {
        "width": 480,
        "height": 420,
        "content": "## 设置"
      },
      "typeVersion": 1
    },
    {
      "id": "7e0484b8-2151-4ed7-b241-2c1de919e93a",
      "name": "ID",
      "type": "n8n-nodes-base.set",
      "position": [
        -1300,
        740
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f7cff112-42bd-4672-9a2f-c0c0b65bb216",
              "name": "Smart Group 1",
              "type": "string",
              "value": "70"
            },
            {
              "id": "a3b44780-bcee-431c-8ab5-913eb20dd0b6",
              "name": "Smart Group 2",
              "type": "string",
              "value": "166"
            },
            {
              "id": "d0ae5b18-9417-4186-9d14-b39d1d9c7aa3",
              "name": "Smart Group 3",
              "type": "string",
              "value": "208"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "69993c27-ab3d-4e36-825d-d87d00095392",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        520
      ],
      "parameters": {
        "color": 3,
        "width": 220,
        "height": 420,
        "content": "## 拆分"
      },
      "typeVersion": 1
    },
    {
      "id": "273b0995-4b40-4f8e-ab94-affbfafe8f2c",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        240
      ],
      "parameters": {
        "color": 7,
        "width": 1430,
        "height": 700,
        "content": "## 循环"
      },
      "typeVersion": 1
    },
    {
      "id": "163460ca-44fa-4b8c-9545-e71e6f713ade",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        460
      ],
      "parameters": {
        "color": 4,
        "width": 180,
        "height": 400,
        "content": "## 获取"
      },
      "typeVersion": 1
    },
    {
      "id": "484bb691-c2b0-4da1-8294-89b55baad943",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        460
      ],
      "parameters": {
        "color": 3,
        "width": 180,
        "height": 400,
        "content": "## 拆分"
      },
      "typeVersion": 1
    },
    {
      "id": "e5c86151-13f6-41d9-9017-8be5c5faa1de",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        460
      ],
      "parameters": {
        "color": 7,
        "width": 180,
        "height": 400,
        "content": "## 第二层循环"
      },
      "typeVersion": 1
    },
    {
      "id": "7deab3c2-a171-4492-8de4-feb2af3755ce",
      "name": "成员循环",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -240,
        660
      ],
      "parameters": {
        "options": {
          "waitForSubWorkflow": "={{ true }}"
        },
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "UYr3yGHbhA6RFyND",
          "cachedResultName": "get members"
        },
        "workflowInputs": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "eba5da43-adb7-4804-bc9b-12cf4d8cead7",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        460
      ],
      "parameters": {
        "color": 5,
        "width": 180,
        "height": 400,
        "content": "## 选择"
      },
      "typeVersion": 1
    },
    {
      "id": "b9232c0e-65bd-4e23-92e5-98050a784532",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        460
      ],
      "parameters": {
        "color": 2,
        "width": 180,
        "height": 400,
        "content": "## 转换"
      },
      "typeVersion": 1
    },
    {
      "id": "0a5f5bcd-0c7c-49a0-a4cc-7996c5b50dfe",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        460
      ],
      "parameters": {
        "width": 200,
        "height": 400,
        "content": "## 发布"
      },
      "typeVersion": 1
    },
    {
      "id": "e46998ca-b549-45b1-8e41-2b7c516bdd67",
      "name": "Slack 频道",
      "type": "n8n-nodes-base.slack",
      "position": [
        380,
        720
      ],
      "webhookId": "b21eb82b-589d-469d-8181-7e5c002cc20a",
      "parameters": {
        "options": {
          "fileName": "data.csv",
          "channelId": "C07PQP5J1BJ",
          "initialComment": "=🚨<https://{{ $('Jamf Server').item.json.server }}.jamfcloud.com/smartComputerGroups.html?id={{ $('Split groups').item.json.value }}|{{ $('Split groups').item.json.key }} Group>🚨\n"
        },
        "resource": "file"
      },
      "credentials": {
        "slackApi": {
          "id": "8kwaKSXWJHzDApmZ",
          "name": "Slack"
        }
      },
      "executeOnce": true,
      "typeVersion": 2.3
    }
  ],
  "pinData": {},
  "connections": {
    "IDs": {
      "main": [
        [
          {
            "node": "Split groups",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Jamf Server",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CSV headers": {
      "main": [
        [
          {
            "node": "Convert to csv",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Jamf Server": {
      "main": [
        [
          {
            "node": "IDs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Members Loop": {
      "main": [
        [
          {
            "node": "CSV headers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split groups": {
      "main": [
        [
          {
            "node": "Loop over groups",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack Channel": {
      "main": [
        [
          {
            "node": "Loop over groups",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to csv": {
      "main": [
        [
          {
            "node": "Slack Channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop over groups": {
      "main": [
        [],
        [
          {
            "node": "Get group members",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get group members": {
      "main": [
        [
          {
            "node": "Split Out members",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out members": {
      "main": [
        [
          {
            "node": "Members Loop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Jamf Server",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 开发运维

需要付费吗?

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

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

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

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

分享此工作流