{
  "name": "10 · Finance & Ops / Invoice OCR → Approval → Pay",
  "active": false,
  "nodes": [
    {
      "id": "fa1dfa17-88c2-4d41-a54c-c6a17875cfd2",
      "name": "📘 Guide",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        -120
      ],
      "parameters": {
        "content": "## 10 · Finance & Ops · Invoice OCR → Approval → Pay\n\n### What this does\nIngests invoice file/URL, extracts fields, policy-checks, routes approval, then payment stub.\n\n### Setup checklist\n1. OCR/LLM extract\n2. Approver map\n3. Bill pay API\n\n### How to test locally\nPOST `fin-invoice` with `{ \"invoiceUrl\":\"...\", \"vendor\":\"...\" }`\n\n### Tips\n- Keep credentials in n8n Credentials (never hardcode secrets).\n- Use **Test URL** on the Webhook while developing.\n- Activate only after credentials + destinations are configured.\n",
        "width": 560,
        "height": 560,
        "color": 3
      }
    },
    {
      "id": "f7859090-0d89-4368-bbfc-dcee0249cdc3",
      "name": "⚙️ Config",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        480
      ],
      "parameters": {
        "content": "## Config map\n\n- **Webhook path:** `fin-invoice`\n- **Replace** all `https://httpbin.org/...` calls with real integrations.\n- **Credentials:** create in n8n → Credentials, then select on HTTP nodes.\n- **Activate** workflow only after a successful Test execution.\n\n### Local files\nShared host folder is mounted at `/files` inside n8n.",
        "width": 560,
        "height": 320,
        "color": 2
      }
    },
    {
      "id": "5c0c0169-863b-4225-8779-78fa5a38f609",
      "name": "Intake Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        200
      ],
      "webhookId": "6b7cd32a-1b3e-4962-8983-36ab7c526efa",
      "parameters": {
        "httpMethod": "POST",
        "path": "fin-invoice",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "id": "e624c480-3e79-4ec8-a592-0d51c40f1a7a",
      "name": "Validate & Risk Score",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        280,
        200
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const body = $input.first().json.body || $input.first().json;\nconst risk = Number(body.riskScore ?? (String(body.caption||body.copy||'').match(/guarantee|free money|urgent/i) ? 80 : 20));\nconst approved = risk < 60 || body.token === 'APPROVE' || body.autoApprove === true;\nreturn [{ json: { ...body, risk, approved, decision: approved ? 'pass' : 'hold' } }];"
      }
    },
    {
      "id": "62999e9c-526d-4aa8-b801-767f8751b0cb",
      "name": "Approved?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        560,
        200
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "fc11d4a4-a73e-4729-bd1c-5de57292d58b",
              "leftValue": "={{ $json.approved }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "04f0672d-30e0-492f-a044-01d9368b9b82",
      "name": "Execute Action",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        840,
        80
      ],
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "options": {},
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}"
      }
    },
    {
      "id": "5fe1f6e0-2b73-432a-bcae-5a5bcf39171b",
      "name": "Hold for Review",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        840,
        320
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "status",
              "value": "pending_approval",
              "type": "string"
            },
            {
              "id": "2",
              "name": "next",
              "value": "Send APPROVE token to resume / approve path",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "017f22ac-ca69-40a7-adce-5b3519b6ef4e",
      "name": "Webhook Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1120,
        200
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {}
      }
    }
  ],
  "connections": {
    "Intake Webhook": {
      "main": [
        [
          {
            "node": "Validate & Risk Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate & Risk Score": {
      "main": [
        [
          {
            "node": "Approved?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approved?": {
      "main": [
        [
          {
            "node": "Execute Action",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Hold for Review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Action": {
      "main": [
        [
          {
            "node": "Webhook Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hold for Review": {
      "main": [
        [
          {
            "node": "Webhook Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "tags": [],
  "meta": {
    "templateCredsSetupCompleted": true,
    "description": "Ingests invoice file/URL, extracts fields, policy-checks, routes approval, then payment stub."
  },
  "pinData": {}
}