8
n8n 中文网amn8n.com

Clockify 到 Syncro

中级

这是一个Sales, IT Ops领域的自动化工作流,包含 13 个节点。主要使用 If, Set, Webhook, Function, HttpRequest 等节点。 将计时条目从 Clockify 同步到 Syncro

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移

无法加载工作流预览

导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "3",
  "name": "Clockify 到 Syncro",
  "nodes": [
    {
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        280,
        350
      ],
      "webhookId": "82b654d7-aeb2-4cc1-97a8-0ebd1a729202",
      "parameters": {
        "path": "82b654d7-aeb2-4cc1-97a8-0ebd1a729202",
        "options": {},
        "httpMethod": "POST",
        "responseData": "allEntries",
        "responseMode": "lastNode"
      },
      "typeVersion": 1
    },
    {
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1830,
        350
      ],
      "parameters": {
        "range": "A:B",
        "options": {
          "valueInputMode": "USER_ENTERED"
        },
        "sheetId": "xxx",
        "operation": "append"
      },
      "credentials": {
        "googleApi": "Google"
      },
      "typeVersion": 1
    },
    {
      "name": "用于 Google",
      "type": "n8n-nodes-base.set",
      "position": [
        1650,
        350
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "Syncro",
              "value": "={{$json[\"id\"]}}"
            },
            {
              "name": "Clockify",
              "value": "={{$node[\"Webhook\"].json[\"body\"][\"id\"]}}"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 1
    },
    {
      "name": "用于 Syncro",
      "type": "n8n-nodes-base.set",
      "position": [
        730,
        350
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "id",
              "value": "={{ $json[\"body\"][\"project\"][\"name\"].match(/\\[(\\d+)]/)[1] }}"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 1
    },
    {
      "name": "查找匹配",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1130,
        350
      ],
      "parameters": {
        "range": "A:B",
        "options": {
          "valueRenderMode": "UNFORMATTED_VALUE",
          "returnAllMatches": true
        },
        "sheetId": "xxx",
        "operation": "lookup",
        "lookupValue": "={{$node[\"Webhook\"].json[\"body\"][\"id\"]}}",
        "lookupColumn": "=Clockify"
      },
      "credentials": {
        "googleApi": "Google"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "position": [
        1300,
        350
      ],
      "parameters": {
        "conditions": {
          "string": [],
          "boolean": [
            {
              "value1": "={{!!Object.keys($node[\"FindMatch\"].data).length}}",
              "value2": true
            }
          ]
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": false
    },
    {
      "name": "新建 Syncro 计时器",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1490,
        350
      ],
      "parameters": {
        "url": "={{$node[\"EnvVariables\"].json[\"syncro_baseurl\"]}}/api/v1/tickets/{{$node[\"ForSyncro\"].json[\"id\"]}}/timer_entry",
        "options": {},
        "requestMethod": "POST",
        "authentication": "headerAuth",
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "start_at",
              "value": "={{$node[\"Webhook\"].json[\"body\"][\"timeInterval\"][\"start\"]}}"
            },
            {
              "name": "end_at",
              "value": "={{$node[\"Webhook\"].json[\"body\"][\"timeInterval\"][\"end\"]}}"
            },
            {
              "name": "notes",
              "value": "={{$node[\"Webhook\"].json[\"body\"][\"description\"]}}"
            },
            {
              "name": "user_id",
              "value": "={{$node[\"MatchTechnician\"].json[\"id\"]}}"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": "Syncro"
      },
      "typeVersion": 1
    },
    {
      "name": "更新 Syncro 计时器",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1490,
        580
      ],
      "parameters": {
        "url": "={{$node[\"EnvVariables\"].json[\"syncro_baseurl\"]}}/api/v1/tickets/{{$node[\"ForSyncro\"].json[\"id\"]}}/update_timer_entry",
        "options": {
          "followRedirect": true
        },
        "requestMethod": "PUT",
        "authentication": "headerAuth",
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "timer_entry_id",
              "value": "={{$node[\"IF\"].json[\"Syncro\"]}}"
            },
            {
              "name": "start_time",
              "value": "={{$node[\"Webhook\"].json[\"body\"][\"timeInterval\"][\"start\"]}}"
            },
            {
              "name": "end_time",
              "value": "={{$node[\"Webhook\"].json[\"body\"][\"timeInterval\"][\"end\"]}}"
            },
            {
              "name": "notes",
              "value": "={{$node[\"Webhook\"].json[\"body\"][\"description\"]}}"
            },
            {
              "name": "user_id",
              "value": "={{$node[\"MatchTechnician\"].json[\"id\"]}}"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": "Syncro"
      },
      "typeVersion": 1
    },
    {
      "name": "环境变量",
      "type": "n8n-nodes-base.set",
      "position": [
        580,
        350
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "syncro_baseurl",
              "value": "https://subdomain.syncromsp.com"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "name": "设置技术人员",
      "type": "n8n-nodes-base.set",
      "position": [
        870,
        350
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "Tech 1",
              "value": "1234"
            },
            {
              "name": "Tech 2",
              "value": "5678"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 1
    },
    {
      "name": "匹配技术人员",
      "type": "n8n-nodes-base.function",
      "position": [
        1000,
        350
      ],
      "parameters": {
        "functionCode": "\nconst results = [];\n\nconst user = $node[\"Webhook\"].json[\"body\"][\"user\"];\n\nconst persons = items[0].json\n\nfor (key of Object.keys(persons)) {\n  if (key === user.name) {\n    results.push({ json: { id: persons[key], name: key } })\n  }\n}\n\nreturn results;"
      },
      "typeVersion": 1
    },
    {
      "name": "IF1",
      "type": "n8n-nodes-base.if",
      "position": [
        420,
        350
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"body\"][\"project\"][\"name\"]}}",
              "value2": "Ticket",
              "operation": "contains"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "name": "无操作",
      "type": "n8n-nodes-base.noOp",
      "position": [
        480,
        520
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {},
  "connections": {
    "IF": {
      "main": [
        [
          {
            "node": "UpdateSyncroTimer",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "NewSyncroTimer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF1": {
      "main": [
        [
          {
            "node": "EnvVariables",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "IF1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FindMatch": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ForGoogle": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ForSyncro": {
      "main": [
        [
          {
            "node": "SetTechnicians",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "EnvVariables": {
      "main": [
        [
          {
            "node": "ForSyncro",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "NewSyncroTimer": {
      "main": [
        [
          {
            "node": "ForGoogle",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SetTechnicians": {
      "main": [
        [
          {
            "node": "MatchTechnician",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MatchTechnician": {
      "main": [
        [
          {
            "node": "FindMatch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 销售, IT 运维

需要付费吗?

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

工作流信息
难度等级
中级
节点数量13
分类2
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流