{
  "name": "GDPR-Compliant AI Document Sanitizer & EU AI Act Governance Gatekeeper",
  "nodes": [
    {
      "parameters": {
        "content": "## 🛡️ GDPR AI Document Sanitizer & EU AI Act Gatekeeper\n**Zero-Data-Retention PII Redaction, Synthetic Masking & Regulatory Risk Classification**\n\n### 🚀 Quick Setup:\n1. **Install Node**: In n8n, go to **Settings > Community Nodes** and install `n8n-nodes-lexgrid`.\n2. **Credentials**: Add **LexGrid API** credentials with your key from [lexgrid.novapixel.it](https://lexgrid.novapixel.it) (or leave empty for daily free trial quota).\n3. **Test Immediately**: Open the **Form Trigger** and click **Open Form**, or run **Test workflow** — realistic default text with Italian PII (Codice Fiscale, IBAN, Email, Phone) is pre-configured!\n\n### 🏢 Real-World Enterprise Integrations:\n• **Dual Ingestion**: Interactive portal for employees + automated REST Webhook for DMS/ERP.\n• **Sovereign PII Scrubber**: Irreversibly masks sensitive personal identifiers in volatile RAM (< 50ms).\n• **EU AI Act Classifier**: Audits downstream AI models under Regulation (EU) 2024/1689 (Art. 50).\n• **Multi-Channel Dispatch**: Automated Slack alert to DPO, AI prompt execution, and audit logging.",
        "height": 640,
        "width": 400,
        "color": 6
      },
      "id": "22222222-0000-4000-8000-000000000000",
      "name": "Sticky Note - Setup & Enterprise Guide",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -280,
        80
      ]
    },
    {
      "parameters": {
        "content": "### 1. Ingestion Layer\nSupports **dual-mode entry**:\n- **n8n Form**: Interactive document upload for employees & legal teams.\n- **REST Webhook**: Direct programmatic API ingestion from DMS, CRM, or HR software.",
        "height": 480,
        "width": 320,
        "color": 7
      },
      "id": "22222222-0010-4000-8000-000000000010",
      "name": "Sticky Note - Step 1 Ingestion",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        160,
        80
      ]
    },
    {
      "parameters": {
        "content": "### 2. In-Memory PII Scrubbing\nIrreversibly scrubs **Codici Fiscali, IBANs, Emails, and Phone Numbers** in volatile RAM (Zero-Data-Retention) and issues a cryptographic SHA-256 redaction seal.",
        "height": 480,
        "width": 360,
        "color": 4
      },
      "id": "22222222-0011-4000-8000-000000000011",
      "name": "Sticky Note - Step 2 PII De-identification",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        520,
        80
      ]
    },
    {
      "parameters": {
        "content": "### 3. EU AI Act Governance Gate\nClassifies the automated AI workflow under **Regulation (EU) 2024/1689**, evaluating risk tier, transparency requirements (Art. 50), and human oversight obligations.",
        "height": 480,
        "width": 520,
        "color": 5
      },
      "id": "22222222-0012-4000-8000-000000000012",
      "name": "Sticky Note - Step 3 AI Governance",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        920,
        80
      ]
    },
    {
      "parameters": {
        "content": "### 4. Decision Matrix & Safe AI Dispatch\n- **Approved AI Path**: Dispatches sanitized, GDPR-safe prompt to external LLM (OpenAI / Claude / Mistral) and posts audit proof to Slack `#ai-governance`.\n- **High Risk Escalation**: Flags unapproved high-risk models to DPO `#dpo-compliance-watchdog`.",
        "height": 580,
        "width": 560,
        "color": 3
      },
      "id": "22222222-0013-4000-8000-000000000013",
      "name": "Sticky Note - Step 4 Safe AI Execution",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1480,
        80
      ]
    },
    {
      "parameters": {
        "path": "confidential-document-portal",
        "formTitle": "🛡️ Enterprise GDPR AI Document Sanitizer",
        "formDescription": "Upload or paste confidential text for automated in-memory PII de-identification, EU AI Act risk tier verification, and safe LLM prompt synthesis.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Document Title",
              "defaultValue": "Confidential Settlement & Severance Agreement",
              "requiredField": true
            },
            {
              "fieldLabel": "Department",
              "defaultValue": "Legal & Human Resources",
              "requiredField": true
            },
            {
              "fieldLabel": "DPO / Auditor Email",
              "defaultValue": "dpo@enterprise.eu",
              "fieldType": "email",
              "requiredField": true
            },
            {
              "fieldLabel": "Target AI Model",
              "defaultValue": "OpenAI GPT-4o / Anthropic Claude 3.5",
              "requiredField": true
            },
            {
              "fieldLabel": "Confidential Document Text",
              "defaultValue": "Il dipendente Mario Rossi, nato a Roma, Codice Fiscale RSSMRA85M01H501Z, titolare di conto corrente con IBAN IT60X0542811101000000123456, raggiungibile al telefono +39 02 9876543 ed email mario.rossi@azienda.it, accetta l'accordo di risoluzione consensuale con liquidazione di 25.000 €.",
              "fieldType": "textarea",
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "id": "22222222-0001-4000-8000-000000000001",
      "name": "Form Trigger - Interactive Document Portal",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.1,
      "position": [
        200,
        180
      ],
      "webhookId": "confidential-document-portal"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "analyze-document-gdpr",
        "responseMode": "onReceived",
        "options": {}
      },
      "id": "22222222-0002-4000-8000-000000000002",
      "name": "Webhook - DMS / ERP Ingestion",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        200,
        380
      ],
      "webhookId": "analyze-document-gdpr"
    },
    {
      "parameters": {
        "jsCode": "// Normalize input whether coming from the interactive Form or automated REST Webhook\nconst raw = $json.body || $json;\n\nreturn [{\n  json: {\n    documentTitle: raw['Document Title'] || raw.documentTitle || 'Confidential Enterprise Document',\n    department: raw['Department'] || raw.department || 'Legal & Compliance',\n    dpoEmail: raw['DPO / Auditor Email'] || raw.dpoEmail || 'dpo@enterprise.eu',\n    targetModel: raw['Target AI Model'] || raw.targetModel || 'OpenAI GPT-4o',\n    textToScrub: raw['Confidential Document Text'] || raw.documentText || raw.text || 'Mario Rossi, Codice Fiscale RSSMRA85M01H501Z, IBAN IT60X0542811101000000123456, email mario.rossi@example.com, tel +39 02 1234567.',\n    timestamp: new Date().toISOString()\n  }\n}];"
      },
      "id": "22222222-0003-4000-8000-000000000003",
      "name": "Code - Normalize Document Input",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        380,
        280
      ]
    },
    {
      "parameters": {
        "resource": "universalTool",
        "suiteId": "sovereign-pii",
        "toolName": "eu_pii_scrubber_anonymizer",
        "payloadJson": "={\n  \"text\": {{ JSON.stringify($json.textToScrub) }}\n}"
      },
      "id": "22222222-0004-4000-8000-000000000004",
      "name": "LexGrid - Sovereign PII Scrubber",
      "type": "n8n-nodes-lexgrid.lexGrid",
      "typeVersion": 1,
      "position": [
        560,
        280
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "cond-has-scrubbed-text",
              "leftValue": "={{ $json.data.scrubbedText || $json.data.maskedText }}",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "22222222-0005-4000-8000-000000000005",
      "name": "IF - PII Successfully Masked?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        740,
        280
      ]
    },
    {
      "parameters": {
        "resource": "universalTool",
        "suiteId": "sovereign-pii",
        "toolName": "ai_act_risk_tier_classifier",
        "payloadJson": "={\n  \"systemName\": \"Enterprise Document Summarizer\",\n  \"useCaseDomain\": \"CUSTOMER_SERVICE_CHATBOT\",\n  \"systemDescription\": \"Automated document summarization and contract extraction for EU enterprises\",\n  \"hasHumanInTheLoopOversight\": true,\n  \"isDirectInteractionWithHumans\": true\n}"
      },
      "id": "22222222-0006-4000-8000-000000000006",
      "name": "LexGrid - EU AI Act Risk Classifier",
      "type": "n8n-nodes-lexgrid.lexGrid",
      "typeVersion": 1,
      "position": [
        960,
        200
      ]
    },
    {
      "parameters": {
        "jsCode": "const initial = $('Code - Normalize Document Input').item.json;\nconst pii = $('LexGrid - Sovereign PII Scrubber').item.json;\nconst aiAct = $('LexGrid - EU AI Act Risk Classifier').item.json;\n\nconst scrubbed = pii.data?.scrubbedText || pii.data?.maskedText || '';\nconst entities = pii.data?.entitiesDetected || pii.data?.detectedEntities || pii.data?.redactedCounts || {};\nconst riskTier = aiAct.data?.riskTier || aiAct.data?.riskCategory || 'MINIMAL_OR_NO_RISK';\n\nreturn [{\n  json: {\n    documentTitle: initial.documentTitle,\n    department: initial.department,\n    dpoEmail: initial.dpoEmail,\n    targetModel: initial.targetModel,\n    sanitizedText: scrubbed,\n    safeAiPrompt: `Analizza e riassumi il seguente documento aziendale de-identificato (privo di PII ex GDPR):\\n\\n${scrubbed}`,\n    redactedEntitiesCount: Object.keys(entities).length,\n    redactedEntitiesDetails: entities,\n    gdprProofId: pii._audit_meta?.certificate_id || 'LG-PII-CERT',\n    gdprVerificationUrl: pii._audit_meta?.verification_url || 'https://lexgrid.novapixel.it/verify',\n    aiActRiskTier: riskTier,\n    aiActObligations: aiAct.data?.mandatoryObligations || ['Article 50 Transparency notice', 'Human oversight'],\n    aiActCertificateId: aiAct._audit_meta?.certificate_id,\n    aiActVerificationUrl: aiAct._audit_meta?.verification_url,\n    governanceStatus: riskTier === 'HIGH_RISK' ? 'MANUAL_DPO_OVERSIGHT_REQUIRED' : 'APPROVED_FOR_SAFE_LLM',\n    zeroDataRetentionGuaranteed: true,\n    timestamp: new Date().toISOString()\n  }\n}];"
      },
      "id": "22222222-0007-4000-8000-000000000007",
      "name": "Code - Synthesize AI Governance Dossier",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1180,
        200
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "cond-safe-llm",
                    "leftValue": "={{ $json.governanceStatus }}",
                    "rightValue": "APPROVED_FOR_SAFE_LLM",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extraPath"
        }
      },
      "id": "22222222-0008-4000-8000-000000000008",
      "name": "Switch - Governance Compliance Gate",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        1380,
        200
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"channel\": \"#ai-governance-feed\",\n  \"username\": \"LexGrid GDPR Sentry\",\n  \"icon_emoji\": \":shield:\",\n  \"text\": \"🛡️ *CONFIDENTIAL DOCUMENT SANITIZED & APPROVED FOR AI*\\n• *Document*: {{ $json.documentTitle }} ({{ $json.department }})\\n• *Entities Redacted*: {{ $json.redactedEntitiesCount }} (Codici Fiscali, IBANs, Emails, Phones)\\n• *AI Act Risk Tier*: {{ $json.aiActRiskTier }} (🟢 Minimal Risk)\\n• *Target Model*: {{ $json.targetModel }}\\n• *GDPR Audit Proof*: <{{ $json.gdprVerificationUrl }}|Inspect Cryptographic Seal>\"\n}",
        "options": {}
      },
      "id": "22222222-0009-4000-8000-000000000009",
      "name": "Slack - Notify Legal & AI Audit Channel",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1620,
        120
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"gpt-4o\",\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are a legal assistant analyzing de-identified corporate documents. All PII has been replaced with cryptographic tokens under GDPR.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"{{ $json.safeAiPrompt }}\"\n    }\n  ],\n  \"temperature\": 0.2\n}",
        "options": {}
      },
      "id": "22222222-0014-4000-8000-000000000014",
      "name": "LLM Dispatch - Execute Safe AI Completion",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1620,
        240
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"channel\": \"#dpo-compliance-watchdog\",\n  \"username\": \"LexGrid AI Act Watchdog\",\n  \"icon_emoji\": \":rotating_light:\",\n  \"text\": \"⚠️ *AI GOVERNANCE ESCALATION REQUIRED*\\n• *Document*: {{ $json.documentTitle }}\\n• *Risk Tier*: {{ $json.aiActRiskTier }} (⚠️ High Risk)\\n• *Mandatory Duties*: {{ $json.aiActObligations.join(', ') }}\\n• *Action*: Automated LLM transmission paused pending human DPO approval.\\n• *Regulatory Certificate*: <{{ $json.aiActVerificationUrl }}|View Regulatory Assessment>\"\n}",
        "options": {}
      },
      "id": "22222222-0015-4000-8000-000000000015",
      "name": "Slack - High-Priority DPO Escalation Alert",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1620,
        380
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"channel\": \"#dpo-compliance-watchdog\",\n  \"username\": \"LexGrid PII Sanitizer\",\n  \"icon_emoji\": \":x:\",\n  \"text\": \"❌ *DOCUMENT PII SANITIZATION FAILED*\\n• *Document*: {{ $('Code - Normalize Document Input').item.json.documentTitle }}\\n• *Reason*: Unable to extract clean text or memory error during scrubbing.\\n• *Action*: Blocked transmission to external AI.\"\n}",
        "options": {}
      },
      "id": "22222222-0016-4000-8000-000000000016",
      "name": "Slack - Alert PII Extraction Error",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        480
      ]
    }
  ],
  "connections": {
    "Form Trigger - Interactive Document Portal": {
      "main": [
        [
          {
            "node": "Code - Normalize Document Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook - DMS / ERP Ingestion": {
      "main": [
        [
          {
            "node": "Code - Normalize Document Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code - Normalize Document Input": {
      "main": [
        [
          {
            "node": "LexGrid - Sovereign PII Scrubber",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LexGrid - Sovereign PII Scrubber": {
      "main": [
        [
          {
            "node": "IF - PII Successfully Masked?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF - PII Successfully Masked?": {
      "main": [
        [
          {
            "node": "LexGrid - EU AI Act Risk Classifier",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Slack - Alert PII Extraction Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LexGrid - EU AI Act Risk Classifier": {
      "main": [
        [
          {
            "node": "Code - Synthesize AI Governance Dossier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code - Synthesize AI Governance Dossier": {
      "main": [
        [
          {
            "node": "Switch - Governance Compliance Gate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch - Governance Compliance Gate": {
      "main": [
        [
          {
            "node": "Slack - Notify Legal & AI Audit Channel",
            "type": "main",
            "index": 0
          },
          {
            "node": "LLM Dispatch - Execute Safe AI Completion",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Slack - High-Priority DPO Escalation Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    "gdpr",
    "pii-scrubber",
    "ai-act",
    "sovereign-ai",
    "lexgrid",
    "document-analysis",
    "enterprise-governance",
    "slack-alerts",
    "openai"
  ]
}