{
  "name": "AHF 03 - Approval and Supplier Follow-up",
  "nodes": [
    {
      "parameters": {"httpMethod":"POST","path":"ahf-followup-approval","responseMode":"responseNode","options":{}},
      "id": "6cb22f96-7fef-4bc1-baea-aa193007271e",
      "name": "Approval Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [-520, 0],
      "webhookId": "ahf-followup-approval"
    },
    {
      "parameters": {"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"e824fb9d-b286-473a-91cd-a60fe67a955d","leftValue":"={{ ($json.body ?? $json).approved }}","rightValue":true,"operator":{"type":"boolean","operation":"true","singleValue":true}}],"combinator":"and"},"options":{}},
      "id": "4ec7cdbb-6de7-45f8-b8c5-7c06e7a16683",
      "name": "Human Approved?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [-260, 0]
    },
    {
      "parameters": {"jsCode":"const body = $json.body ?? $json;\nconst draft = body.supplier_email ?? {};\nreturn [{ json: {\n  status: 'approved_demo',\n  outbound_channel: 'email_draft',\n  subject: String(draft.subject ?? 'AHF reconciliation follow-up').slice(0, 160),\n  body: String(draft.body ?? '').slice(0, 4000),\n  audit: { approved_by: String(body.approved_by ?? 'Portfolio reviewer').slice(0, 80), approved_at: new Date().toISOString() },\n  note: 'Connect an email node only after credentials and recipient controls are configured.'\n} }];"},
      "id": "79ded732-e130-499e-8695-6ad2aacdb3c8",
      "name": "Prepare Approved Draft",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [20, -80]
    },
    {
      "parameters": {"jsCode":"return [{ json: { status: 'blocked', outbound_action_blocked: true, reason: 'Explicit human approval is required before supplier follow-up.' } }];"},
      "id": "47cb6f12-98ed-4aad-9434-297f1119bbf8",
      "name": "Block Outbound Action",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [20, 100]
    },
    {
      "parameters": {"respondWith":"json","responseBody":"={{ $json }}","options":{}},
      "id": "bc0effbd-44f0-45ce-8496-2d0d7450355e",
      "name": "Return Approval Result",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [320, 0]
    }
  ],
  "pinData": {},
  "connections": {
    "Approval Webhook": {"main":[[{"node":"Human Approved?","type":"main","index":0}]]},
    "Human Approved?": {"main":[[{"node":"Prepare Approved Draft","type":"main","index":0}],[{"node":"Block Outbound Action","type":"main","index":0}]]},
    "Prepare Approved Draft": {"main":[[{"node":"Return Approval Result","type":"main","index":0}]]},
    "Block Outbound Action": {"main":[[{"node":"Return Approval Result","type":"main","index":0}]]}
  },
  "active": false,
  "settings": {"executionOrder":"v1"},
  "versionId": "d31c715f-289c-4729-9bbb-37836f6831d0",
  "meta": {"templateCredsSetupCompleted": true},
  "tags": []
}
