{
  "name": "12 — AI: ekstrakcja pól z dokumentu → arkusz (klinweb.pl)",
  "nodes": [
    {
      "parameters": {
        "content": "## AI: ekstrakcja kluczowych pól z dokumentu\nSzablon KlinWeb. Z PDF (umowa/faktura) AI wyciąga: numer, datę, strony, kwotę, termin — i zapisuje do arkusza. **Wymaga kontroli jakości:** przy niskiej pewności dokument trafia do ręcznej weryfikacji zamiast wprost do bazy.\n\n⚠️ RODO/AI Act: treść dokumentu idzie do modelu. DPA + EU residency obowiązkowe, dokumenty z danymi wrażliwymi — tylko za świadomą zgodą. Oznaczaj wynik jako „wygenerowany przez AI\".",
        "height": 190,
        "width": 880,
        "color": 6
      },
      "id": "note-a5",
      "name": "Sticky Note a5",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -220
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "document-uploaded",
        "responseMode": "onReceived",
        "options": {}
      },
      "id": "n5-webhook",
      "name": "Nowy dokument (Webhook)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "url": "={{ $json.file_url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "n5-http",
      "name": "Pobierz plik",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "text": "={{ $json.data }}",
        "attributes": {
          "attributes": [
            {
              "name": "numer",
              "description": "Numer dokumentu / umowy / faktury",
              "required": true
            },
            {
              "name": "data",
              "description": "Data wystawienia (YYYY-MM-DD)",
              "required": true
            },
            {
              "name": "strony",
              "description": "Strony umowy / kontrahent",
              "required": false
            },
            {
              "name": "kwota",
              "description": "Kwota brutto w PLN (liczba)",
              "required": false
            },
            {
              "name": "termin",
              "description": "Termin płatności / obowiązywania",
              "required": false
            }
          ]
        },
        "options": {}
      },
      "id": "n5-extract",
      "name": "Ekstraktor AI",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1,
      "position": [
        460,
        0
      ]
    },
    {
      "parameters": {
        "model": {
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "id": "n5-llm",
      "name": "Model (OpenAI, EU)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        400,
        220
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "e1",
              "leftValue": "={{ $json.output.numer }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "n5-if",
      "name": "Pewność wystarczająca?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        700,
        0
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "mode": "list",
          "value": "Dokumenty"
        },
        "options": {}
      },
      "id": "n5-sheet",
      "name": "Zapis do arkusza",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        920,
        -100
      ]
    },
    {
      "parameters": {},
      "id": "n5-review",
      "name": "Do weryfikacji ręcznej",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        920,
        120
      ]
    }
  ],
  "connections": {
    "Nowy dokument (Webhook)": {
      "main": [
        [
          {
            "node": "Pobierz plik",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pobierz plik": {
      "main": [
        [
          {
            "node": "Ekstraktor AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ekstraktor AI": {
      "main": [
        [
          {
            "node": "Pewność wystarczająca?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Model (OpenAI, EU)": {
      "ai_languageModel": [
        [
          {
            "node": "Ekstraktor AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Pewność wystarczająca?": {
      "main": [
        [
          {
            "node": "Zapis do arkusza",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Do weryfikacji ręcznej",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "klinweb-n8n-templates-pl"
  },
  "tags": [
    {
      "name": "klinweb.pl"
    },
    {
      "name": "szablon-PL"
    }
  ],
  "pinData": {}
}