Back to Alchemy
Alchemy RecipeAdvancedautomation

Automate legal contract review and generate compliance checklists

A contract lands in your inbox at 4:47 p.m. on a Friday. Your legal team needs it reviewed by Monday morning. Someone will spend the weekend reading through 47 pages, cross-referencing clauses against your company's risk profile, checking whether payment terms align with your standard agreements, and verifying that liability caps meet your insurance thresholds. It's necessary work, but it's also the kind of task that leaves your in-house counsel exhausted and your timeline uncertain. This scenario repeats across most organisations with internal legal teams. Contracts arrive at an unpredictable cadence, each one demands careful reading, and the bottleneck isn't always obvious until you're behind on multiple reviews. Manual contract analysis also introduces human inconsistency: one reviewer might catch a problematic indemnity clause while another misses it entirely. What if you could reduce this friction by automating the initial analysis and flagging compliance issues before a human touches the document? Building a workflow for contract review and compliance checklist generation sits at the advanced end of automation, but it's entirely achievable with the right tools wired together. The approach here uses AI-powered document dialogue, encrypted collaborative drafting, and content summarisation, all orchestrated through a single workflow engine. Let's walk through how to build it.

The Automated Workflow

The workflow operates in four stages: document ingestion, intelligent extraction and analysis, compliance checking, and checklist generation. Here's what happens:

Stage 1: Contract arrives and gets indexed

A contract PDF lands in a shared folder, Slack channel, or email inbox. Your orchestration tool (n8n works particularly well for this due to its native file handling) detects the new file and passes it to Chat With PDF by Copilot.us. This tool indexes the document and makes it queryable through an API endpoint.

Stage 2: Extract key contract data

Once indexed, you'll use Claude Opus 4.6 or GPT-4.1 via Chat With PDF to extract structured information. Send targeted prompts to pull out: parties involved, effective dates, payment terms, liability limitations, termination clauses, and any defined compliance obligations specific to your industry.

Stage 3: Cross-reference against your compliance framework

This is where Okara AI comes in. It provides encrypted multi-model chat, which means you can store your company's standard contract terms, compliance requirements, and risk thresholds securely. You send the extracted contract data to Okara AI alongside your internal standards, then ask it to identify gaps, mismatches, or flagged risks. The encryption layer is critical here; you're handling sensitive legal documents and internal policy documents together.

Stage 4: Summarise findings and generate a checklist

Smmry condenses the analysis into a structured summary. Your orchestration tool then formats this into a compliance checklist: a markdown or PDF file listing which clauses need human review, which compliance requirements are met, which are missing, and which carry risk flags.

Here's how to wire this in n8n:

Start by creating a new workflow. Add a trigger that watches your chosen input method. For this example, we'll use Google Drive as the trigger source.

{ "nodes": [ { "name": "Trigger: New Contract PDF", "type": "n8n-nodes-base.googleDrive", "typeVersion": 1, "position": [250, 300], "parameters": { "event": "fileCreated", "folderId": "your_folder_id_here", "mimeType": "application/pdf" } } ]
}

Once a PDF is detected, pass its download URL to Chat With PDF. You'll need to authenticate with an API key from Copilot.us.

POST https://api.copilot.us/v1/documents/upload
Content-Type: application/json
Authorization: Bearer YOUR_COPILOT_API_KEY { "url": "{{ $node['Trigger: New Contract PDF'].data.webViewLink }}", "document_name": "{{ $node['Trigger: New Contract PDF'].data.name }}"
}

The API returns a document_id. Store this; you'll use it for querying the document. Next, create a node that sends your first extraction prompt to Claude Opus 4.6 via the Chat With PDF interface:

POST https://api.copilot.us/v1/chat
Content-Type: application/json
Authorization: Bearer YOUR_COPILOT_API_KEY { "document_id": "{{ $node['Upload Contract'].data.document_id }}", "model": "claude-opus-4.6", "messages": [ { "role": "user", "content": "Extract the following fields from this contract in JSON format: parties, effective_date, expiration_date, payment_terms, liability_cap, termination_clause, and any regulatory compliance obligations. Return only valid JSON." } ], "temperature": 0.2
}

Set temperature to 0.2 for extraction tasks; you want consistency, not creativity. The model will return structured JSON. Store this output. Now add a node for Okara AI. This step compares the extracted contract data against your internal standards. You'll set up Okara with your company's standard terms and compliance requirements beforehand.

