{
  "name": "AgentDraft — Race-free meeting booking",
  "nodes": [
    {
      "parameters": {},
      "id": "a1b2c3d4-0001-4a00-8000-000000000001",
      "name": "When clicking 'Execute workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [220, 320]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f0000000-0000-4000-8000-000000000010",
              "name": "start",
              "value": "2026-05-12T16:00:00Z",
              "type": "string"
            },
            {
              "id": "f0000000-0000-4000-8000-000000000011",
              "name": "end",
              "value": "2026-05-12T16:30:00Z",
              "type": "string"
            },
            {
              "id": "f0000000-0000-4000-8000-000000000012",
              "name": "title",
              "value": "Discovery call · Acme",
              "type": "string"
            },
            {
              "id": "f0000000-0000-4000-8000-000000000013",
              "name": "idempotencyKey",
              "value": "n8n-discovery-acme-20260512T1600",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-0002-4a00-8000-000000000002",
      "name": "Booking details",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [460, 320]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.agentdraft.io/v1/bookings",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "={{ $json.idempotencyKey }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"start\": \"{{ $json.start }}\",\n  \"end\": \"{{ $json.end }}\",\n  \"mode\": \"commit\",\n  \"metadata\": { \"title\": \"{{ $json.title }}\" }\n}",
        "options": {
          "response": {
            "response": {
              "neverError": true,
              "fullResponse": true
            }
          }
        }
      },
      "id": "a1b2c3d4-0003-4a00-8000-000000000003",
      "name": "Commit booking (AgentDraft)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [700, 320]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "c0000000-0000-4000-8000-000000000020",
              "leftValue": "={{ $json.statusCode }}",
              "rightValue": 201,
              "operator": {
                "type": "number",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a1b2c3d4-0004-4a00-8000-000000000004",
      "name": "Committed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [940, 320]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d0000000-0000-4000-8000-000000000030",
              "name": "result",
              "value": "=Booked {{ $json.body.booking_id }} (status {{ $json.body.status }})",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-0005-4a00-8000-000000000005",
      "name": "Booked",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [1180, 220]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d0000000-0000-4000-8000-000000000031",
              "name": "result",
              "value": "=Outranked by agent {{ $json.body.winning_agent_id }} (priority {{ $json.body.winning_agent_priority }}) — pick another slot",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-0006-4a00-8000-000000000006",
      "name": "Outranked — try another slot",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [1180, 420]
    }
  ],
  "connections": {
    "When clicking 'Execute workflow'": {
      "main": [[{ "node": "Booking details", "type": "main", "index": 0 }]]
    },
    "Booking details": {
      "main": [[{ "node": "Commit booking (AgentDraft)", "type": "main", "index": 0 }]]
    },
    "Commit booking (AgentDraft)": {
      "main": [[{ "node": "Committed?", "type": "main", "index": 0 }]]
    },
    "Committed?": {
      "main": [
        [{ "node": "Booked", "type": "main", "index": 0 }],
        [{ "node": "Outranked — try another slot", "type": "main", "index": 0 }]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "settings": {
    "executionOrder": "v1"
  }
}
