{
  "name": "Sistema Automa\u00e7\u00e3o Jur\u00eddica - Workflow Principal",
  "nodes": [
    {
      "parameters": {},
      "id": "node-1",
      "name": "Webhook - Receber PDF",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "path": "={{$json[\"attachments\"][0][\"url\"]}}"
      },
      "id": "node-2",
      "name": "Google Drive - Buscar PDF",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "http://python-services:5000/extract-pdf",
        "options": {
          "bodyContentType": "json"
        },
        "jsonParameters": true,
        "bodyParametersJson": "={{$json}}"
      },
      "id": "node-3",
      "name": "Python - Extrair Texto PDF",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "http://python-services:5000/firac-analysis",
        "options": {
          "bodyContentType": "json"
        },
        "jsonParameters": true,
        "bodyParametersJson": "={{$json}}"
      },
      "id": "node-4",
      "name": "An\u00e1lise FIRAC",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"analysis_type\"]}}",
              "operation": "equal",
              "value2": "jurisprudence"
            }
          ]
        }
      },
      "id": "node-5",
      "name": "Switch - Tipo de An\u00e1lise",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [
        1120,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "http://python-services:5000/datajud-search",
        "options": {
          "bodyContentType": "json"
        },
        "jsonParameters": true,
        "bodyParametersJson": "={{$json}}"
      },
      "id": "node-6",
      "name": "DATAJUD - Pesquisa Jurisprud\u00eancia",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1340,
        200
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "http://python-services:5000/distinguish-analysis",
        "options": {
          "bodyContentType": "json"
        },
        "jsonParameters": true,
        "bodyParametersJson": "={{$json}}"
      },
      "id": "node-7",
      "name": "An\u00e1lise Distinguish",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1560,
        200
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "http://python-services:5000/generate-document",
        "options": {
          "bodyContentType": "json"
        },
        "jsonParameters": true,
        "bodyParametersJson": "={\"document_type\": \"sentenca\", \"case_data\": $json}"
      },
      "id": "node-8",
      "name": "OpenAI - Gerar Minuta",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1780,
        300
      ]
    },
    {
      "parameters": {
        "resource": "document",
        "operation": "create",
        "title": "Minuta - {{$json[\"case_number\"]}}"
      },
      "id": "node-9",
      "name": "Google Docs - Salvar Minuta",
      "type": "n8n-nodes-base.googleDocs",
      "typeVersion": 1,
      "position": [
        2000,
        300
      ]
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": "YOUR_SHEET_ID",
        "sheetName": "Processos",
        "columnMappings": {
          "processo": "={{$json[\"case_number\"]}}",
          "data": "={{$now}}",
          "status": "={{$json[\"status\"]}}",
          "minuta_link": "={{$json[\"document_url\"]}}"
        }
      },
      "id": "node-10",
      "name": "Google Sheets - Registrar",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        2220,
        300
      ]
    },
    {
      "parameters": {
        "fromEmail": "sistema@seudominio.com",
        "toEmail": "={{$json[\"user_email\"]}}",
        "subject": "An\u00e1lise Processual Conclu\u00edda - {{$json[\"case_number\"]}}",
        "message": "A an\u00e1lise do processo foi conclu\u00edda com sucesso. Documento dispon\u00edvel em: {{$json[\"document_url\"]}}"
      },
      "id": "node-11",
      "name": "Email - Notifica\u00e7\u00e3o",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        2440,
        300
      ]
    }
  ],
  "connections": {
    "Webhook - Receber PDF": {
      "main": [
        [
          {
            "node": "Google Drive - Buscar PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive - Buscar PDF": {
      "main": [
        [
          {
            "node": "Python - Extrair Texto PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Python - Extrair Texto PDF": {
      "main": [
        [
          {
            "node": "An\u00e1lise FIRAC",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "An\u00e1lise FIRAC": {
      "main": [
        [
          {
            "node": "Switch - Tipo de An\u00e1lise",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch - Tipo de An\u00e1lise": {
      "main": [
        [
          {
            "node": "DATAJUD - Pesquisa Jurisprud\u00eancia",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DATAJUD - Pesquisa Jurisprud\u00eancia": {
      "main": [
        [
          {
            "node": "An\u00e1lise Distinguish",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "An\u00e1lise Distinguish": {
      "main": [
        [
          {
            "node": "OpenAI - Gerar Minuta",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Gerar Minuta": {
      "main": [
        [
          {
            "node": "Google Docs - Salvar Minuta",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Docs - Salvar Minuta": {
      "main": [
        [
          {
            "node": "Google Sheets - Registrar",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Registrar": {
      "main": [
        [
          {
            "node": "Email - Notifica\u00e7\u00e3o",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "saveManualExecutions": true,
    "saveDataSuccessExecution": "all",
    "saveDataErrorExecution": "all",
    "saveDataProgressExecution": true
  },
  "staticData": {},
  "tags": [
    "legal",
    "automation",
    "judiciary"
  ],
  "triggerCount": 1,
  "updatedAt": "2025-06-30T11:54:45.441Z",
  "versionId": "1"
}