POST https://api.okara.ai/v1/analysis
Content-Type: application/json
Authorization: Bearer YOUR_OKARA_API_KEY { "contract_data": { "parties": "{{ $node['Extract Contract Data'].data.parties }}", "payment_terms": "{{ $node['Extract Contract Data'].data.payment_terms }}", "liability_cap": "{{ $node['Extract Contract Data'].data.liability_cap }}", "compliance_obligations": "{{ $node['Extract Contract Data'].data.compliance_obligations }}" }, "internal_standards": { "acceptable_liability_range": "$500,000 to $2,000,000", "required_compliance_standards": ["GDPR", "ISO 27001"], "standard_payment_terms": "Net 30" }, "analysis_type": "compliance_gap"
}

The response flags any deviations and identifies compliance risks. Feed this output to a summarisation step using Smmry:

POST https://api.smmry.com/API
Content-Type: application/json { "sm_api_input": "{{ $node['Okara Analysis'].data.gaps_and_risks_text }}", "sm_length": 10
}

Smmry returns a condensed version. Finally, use a code node to structure this into a checklist and save it:

javascript
const analysisResults = $node['Okara Analysis'].data;
const summary = $node['Smmry Summary'].data.sm_api_output; const checklist = `
- Parties: ${analysisResults.parties}
- Effective Date: ${analysisResults.effective_date}
- Payment Terms: ${analysisResults.payment_terms}
- Liability Cap: ${analysisResults.liability_cap}

## Compliance Status
- [ ] Liability cap within acceptable range
- [ ] All required compliance standards mentioned
- [ ] Payment terms match standard agreement
- [ ] Termination clause includes standard notice period

## Flagged Risks
${analysisResults.flagged_risks.map(r => `- **${r.severity}**: ${r.description}`).join('\n')}

## Summary
${summary}

## Next Steps
1. Review flagged risks with legal team
2. Assess whether deviations are acceptable
3. Negotiate or approve contract
`; return { checklist };

Save this checklist back to Google Drive or send it to a shared workspace. You can also wire in a Slack notification that pings your legal team with a link to the checklist and highlights of any critical risks.

The Manual Alternative

If you prefer more human oversight at each stage, you can pause the workflow between steps. After extraction but before Okara analysis, add a Slack approval node that sends the extracted data to your lead counsel for quick review. After the checklist is generated, you could require sign-off before it's shared with stakeholders. This trades some automation for control, but it keeps your team in the loop. Alternatively, if Okara's encrypted interface isn't necessary for your use case, you can skip it and instead use a single Claude Opus 4.6 call that handles both extraction and comparison. Feed it both the contract and your internal standards in a single prompt, then let it return a structured analysis. This is simpler to set up but less modular if you need to update your standards regularly.

Pro Tips

Manage API rate limits carefully.

Chat With PDF and Okara both have rate limits.

If you process multiple contracts simultaneously, queue them through a rate-limiter node in n8n. Set a delay of 2 seconds between API calls to stay well below typical limits (usually 60 calls per minute).

Temperature matters for extraction.

Keep temperature below 0.3 for data extraction; anything higher introduces variability. Reserve higher temperatures (0.7+) for the analysis and summary stages, where you want the model to draw creative inferences.

Store the document ID.

Chat With PDF indexes documents, and the indexing lasts for a session. Save the document_id in your workflow state so you can re-query the same document without re-uploading it. This saves API calls and bandwidth.

Encrypt sensitive output.

Okara handles encryption for its own interface, but when you export checklists to shared storage, consider encrypting PDFs or restricting access to Google Drive folders. Legal documents contain sensitive data; treat them accordingly.

Cost control through selective review.

You don't need to analyse every single clause with Claude Opus 4.6. Use GPT-4.1 mini or Claude Haiku 4.5 for initial extraction (they're fast and cheap), then escalate to Opus or GPT-4.1 only for complex compliance analysis. This cuts costs by 60-70% without sacrificing accuracy on straightforward contracts.

Cost Breakdown

ToolPlan NeededMonthly CostNotes
Chat With PDF by Copilot.usPro$29Unlimited document uploads and queries
Okara AIProfessional$99Encrypted multi-model chat with compliance features
SmmryPremium$5100 articles per month; overage at $0.05 per article
Claude Opus 4.6 (via API)Pay-as-you-go$50-150~$15 per million input tokens; ~$60 per million output tokens
GPT-4.1 mini (via API)Pay-as-you-go$10-30Cheaper extraction alternative; ~$0.15 per million input tokens
n8n (self-hosted)Open source$0Or $30/month for n8n Cloud with higher execution limits
Google Drive APIIncluded$0Included with workspace subscription