This workflow corresponds to n8n.io template #11861 — we link there as the canonical source.
This workflow follows the Agent → HTTP Request recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "9wqIGHvF3ZQ33o6w",
"name": "Intelligent Legal Document Review and Compliance Automation",
"tags": [],
"nodes": [
{
"id": "25e02a26-54b3-4994-9bdc-fa098345074b",
"name": "Document Upload Webhook",
"type": "n8n-nodes-base.webhook",
"position": [
0,
0
],
"parameters": {
"path": "legal-document-upload",
"options": {},
"httpMethod": "POST",
"responseMode": "lastNode"
},
"typeVersion": 2.1
},
{
"id": "d2fcba9d-b74b-4d3a-a9b0-fd0844deedc0",
"name": "Workflow Configuration",
"type": "n8n-nodes-base.set",
"position": [
224,
0
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "complianceRules",
"type": "string",
"value": "<__PLACEHOLDER_VALUE__Compliance rules and regulations to check against__>"
},
{
"id": "id-2",
"name": "riskThreshold",
"type": "string",
"value": "medium"
},
{
"id": "id-3",
"name": "documentType",
"type": "string",
"value": "contract"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "46fda9ae-8c8a-486a-be59-badeb6c112c6",
"name": "Extract Document Text",
"type": "n8n-nodes-base.extractFromFile",
"position": [
448,
0
],
"parameters": {
"options": {},
"operation": "pdf"
},
"typeVersion": 1.1
},
{
"id": "c56c477a-b08e-49a0-bf91-7f03e5274fd2",
"name": "Clause Analysis Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
672,
0
],
"parameters": {
"text": "={{ $json.text }}",
"options": {
"systemMessage": "You are a legal document analysis expert specializing in contract review.\n\nYour task is to:\n1. Identify and extract all key clauses from the legal document\n2. Categorize each clause by type (e.g., termination, liability, payment, confidentiality, indemnification)\n3. Extract the exact text of each clause\n4. Identify the location (section/paragraph) of each clause\n5. Note any unusual or non-standard clauses\n\nReturn your analysis in the structured JSON format defined by the output parser."
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 3
},
{
"id": "05fca994-f629-44a0-ac1e-192427f51d03",
"name": "OpenAI Model - Clause Analysis",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
680,
224
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {},
"builtInTools": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "f2596eac-1f32-4a32-8415-f06ceb15a35b",
"name": "Clause Analysis Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
808,
224
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"clauses\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"type\": {\"type\": \"string\"},\n \"text\": {\"type\": \"string\"},\n \"location\": {\"type\": \"string\"},\n \"isStandard\": {\"type\": \"boolean\"}\n }\n }\n }\n }\n}"
},
"typeVersion": 1.3
},
{
"id": "77bc6613-bd72-486f-8b85-d669cd5f8458",
"name": "Compliance Check Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1024,
0
],
"parameters": {
"text": "=Clauses: {{ JSON.stringify($json.clauses) }}\n\nCompliance Rules: {{ $('Workflow Configuration').first().json.complianceRules }}\n\nRisk Threshold: {{ $('Workflow Configuration').first().json.riskThreshold }}",
"options": {
"systemMessage": "You are a legal compliance expert specializing in contract risk assessment.\n\nYour task is to:\n1. Review each clause against the provided compliance rules and regulations\n2. Identify any clauses that violate or conflict with compliance requirements\n3. Assess the risk level of each problematic clause (low, medium, high, critical)\n4. Highlight specific compliance issues and their potential legal implications\n5. Flag any missing clauses that are required for compliance\n\nReturn your analysis in the structured JSON format defined by the output parser."
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 3
},
{
"id": "dfe22a4a-7702-4db8-8d1c-16555cfaf048",
"name": "OpenAI Model - Compliance",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1032,
224
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {},
"builtInTools": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "bfb0e9c7-f955-405d-b4fe-bc623ae89f3b",
"name": "Compliance Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1160,
224
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"riskyAreas\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"clauseType\": {\"type\": \"string\"},\n \"clauseText\": {\"type\": \"string\"},\n \"riskLevel\": {\"type\": \"string\"},\n \"complianceIssue\": {\"type\": \"string\"},\n \"legalImplication\": {\"type\": \"string\"}\n }\n }\n },\n \"missingClauses\": {\n \"type\": \"array\",\n \"items\": {\"type\": \"string\"}\n }\n }\n}"
},
"typeVersion": 1.3
},
{
"id": "a6d9fedc-8f73-4377-8bbe-2e1bb99eb9d0",
"name": "Alternative Wording Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1376,
0
],
"parameters": {
"text": "=Risky Areas: {{ JSON.stringify($json.riskyAreas) }}",
"options": {
"systemMessage": "You are a legal drafting expert specializing in contract language optimization.\n\nYour task is to:\n1. For each risky clause identified, provide alternative wording that addresses the compliance issue\n2. Ensure the alternative wording maintains the original intent while reducing legal risk\n3. Make the language clear, unambiguous, and legally sound\n4. Provide a brief explanation of why the alternative wording is better\n5. Suggest wording for any missing clauses that were flagged\n\nReturn your suggestions in the structured JSON format defined by the output parser."
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 3
},
{
"id": "2106f14d-4f44-443b-adfb-87d8a77590c7",
"name": "OpenAI Model - Alternative Wording",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1384,
224
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {},
"builtInTools": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "d0f487f9-6b3a-47c3-9d06-77ff3c35c746",
"name": "Alternative Wording Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1512,
224
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"suggestions\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"originalClause\": {\"type\": \"string\"},\n \"alternativeWording\": {\"type\": \"string\"},\n \"explanation\": {\"type\": \"string\"},\n \"riskReduction\": {\"type\": \"string\"}\n }\n }\n },\n \"missingClauseSuggestions\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"clauseType\": {\"type\": \"string\"},\n \"suggestedWording\": {\"type\": \"string\"}\n }\n }\n }\n }\n}"
},
"typeVersion": 1.3
},
{
"id": "9203062b-979e-420b-a970-8c4f0c40298a",
"name": "Summary Report Generator",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1728,
0
],
"parameters": {
"text": "=Complete Analysis Data:\n\nClauses: {{ JSON.stringify($('Clause Analysis Agent').first().json.clauses) }}\n\nRisky Areas: {{ JSON.stringify($('Compliance Check Agent').first().json.riskyAreas) }}\n\nMissing Clauses: {{ JSON.stringify($('Compliance Check Agent').first().json.missingClauses) }}\n\nSuggestions: {{ JSON.stringify($json.suggestions) }}\n\nMissing Clause Suggestions: {{ JSON.stringify($json.missingClauseSuggestions) }}",
"options": {
"systemMessage": "You are a legal document review specialist creating executive summaries.\n\nYour task is to:\n1. Create a comprehensive summary report of the legal document review\n2. Include an executive summary highlighting the most critical findings\n3. List all risky areas with their risk levels and compliance issues\n4. Provide all alternative wording suggestions in a clear, actionable format\n5. Include recommendations for next steps\n6. Format the report in professional HTML with proper sections and styling\n\nReturn ONLY the complete HTML report (including <html>, <head>, and <body> tags)."
},
"promptType": "define"
},
"typeVersion": 3
},
{
"id": "d3c9d17b-d679-4e67-86bf-c71df22f977d",
"name": "OpenAI Model - Summary",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1800,
224
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {},
"builtInTools": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "a9dbdec8-4e88-4011-b624-6bbd7bdeea6a",
"name": "Prepare Database Record",
"type": "n8n-nodes-base.set",
"position": [
2080,
0
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "document_name",
"type": "string",
"value": "={{ $('Document Upload Webhook').first().json.body.filename || \"Unknown Document\" }}"
},
{
"id": "id-2",
"name": "review_date",
"type": "string",
"value": "={{ $now.toISO() }}"
},
{
"id": "id-3",
"name": "risk_summary",
"type": "string",
"value": "={{ JSON.stringify($('Compliance Check Agent').first().json.riskyAreas) }}"
},
{
"id": "id-4",
"name": "suggestions_summary",
"type": "string",
"value": "={{ JSON.stringify($('Alternative Wording Agent').first().json.suggestions) }}"
},
{
"id": "id-5",
"name": "full_report_html",
"type": "string",
"value": "={{ $json.output }}"
},
{
"id": "id-6",
"name": "total_clauses",
"type": "number",
"value": "={{ $('Clause Analysis Agent').first().json.clauses.length }}"
},
{
"id": "id-7",
"name": "high_risk_count",
"type": "number",
"value": "={{ $('Compliance Check Agent').first().json.riskyAreas.filter(r => r.riskLevel === \"high\" || r.riskLevel === \"critical\").length }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "e05d6178-f926-45fb-b0cb-17928622f8e3",
"name": "Log to Contract Database",
"type": "n8n-nodes-base.postgres",
"position": [
2304,
0
],
"parameters": {
"table": {
"__rl": true,
"mode": "name",
"value": "<__PLACEHOLDER_VALUE__Table name for contract reviews__>"
},
"schema": {
"__rl": true,
"mode": "name",
"value": "<__PLACEHOLDER_VALUE__Database schema name__>"
},
"columns": {
"value": {
"review_date": "",
"risk_summary": "",
"document_name": "",
"total_clauses": "",
"high_risk_count": "",
"full_report_html": "",
"suggestions_summary": ""
},
"mappingMode": "defineBelow"
},
"options": {}
},
"typeVersion": 2.6
},
{
"id": "16224613-d3a9-4287-a17a-47f7346eac84",
"name": "Send Notification",
"type": "n8n-nodes-base.httpRequest",
"position": [
2528,
0
],
"parameters": {
"url": "<__PLACEHOLDER_VALUE__Notification webhook URL (e.g., Slack, Teams, email service)__>",
"method": "POST",
"options": {},
"jsonBody": "={\n \"document\": \"={{ $('Prepare Database Record').first().json.document_name }}\",\n \"review_date\": \"={{ $('Prepare Database Record').first().json.review_date }}\",\n \"total_clauses\": \"={{ $('Prepare Database Record').first().json.total_clauses }}\",\n \"high_risk_count\": \"={{ $('Prepare Database Record').first().json.high_risk_count }}\",\n \"message\": \"Legal document review completed. {{ $('Prepare Database Record').first().json.high_risk_count }} high-risk issues found.\"\n}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.3
},
{
"id": "865183a6-17be-4d2e-aabc-9ea24d40a1f0",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
-400
],
"parameters": {
"width": 784,
"height": 192,
"content": "## How It Works\nThis template automates legal document review by extracting text, analyzing clauses with OpenAI, checking compliance standards, and generating alternative wordings. Target audience: legal teams, contract managers, and compliance officers seeking efficient document processing. Problem solved: manual clause extraction and compliance review is time-consuming and error-prone. Workflow extracts document text, performs parallel AI-powered clause analysis and compliance verification via OpenAI, consolidates findings, generates alternative wordings for non-compliant clauses, creates summary reports, stores results in databases, and notifies stakeholders via email."
},
"typeVersion": 1
},
{
"id": "124bff6d-b882-4e27-a988-57ea422d7436",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1808,
-400
],
"parameters": {
"color": 5,
"width": 640,
"height": 176,
"content": "## Customization\nModify OpenAI prompts for industry-specific clauses. Swap Google Sheets for your database. \n\n## Benefits\nReduces manual review time by 80%, ensures consistent clause standardization "
},
"typeVersion": 1
},
{
"id": "a17bbae1-fb09-4661-a497-48c0ed36fe5f",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1136,
-400
],
"parameters": {
"color": 4,
"width": 640,
"height": 208,
"content": "## Prerequisites\nOpenAI API key, Gmail account, Google Sheets access, document upload capability.\n\n## Use Cases\nLegal teams reviewing SaaS contracts, compliance departments auditing vendor agreements "
},
"typeVersion": 1
},
{
"id": "1db1b24f-c762-4894-9806-bbc70eb69adb",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
736,
-400
],
"parameters": {
"color": 3,
"width": 352,
"height": 208,
"content": "## Setup Steps\n1. Configure OpenAI API with clause analysis and compliance prompts. \n2. Connect Google Sheets for database staging. \n3. Set Gmail for notifications. \n4. Input document source (upload node). \n5. Test with sample contracts."
},
"typeVersion": 1
},
{
"id": "540ca8bc-b566-4714-90c5-b9e436665d24",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
-112
],
"parameters": {
"color": 7,
"width": 1072,
"height": 512,
"content": "## Extract & Analyze\n**What:** Documents uploaded trigger text extraction and parallel clause analysis.\n**Why:** Automated extraction eliminates manual reading; parallel processing accelerates multi-clause evaluation."
},
"typeVersion": 1
},
{
"id": "47a7c53a-4aec-46e2-aa29-379520cb67b0",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1008,
-112
],
"parameters": {
"color": 7,
"width": 672,
"height": 528,
"content": "## Compliance & Alternatives\n**What:** Compliance agent verifies standards; alternative agent rewrites problematic clauses.\n**Why:** Parallel checks ensure thoroughness and provides immediate improvement suggestions.\n"
},
"typeVersion": 1
},
{
"id": "8af54637-ec35-4f29-8715-354ad6f2655b",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1712,
-112
],
"parameters": {
"color": 7,
"width": 1024,
"height": 528,
"content": "## Report & Archive\n**What:** Summary generator creates unified reports; results stored in database.\n**Why:** Centralized reporting simplifies compliance tracking and maintains audit trails."
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "59d8673a-8929-4321-9f8b-1b607dc1f990",
"connections": {
"Clause Analysis Agent": {
"main": [
[
{
"node": "Compliance Check Agent",
"type": "main",
"index": 0
}
]
]
},
"Extract Document Text": {
"main": [
[
{
"node": "Clause Analysis Agent",
"type": "main",
"index": 0
}
]
]
},
"Compliance Check Agent": {
"main": [
[
{
"node": "Alternative Wording Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Model - Summary": {
"ai_languageModel": [
[
{
"node": "Summary Report Generator",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Workflow Configuration": {
"main": [
[
{
"node": "Extract Document Text",
"type": "main",
"index": 0
}
]
]
},
"Document Upload Webhook": {
"main": [
[
{
"node": "Workflow Configuration",
"type": "main",
"index": 0
}
]
]
},
"Prepare Database Record": {
"main": [
[
{
"node": "Log to Contract Database",
"type": "main",
"index": 0
}
]
]
},
"Compliance Output Parser": {
"ai_outputParser": [
[
{
"node": "Compliance Check Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Log to Contract Database": {
"main": [
[
{
"node": "Send Notification",
"type": "main",
"index": 0
}
]
]
},
"Summary Report Generator": {
"main": [
[
{
"node": "Prepare Database Record",
"type": "main",
"index": 0
}
]
]
},
"Alternative Wording Agent": {
"main": [
[
{
"node": "Summary Report Generator",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Model - Compliance": {
"ai_languageModel": [
[
{
"node": "Compliance Check Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Clause Analysis Output Parser": {
"ai_outputParser": [
[
{
"node": "Clause Analysis Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"OpenAI Model - Clause Analysis": {
"ai_languageModel": [
[
{
"node": "Clause Analysis Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Alternative Wording Output Parser": {
"ai_outputParser": [
[
{
"node": "Alternative Wording Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"OpenAI Model - Alternative Wording": {
"ai_languageModel": [
[
{
"node": "Alternative Wording Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
openAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This template automates legal document review by extracting text, analyzing clauses with OpenAI, checking compliance standards, and generating alternative wordings. Target audience: legal teams, contract managers, and compliance officers seeking efficient document processing.…
Source: https://n8n.io/workflows/11861/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow automates veterinary clinic operations and client communications for animal hospitals and veterinary practices managing appointments, inventory, and patient care. It solves the dual chal
Logo Animator - Supabase. Uses postgres, openAi, agent, toolThink. Webhook trigger; 26 nodes.
This workflow captures incoming leads from a webhook, enriches them using AI, and automates the entire sales pipeline. It validates data, scores leads as hot, warm, or cold, assigns them to sales reps
Automate peer review assignment and grading with AI-powered evaluation. Designed for educators managing collaborative assessments efficiently.
This workflow was created by Varritech Technologies, a cutting-edge software agency that helps founders and operators go from idea to production 5× faster using AI. Based in New York City, we speciali