{
  "name": "03 - Triage & Enrichment",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "triage-trigger",
        "responseMode": "lastNode"
      },
      "id": "triage-webhook",
      "name": "Triage Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.APP_URL}}/api/n8n/triage/classify",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$env.N8N_API_KEY}}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "enquiryId",
              "value": "={{ $json.body.enquiryId }}"
            }
          ]
        },
        "options": {
          "timeout": 30000
        }
      },
      "id": "classify-urgency",
      "name": "Classify Urgency",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.data.needsMoreInfo }}",
              "value2": true
            }
          ]
        }
      },
      "id": "check-missing-info",
      "name": "Check Missing Information",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.APP_URL}}/api/n8n/missing-info/follow-up",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$env.N8N_API_KEY}}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "visitRequestId",
              "value": "={{ $('Classify Urgency').item.json.data.visitRequestId }}"
            }
          ]
        },
        "options": {
          "timeout": 30000
        }
      },
      "id": "send-follow-up",
      "name": "Send Follow-Up",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        850,
        200
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "status",
              "value": "ready"
            },
            {
              "name": "message",
              "value": "Enquiry classified and ready for planning"
            },
            {
              "name": "visitRequestId",
              "value": "={{ $('Classify Urgency').item.json.data.visitRequestId }}"
            },
            {
              "name": "planningStatus",
              "value": "={{ $('Classify Urgency').item.json.data.planningStatus }}"
            }
          ]
        },
        "options": {}
      },
      "id": "set-ready-status",
      "name": "Ready for Planning",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        850,
        400
      ]
    }
  ],
  "connections": {
    "Triage Trigger": {
      "main": [
        [
          {
            "node": "Classify Urgency",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Urgency": {
      "main": [
        [
          {
            "node": "Check Missing Information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Missing Information": {
      "main": [
        [
          {
            "node": "Send Follow-Up",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Ready for Planning",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "phase4"
    },
    {
      "name": "phase12c"
    }
  ]
}