{
  "name": "Zero-Fluff Ops #007 — BYO-Key ClickUp AI Triage Gateway (n8n)",
  "nodes": [
    {
      "parameters": {
        "path": "clickup-task-triage",
        "httpMethod": "POST",
        "responseMode": "lastNode"
      },
      "id": "clickup-webhook",
      "name": "ClickUp taskCreated Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [200, 300]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ ($json.body.name || '').length > 6 && !$json.body.parent && !$json.body.creator_is_bot }}",
              "value2": true
            }
          ]
        }
      },
      "id": "early-noise-filter",
      "name": "Early Zero-Cost Filter",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [440, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/chat/completions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'gpt-4o-mini', response_format: { type: 'json_object' }, messages: [ { role: 'system', content: 'Return strict JSON: {priority: urgent|high|normal, owner_team: ops|eng|support, summary_one_line: string}' }, { role: 'user', content: 'Title: ' + $json.body.name + ' | Description: ' + ($json.body.description || '') } ] }) }}"
      },
      "id": "byo-llm-classifier",
      "name": "BYO LLM Triage Classifier",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [680, 280]
    },
    {
      "parameters": {
        "jsCode": "const parsed = JSON.parse($json.choices[0].message.content);\nconst orig = $('ClickUp taskCreated Webhook').first().json.body;\nreturn [{ json: { task_id: orig.task_id, name: orig.name, priority: parsed.priority, owner_team: parsed.owner_team, summary_one_line: parsed.summary_one_line, tokens_used: $json.usage?.total_tokens || 0, workflow_version: 'v1.0-issue-007' } }];"
      },
      "id": "parse-and-tag",
      "name": "Parse JSON & Attach Audit Meta",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [920, 280]
    },
    {
      "parameters": {
        "resource": "task",
        "operation": "update",
        "id": "={{ $json.task_id }}",
        "updateFields": {
          "priority": "={{ $json.priority === 'urgent' ? 1 : ($json.priority === 'high' ? 2 : 3) }}"
        }
      },
      "id": "clickup-update-task",
      "name": "ClickUp Update Priority (0 Credits)",
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [1160, 280]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $('Parse JSON & Attach Audit Meta').first().json.priority }}",
              "operation": "equal",
              "value2": "urgent"
            }
          ]
        }
      },
      "id": "urgent-switch",
      "name": "Is Urgent?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [1400, 280]
    },
    {
      "parameters": {
        "channel": "YOUR_OPS_ALERTS_CHANNEL_ID",
        "text": "={{ 'Urgent ClickUp Task [' + $('Parse JSON & Attach Audit Meta').first().json.owner_team + ']: ' + $('Parse JSON & Attach Audit Meta').first().json.name + ' — ' + $('Parse JSON & Attach Audit Meta').first().json.summary_one_line }}"
      },
      "id": "slack-alert",
      "name": "Slack Urgent Escalation",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2,
      "position": [1640, 180]
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "create",
        "databaseId": "YOUR_AUDIT_LOG_DATABASE_ID"
      },
      "id": "audit-log",
      "name": "Write AI Audit & Token Log",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2,
      "position": [1640, 380]
    }
  ],
  "connections": {
    "ClickUp taskCreated Webhook": {
      "main": [[{ "node": "Early Zero-Cost Filter", "type": "main", "index": 0 }]]
    },
    "Early Zero-Cost Filter": {
      "main": [[{ "node": "BYO LLM Triage Classifier", "type": "main", "index": 0 }], []]
    },
    "BYO LLM Triage Classifier": {
      "main": [[{ "node": "Parse JSON & Attach Audit Meta", "type": "main", "index": 0 }]]
    },
    "Parse JSON & Attach Audit Meta": {
      "main": [[{ "node": "ClickUp Update Priority (0 Credits)", "type": "main", "index": 0 }]]
    },
    "ClickUp Update Priority (0 Credits)": {
      "main": [[{ "node": "Is Urgent?", "type": "main", "index": 0 }]]
    },
    "Is Urgent?": {
      "main": [
        [
          { "node": "Slack Urgent Escalation", "type": "main", "index": 0 },
          { "node": "Write AI Audit & Token Log", "type": "main", "index": 0 }
        ],
        [{ "node": "Write AI Audit & Token Log", "type": "main", "index": 0 }]
      ]
    }
  }
}
