{
  "name": "Client request triage (human approval)",
  "nodes": [
    {
      "parameters": {"httpMethod": "POST", "path": "client-request", "responseMode": "lastNode", "options": {}},
      "name": "Webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [0, 0], "webhookId": "client-request-triage"
    },
    {
      "parameters": {
        "method": "POST", "url": "http://localhost:8000/webhook/triage", "sendBody": true, "specifyBody": "json",
        "jsonBody": "={{ { source: $json.body.source || 'form', from_name: $json.body.from_name, subject: $json.body.subject, body: $json.body.body } }}",
        "options": {"timeout": 30000}
      },
      "name": "Triage Service", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [240, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": {"caseSensitive": true, "typeValidation": "loose"},
          "combinator": "or",
          "conditions": [
            {"leftValue": "={{ $json.needs_review }}", "rightValue": true, "operator": {"type": "boolean", "operation": "true", "singleValue": true}},
            {"leftValue": "={{ $json.status }}", "rightValue": "ok", "operator": {"type": "string", "operation": "notEquals"}}
          ]
        }
      },
      "name": "Needs Review?", "type": "n8n-nodes-base.if", "typeVersion": 2.2, "position": [480, 0]
    },
    {
      "parameters": {"assignments": {"assignments": [
        {"id": "a1", "name": "next_step", "type": "string", "value": "Escalate: a person must read the original request before any draft is used"},
        {"id": "a2", "name": "review_url", "type": "string", "value": "http://localhost:8000/runs"},
        {"id": "a3", "name": "run_id", "type": "number", "value": "={{ $json.run_id }}"}
      ]}},
      "name": "Flag For Human", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [720, -100]
    },
    {
      "parameters": {"assignments": {"assignments": [
        {"id": "b1", "name": "next_step", "type": "string", "value": "Draft ready: open the review page and approve or reject. Nothing is sent automatically."},
        {"id": "b2", "name": "review_url", "type": "string", "value": "http://localhost:8000/runs"},
        {"id": "b3", "name": "run_id", "type": "number", "value": "={{ $json.run_id }}"}
      ]}},
      "name": "Queue For Approval", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [720, 100]
    }
  ],
  "connections": {
    "Webhook": {"main": [[{"node": "Triage Service", "type": "main", "index": 0}]]},
    "Triage Service": {"main": [[{"node": "Needs Review?", "type": "main", "index": 0}]]},
    "Needs Review?": {"main": [
      [{"node": "Flag For Human", "type": "main", "index": 0}],
      [{"node": "Queue For Approval", "type": "main", "index": 0}]
    ]}
  },
  "settings": {"executionOrder": "v1"},
  "pinData": {},
  "meta": {"note": "Prototype export. Not imported into a live n8n instance during the build; verify after import. No send/email node on purpose."}
}
