{
  "name": "Zero-Fluff Ops #008 — 2-Tier AI Model Router (79% Token Cut)",
  "flow": [
    {
      "id": 1,
      "module": "gateway:CustomWebHook",
      "version": 1,
      "parameters": {
        "hook": "inbound-lead-or-ticket-webhook"
      },
      "metadata": {
        "designer": { "x": 0, "y": 0 },
        "notes": "Step 1: Receive inbound email, form, or support webhook."
      }
    },
    {
      "id": 2,
      "module": "http:ActionSendData",
      "version": 3,
      "filter": {
        "name": "Drop 40% Noise ($0 Token Filter)",
        "conditions": [
          [
            { "a": "{{lower(1.sender_email)}}", "b": "no-reply", "o": "text:notcontain" },
            { "a": "{{lower(1.sender_email)}}", "b": "mailer-daemon", "o": "text:notcontain" },
            { "a": "{{length(1.body)}}", "b": "30", "o": "number:greater" }
          ]
        ]
      },
      "mapper": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent",
        "method": "post",
        "headers": [
          { "name": "Content-Type", "value": "application/json" },
          { "name": "x-goog-api-key", "value": "{{env.GEMINI_API_KEY}}" }
        ],
        "bodyType": "raw",
        "contentType": "application/json",
        "data": "{\"contents\":[{\"parts\":[{\"text\":\"Return strict JSON {intent, priority, confidence, draft_reply} for: {{1.subject}} - {{1.body}}\"}]}]}"
      },
      "metadata": {
        "designer": { "x": 300, "y": 0 },
        "notes": "Step 2 & 3: Early noise filter + Fast-tier Flash/Mini JSON classifier."
      }
    },
    {
      "id": 3,
      "module": "builtin:BasicRouter",
      "version": 1,
      "routes": [
        {
          "flow": [
            {
              "id": 4,
              "module": "notion:createDatabaseItem",
              "version": 1,
              "filter": {
                "name": "80% Routine Path (Confidence >= 85)",
                "conditions": [
                  [
                    { "a": "{{2.data.confidence}}", "b": "85", "o": "number:greaterequal" },
                    { "a": "{{2.data.priority}}", "b": "high", "o": "text:notequal" }
                  ]
                ]
              },
              "mapper": {
                "database": "{{env.NOTION_APPROVAL_DB_ID}}",
                "properties": {
                  "Subject": "{{1.subject}}",
                  "Status": "Needs Review",
                  "ModelTier": "Fast (Flash/Mini)",
                  "DraftReply": "{{2.data.draft_reply}}"
                }
              }
            }
          ]
        },
        {
          "flow": [
            {
              "id": 5,
              "module": "http:ActionSendData",
              "version": 3,
              "filter": {
                "name": "20% Frontier Escalation (VIP or Low Confidence)",
                "conditions": [
                  [
                    { "a": "{{2.data.priority}}", "b": "high", "o": "text:equal" }
                  ],
                  [
                    { "a": "{{2.data.confidence}}", "b": "85", "o": "number:less" }
                  ]
                ]
              },
              "mapper": {
                "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-4-argon:generateContent",
                "method": "post",
                "headers": [
                  { "name": "Content-Type", "value": "application/json" },
                  { "name": "x-goog-api-key", "value": "{{env.GEMINI_API_KEY}}" }
                ],
                "bodyType": "raw",
                "contentType": "application/json",
                "data": "{\"contents\":[{\"parts\":[{\"text\":\"Draft a high-precision executive reply with full SOP context for: {{1.subject}} - {{1.body}}\"}]}]}"
              }
            },
            {
              "id": 6,
              "module": "notion:createDatabaseItem",
              "version": 1,
              "mapper": {
                "database": "{{env.NOTION_APPROVAL_DB_ID}}",
                "properties": {
                  "Subject": "{{1.subject}}",
                  "Status": "Needs Review (VIP)",
                  "ModelTier": "Frontier (Gemini 4)",
                  "DraftReply": "{{5.data.candidates[0].content.parts[0].text}}"
                }
              }
            }
          ]
        }
      ],
      "metadata": {
        "designer": { "x": 600, "y": 0 }
      }
    }
  ],
  "metadata": {
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "sequential": false
    },
    "author": "Zero-Fluff Ops (zerofluffops.com)"
  }
}
