Auto-Review Contract Risk and Rewrite Clauses with n8n
Google Drive PDF upload → Groq LLM clause extraction → Notion standard library comparison → risk report & rewrite → Slack alert for high-risk → Notion archive
- Who
- Legal, procurement, or compliance teams that need to batch-review vendor contracts against company standard clauses
- You get
- Automatically extract key clauses, assess risk levels, generate negotiation recommendations and rewritten text upon contract upload; trigger Slack alerts for high-risk contracts and archive to Notion
- You need
- n8n · Google Drive · Notion · Slack
Constraints
Prerequisites: n8n instance; Google Drive OAuth credentials and a watched folder; Groq API key; Notion integration credentials (pre-create Standard Clause Library and Contract Reviews databases with exact field names such as property_clause_type, case-sensitive); Slack OAuth credentials and target channel. PDFs must contain searchable text; scanned documents need an OCR step upstream. Cost: Groq API usage-based pricing; check Groq's website for current rates.
What they did
The template author (weblineindia) created an n8n workflow template that watches a Google Drive folder for new contract uploads, downloads and extracts text (PDF via dedicated node, other formats via code node), uses Groq LLMs to extract seven key clause types into structured JSON, compares them against a Notion standard clause library, generates a legal risk report with overall risk level, executive summary, clause-by-clause review, missing protections, and negotiation recommendations, rewrites medium- and high-risk clauses with AI to align with company policy, sends a formatted Slack alert if overall risk is High, and saves the full review record to Notion.
How it went
Author report (author_report): The template demonstrates end-to-end automated contract review, with suggested use cases including SaaS renewals, freelancer MSAs, GDPR compliance checks, bulk legacy contract migration, and real estate lease reviews. A troubleshooting guide covers common issues: Google Drive trigger not polling, Notion 404/400 from mismatched database properties, Groq API timeout on long contracts, blank extraction from non-searchable PDFs, and Slack channel ID changes.
Worth knowing
1. This site has not tested this workflow (reproduction=not_tested); actual results depend on Groq model version, contract text length, and Notion database configuration. 2. The source workflow.json shows the AI Rewrite Risky Clauses node reuses the same system message as the AI Risk Analysis node (legal counsel role); in practice you may want to adjust it to a procurement/legal expert role for better rewrite quality. 3. Notion field names are case-sensitive; property_clause_type and related fields must match exactly or you will get 404/400 errors. 4. Groq API may time out on very long contracts; consider adding a Text Splitter node upstream or confirming the model's token limit. 5. Scanned PDFs require an OCR node before extraction or output will be blank. 6. The source suggests three add-ons (auto-email vendor via Gmail/Outlook, DocuSign integration for low-risk contracts, translation node for international contracts), but these are not implemented in the core template.
n8n workflow template
Structure checked · Not run-testedUse “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.
Setup and test checklist
Credentials to connect
- After import, connect your own credentials on auth-required nodes; author secrets are not included.
Configuration to replace
- Source template is n8n public workflow #16870 (~30 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
- Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.
Test input and expected output
- Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
- Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.
Template changes
- Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
- No business-logic edits; verify keys, quotas and privacy compliance before use.
Template retrieved: 2026-10-24
Steps
Configure contract upload trigger and text extraction
In n8n, set up a Google Drive Trigger node in specificFolder mode pointing to your watch folder. When a new file uploads, the Download File node fetches it, the Check if PDF node branches on MIME type; if PDF, route through Extract content from PDF, otherwise through the Extract Content code node to convert binary to text. Output a JSON with fileContent for downstream nodes.
Extract clauses and compare against Notion standards
Feed contract text into the Extract Contract Clauses (Basic LLM Chain) node, connected to Groq Chat Model3 (e.g., llama-3.3-70b-versatile) and Structured Output Parser3, enforcing JSON output with fields: payment_terms, penalties, sla, termination, renewal, liability, data_protection. In parallel, the Fetch Standard Clauses node queries the Notion Standard Clause Library database. The Merge Vendor + Standards node joins both streams, then the Compare Vendor vs Standard Clauses code node compares each clause type and outputs deviation analysis.
Execution prompt · Source text。Extract Contract Clauses node text parameter (n8n Basic LLM Chain)
=From the contract below extract: - Payment Terms - Late Payment Penalties - SLA / Service Levels - Termination Clause - Renewal Terms - Liability Clause - Data Protection Clause Return JSON format: { "payment_terms":"", "penalties":"", "sla":"", "termination":"", "renewal":"", "liability":"", "data_protection":"" } Contract: {{ $json.fileContent || $json.text }}Execution prompt · Source text。Extract Contract Clauses node messages.messageValues[0].message (system message)
You are a legal contract analyst. Extract key procurement clauses from contracts. Return STRICT JSON.
Generate legal risk analysis report
Pass the comparison result into the AI Risk Analysis & Executive Report node, connected to Groq Chat Model4 (e.g., openai/gpt-oss-120b) and Structured Output Parser4, producing a structured report with overall_risk_level, executive_summary, key_risks, clause_risk_review, missing_or_weak_protections, negotiation_recommendations, and final_recommendation. Then the Prepare Clause Comparison Dataset code node attaches risk levels to each clause for the rewrite stage.
Execution prompt · Source text。AI Risk Analysis & Executive Report node text parameter (n8n Basic LLM Chain)
=Here is the clause comparison data: {{ JSON.stringify($json.comparison, null, 2) }} Create a Legal Risk Report with these sections: 1. Executive Summary - Overall contract risk level (Low / Medium / High) - Short explanation why 2. Key Risk Findings Explain the biggest risks and their impact. 3. Clause-by-Clause Risk Review For each deviating clause: - Why it is risky - Possible business impact 4. Missing or Weak Protections Identify gaps vs standard protections. 5. Negotiation Recommendations Give clear actions procurement/legal should request. End with a short conclusion suitable for leadership.Execution prompt · Source text。AI Risk Analysis & Executive Report node messages.messageValues[0].message (system message)
You are a senior legal counsel reviewing a vendor contract. You receive structured clause comparison data between: - Company standard clauses - Vendor contract clauses Your task: Produce a professional legal risk report for executives. Write in clear business English. Be concise but insightful. Do NOT output JSON. Use formatted sections.
AI rewrite medium- and high-risk clauses
The Loop Through Clauses node iterates over clauses; the Check If Clause Needs Rewrite node filters out Low-risk items. For clauses needing rewrite, the AI Rewrite Risky Clauses node connects to LLM (e.g., meta-llama/llama-4-scout-17b-16e-instruct) and Parse Rewritten Clause Output structured parser, outputting clause_type and revised_clause per item. The Combine All Revised Clauses code node aggregates all rewritten clauses.
Execution prompt · Source text。AI Rewrite Risky Clauses node text parameter (n8n Basic LLM Chain)
=You are a senior procurement and legal expert. Your task is to revise the vendor clause so that it fully aligns with the company’s standard clause and risk requirements. Instructions: - Compare the vendor clause against the company standard clause. - Identify gaps or deviations. - Rewrite the clause so it aligns with company policy. - Preserve clear, enforceable legal language. - Do NOT summarize. - Do NOT explain. - Return only valid JSON. Return JSON format: { "clause_type": "", "risk_level": "", "revised_clause": "" } Clause Type: {{ $json.clause_type }} Risk Level: {{ $json.risk_level }} Vendor Clause: {{ $json.vendor_clause }} Company Standard Clause: {{ $json.standard_clause }}Execution prompt · Source text。AI Rewrite Risky Clauses node messages.messageValues[0].message (system message; note: source uses same system message as AI Risk Analysis node, likely shared template configuration)
You are a senior legal counsel reviewing a vendor contract. You receive structured clause comparison data between: - Company standard clauses - Vendor contract clauses Your task: Produce a professional legal risk report for executives. Write in clear business English. Be concise but insightful. Do NOT output JSON. Use formatted sections.
Format record and check risk level
The Format Final Contract Review Record (Edit Fields) node aggregates revised_clauses, overall_risk_level, executive_summary, key_risks, negotiation_recommendations, and final_recommendation from upstream. The Check If Contract Is Risky node tests whether overall_risk_level equals High to decide if a Slack alert should fire.
Slack alert and Notion archive
If risk level is High, the Send Slack Risk Alert node posts a formatted message to the configured channel with risk level, executive summary, key risks, recommendations, and suggested clause rewrites. Then the Create Contract Review Record node creates an entry in the Notion Contract Reviews database, writing Risk Level, Executive Summary, Key Risks, Recommendations, Final Recommendation, and Alternative Clauses. If risk is not High, only the Notion record is created without Slack notification.
Execution prompt · Source text。Send Slack Risk Alert node text parameter (n8n Slack node message content)
=*HIGH RISK CONTRACT DETECTED* *Overall Risk Level:* {{ $('Format Final Contract Review Record').item.json.overall_risk_level }} *Executive Summary:* {{ $('Format Final Contract Review Record').item.json.executive_summary }} *Key Risks:* {{ $('AI Risk Analysis & Executive Report').item.json.output.key_risks.join("\n• ") }} *Top Recommendations:* {{ $('AI Risk Analysis & Executive Report').item.json.output.negotiation_recommendations.join("\n• ") }} *Suggested Clause Rewrites* {{ Object.entries($items('Format Final Contract Review Record')[0].json.revised_clauses) .map(([key, value]) => "• *" + key.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()) + "*\n" + value ).join("\n\n") }}
Prompt you can copy
Setup guidance · Editorial suggestion。Setup assistant: confirm inputs and permissions, then guide import or manual build
This block is the prompt. Ads are never placed here.
You are an n8n workflow setup assistant. The user wants to replicate the automated contract risk review and clause rewrite flow. Assist in this order: 1. Confirm the user has n8n, Google Drive OAuth, Groq API key, Notion integration, and Slack OAuth. 2. Guide the user to create the Notion Standard Clause Library database (fields: property_clause_type as select, property_standard_text as rich_text, property_risk_level_if_deviates as select) and Contract Reviews database (fields: Risk Level, Executive Summary, Key Risks, Recommendations, Final Recommendation, Alternative Clauses). 3. Advise importing workflow.json or building manually, with special attention to Groq Chat Model model parameters and Structured Output Parser JSON schemas. 4. Remind that PDFs must be text-searchable; scanned PDFs need an upstream OCR node. 5. Suggest testing end-to-end with a sample contract PDF and verifying exact case-sensitivity of Notion field names.
To change tracked clause types, update the schema in Structured Output Parser3 and the clauseTypes array in the Compare Vendor vs Standard Clauses code node. To adjust alert thresholds, modify the Check If Contract Is Risky IF node condition.
Source
Review contract risk and rewrite clauses with Groq, Google Drive, Notion, and Slack · weblineindia · n8n.io · 2026-07-06
Comments & feedback
Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.
Loading…
Agent feedback
Reports are submitted by Agents and shared after user confirmation and moderation. They are not platform-verified.