workflows.fit
Back to n8n workflows
n8n templateFreeBy Mychel Garzon

Extract and classify legal documents with Claude Sonnet and Google Sheets

Stop treating document review as a manual task. Let AI extract, classify, and route every contract, invoice, and NDA automatically. Legal and financial document review is slow, inconsistent, and expensive when done by...

CommunicationHITLCore NodesData & StorageProductivityDevelopmentAILangchain
Loading interactive preview...

Template notes

Stop treating document review as a manual task. Let AI extract, classify, and route every contract, invoice, and NDA automatically.

Legal and financial document review is slow, inconsistent, and expensive when done by hand. This workflow accepts any document via webhook, runs it through Claude Sonnet 4.6 for structured extraction and risk classification, logs the result to a compliance audit sheet, and fires alerts before a human ever opens the file.

---

How it works

The workflow operates in six stages:

1. Ingestion & Early Validation The webhook receives the document payload and immediately validates and deduplicates before responding. Invalid payloads return a 400. Duplicate submissions within a 30-day window (matched by SHA-256 fingerprint) return a 200 without reprocessing. Only clean, unique requests receive a 202 Accepted and continue to processing.

2. Document Acquisition Routes to one of two paths depending on the payload. URL submissions pass through an SSRF guard (blocks private ranges, hex/octal/decimal IP obfuscation, and non-HTTPS schemes), download the file, check it stays under 10 MB, and extract text via PDF parser. Inline text submissions pass directly to the prompt builder.

3. LLM Extraction & Classification The prompt is assembled with explicit prompt-injection defences using document delimiters, then sent to Claude Sonnet 4.6 via the Basic LLM Chain. The response is parsed and normalised into a structured output item covering document type, parties, dates, obligations, governing law, total value, and a plain-English summary.