{
  "name": "Whatask 人手批核（範例）",
  "nodes": [
    {
      "id": "a1f0c001-0000-4000-8000-000000000001",
      "name": "有新發票",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "a1f0c001-0000-4000-8000-000000000002",
      "name": "請 Whatask 批核",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        240,
        0
      ],
      "parameters": {
        "method": "POST",
        "url": "https://whatask.tech/api/v1/approvals/<網址觸發地址最後的一段>",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ request_id: 'inv-' + ($json.invoice_no ?? $execution.id), title: '發票批核', source: 'n8n', fields: [ { key: 'supplier', label: '供應商', value: $json.supplier ?? '' }, { key: 'total', label: '金額', type: 'number', value: $json.total ?? null }, { key: 'due', label: '到期日', type: 'date', value: $json.due ?? null } ], callback_url: 'https://<你的 n8n 地址>/webhook/whatask-approval' }) }}",
        "options": {}
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "",
          "name": "Whatask 網址觸發密鑰"
        }
      }
    },
    {
      "id": "a1f0c001-0000-4000-8000-000000000003",
      "name": "收到 Whatask 批核結果",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        240
      ],
      "webhookId": "whatask-approval",
      "parameters": {
        "httpMethod": "POST",
        "path": "whatask-approval",
        "responseMode": "onReceived",
        "options": {}
      }
    },
    {
      "id": "a1f0c001-0000-4000-8000-000000000004",
      "name": "已確認？",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        240,
        240
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a1f0c001-0000-4000-8000-000000000005",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.decision }}",
              "rightValue": "confirm"
            }
          ]
        }
      }
    }
  ],
  "connections": {
    "有新發票": {
      "main": [
        [
          {
            "node": "請 Whatask 批核",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "收到 Whatask 批核結果": {
      "main": [
        [
          {
            "node": "已確認？",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
