{
 "id": "FLUXIEL-DEMO3-INTAKE",
 "name": "Fluxiel Démo 3 — Traitement administratif avec validation humaine",
 "nodes": [
  {
   "parameters": {
    "content": "## Démo 3 — Traitement administratif + validation humaine\n\n1. Upload d'un PDF sur le webhook `documents-admin`.\n2. **admin-api** (`ADMIN_API_URL/classer`) : OCR/texte, classification, extraction de champs, score de confiance.\n3. Confiance ≥ seuil → classement automatique (`/dossiers`).\n4. Sinon → création d'une validation humaine (`/validations`) ; revue via `ADMIN_API_URL/validations/ui`.\n5. La décision humaine déclenche le workflow « Fluxiel Démo 3 — Reprise après validation ».\n\nVariables : voir `.env.example`.",
    "height": 420,
    "width": 420
   },
   "id": "note-intro",
   "name": "Note explicative",
   "type": "n8n-nodes-base.stickyNote",
   "typeVersion": 1,
   "position": [
    200,
    40
   ]
  },
  {
   "parameters": {
    "httpMethod": "POST",
    "path": "documents-admin",
    "responseMode": "responseNode",
    "options": {
     "binaryData": true
    }
   },
   "id": "webhook-upload",
   "name": "Webhook upload document",
   "type": "n8n-nodes-base.webhook",
   "typeVersion": 2,
   "position": [
    240,
    320
   ],
   "webhookId": "fluxiel-demo3-upload"
  },
  {
   "parameters": {
    "method": "POST",
    "url": "={{ $env.ADMIN_API_URL || 'http://127.0.0.1:8103' }}/classer",
    "sendBody": true,
    "contentType": "multipart-form-data",
    "bodyParameters": {
     "parameters": [
      {
       "name": "fichier",
       "parameterType": "formBinaryData",
       "inputDataFieldName": "fichier"
      }
     ]
    },
    "options": {
     "timeout": 120000
    }
   },
   "id": "classer",
   "name": "Classer (admin-api)",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    460,
    320
   ]
  },
  {
   "parameters": {
    "conditions": {
     "options": {
      "caseSensitive": true,
      "leftValue": "",
      "typeValidation": "loose"
     },
     "conditions": [
      {
       "id": "cond-auto",
       "leftValue": "={{ $json.statut }}",
       "rightValue": "qualifie_auto",
       "operator": {
        "type": "string",
        "operation": "equals"
       }
      }
     ],
     "combinator": "and"
    },
    "options": {}
   },
   "id": "si-auto",
   "name": "Confiance suffisante ?",
   "type": "n8n-nodes-base.if",
   "typeVersion": 2.2,
   "position": [
    680,
    320
   ]
  },
  {
   "parameters": {
    "method": "POST",
    "url": "={{ $env.ADMIN_API_URL || 'http://127.0.0.1:8103' }}/dossiers",
    "sendBody": true,
    "specifyBody": "json",
    "jsonBody": "={{ { document_id: $json.document_id, fichier: $json.fichier, type_document: $json.type_document, champs: $json.champs, decision: 'qualifie_auto', chemin_stocke: $json.chemin_stocke } }}",
    "options": {}
   },
   "id": "classer-auto",
   "name": "Classer automatiquement",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    900,
    220
   ]
  },
  {
   "parameters": {
    "respondWith": "json",
    "responseBody": "={{ { statut: 'qualifie_auto', document_id: $json.document_id } }}",
    "options": {}
   },
   "id": "repondre-auto",
   "name": "Répondre (qualifié auto)",
   "type": "n8n-nodes-base.respondToWebhook",
   "typeVersion": 1.4,
   "position": [
    1120,
    220
   ]
  },
  {
   "parameters": {
    "method": "POST",
    "url": "={{ $env.ADMIN_API_URL || 'http://127.0.0.1:8103' }}/validations",
    "sendBody": true,
    "specifyBody": "json",
    "jsonBody": "={{ { document_id: $json.document_id, fichier: $json.fichier, type_document: $json.type_document, confiance: $json.confiance, champs: $json.champs, chemin_stocke: $json.chemin_stocke } }}",
    "options": {}
   },
   "id": "creer-validation",
   "name": "Créer une validation humaine",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    900,
    440
   ]
  },
  {
   "parameters": {
    "respondWith": "json",
    "responseBody": "={{ { statut: 'en_attente_validation_humaine', validation_id: $json.validation_id, url_revue: ($env.ADMIN_API_URL || 'http://127.0.0.1:8103') + '/validations/ui' } }}",
    "options": {}
   },
   "id": "repondre-attente",
   "name": "Répondre (en attente humaine)",
   "type": "n8n-nodes-base.respondToWebhook",
   "typeVersion": 1.4,
   "position": [
    1120,
    440
   ]
  }
 ],
 "connections": {
  "Webhook upload document": {
   "main": [
    [
     {
      "node": "Classer (admin-api)",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Classer (admin-api)": {
   "main": [
    [
     {
      "node": "Confiance suffisante ?",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Confiance suffisante ?": {
   "main": [
    [
     {
      "node": "Classer automatiquement",
      "type": "main",
      "index": 0
     }
    ],
    [
     {
      "node": "Créer une validation humaine",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Classer automatiquement": {
   "main": [
    [
     {
      "node": "Répondre (qualifié auto)",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Créer une validation humaine": {
   "main": [
    [
     {
      "node": "Répondre (en attente humaine)",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "errorWorkflow": "WF-ERREUR-DEMO3",
  "timezone": "Europe/Paris",
  "saveDataErrorExecution": "all"
 },
 "tags": [
  {
   "name": "fluxiel-demo"
  }
 ]
}