# Contract extraction, risk analysis & compliance automation: n8n workflow

> Started by another system calling it, and works across Gmail, Postgres, Slack and in-memory vectors.

Source: https://millionrounds.com/workflow/contract-extraction-risk-analysis-and-compliance-automation (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Research and reporting](https://millionrounds.com/workflows?category=Research+and+reporting#library)

# Contract extraction, risk analysis & compliance automation

Started by another system calling it, and works across Gmail, Postgres, Slack and in-memory vectors. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 23 steps, 1 branch: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fcontract-extraction-risk-analysis-and-compliance-automation)

**23 steps** Large: read it before trusting it with anything live

**1** Branch: places the flow splits

**0** Loops or waits

**4** Services it connects to

## The flow

Starts it 3 Model 7 Logic 5 Service 8

The steps in the order they run, from what starts it.

- 1 **Schedule Contract Review** Schedule trigger *Starts it*
- 2 **Webhook - Contract Upload** Webhook *Starts it*
- 3 **Gmail - Contract Emails** Gmail trigger *Starts it*
- 4 **Text Splitter - Clause Chunking** Text Splitter Recursive Character Text Splitter *Model*
- 5 **OpenAI Embeddings** Embeddings Open Ai *Model*
- 6 **OpenAI Chat Model - Compliance Analysis** Lm Chat Open Ai *Model*
- 7 **Structured Parser - Compliance Results** Output Parser Structured *Model*
- 8 **Workflow Configuration** Set *Logic*
- 9 **Merge All Contract Sources** Merge *Logic*
- 10 **Document Loader - Contract Processing** Document Default Data Loader *Model*
- 11 **Vector Store - Contract Clauses** Vector Store In Memory *Model*
- 12 **AI Agent - Compliance Checker** Agent *Model*
- 13 **Fetch Contracts from Repository** Http Request *Service*
- 14 **Extract Contract Content** Extract From File *Service*
- 15 **Calculate Risk Score** Code *Logic*
- 16 **Store Compliance Results** Postgres *Service*
- 17 **Route by Risk Level** Switch *Logic*
- 18 **Alert - High Risk Contracts** Slack *Service*
- 19 **Send to Dashboard API** Http Request *Service*
- 20 **Update CLM System** Http Request *Service*
- 21 **Update ERP System** Http Request *Service*
- 22 **Prepare Audit Trail** Set *Logic*
- 23 **Store Audit Trail** Postgres *Service*

## How it's built

- **Starts on:** Another system calling it
- **Steps:** 23, with 1 branch
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Gmail, Postgres, Slack, in-memory vectors
- **Model:** OpenAI
- **Retrieval:** Answers are drawn from documents you supply, not from the model alone

## Questions

What does it need to run?

An n8n account, plus your own Gmail, Postgres, Slack and in-memory vectors accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on another system calling it.

Does it use AI?

Yes. It calls OpenAI. Its answers draw on documents you give it, not on the model alone. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 23 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 23 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fcontract-extraction-risk-analysis-and-compliance-automation)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Gmail](https://millionrounds.com/workflows?service=Gmail#library)[Postgres](https://millionrounds.com/workflows?service=Postgres#library)[Slack](https://millionrounds.com/workflows?service=Slack#library)[in-memory vectors](https://millionrounds.com/workflows?service=in-memory+vectors#library)

## Workflows like it

Also research and reporting, with the same services where possible, closest in size first.

- [**AI research agents to automate PDF analysis with Mistral** 23 steps · calls a model · Gmail](https://millionrounds.com/workflow/ai-research-agents-to-automate-pdf-analysis-with-mistral)
- [**Automate privacy risk detection, approvals, and audit reports** 23 steps · calls a model · Gmail, Slack](https://millionrounds.com/workflow/automate-privacy-risk-detection-approvals-and-audit-reports)
- [**Find competitor feature gaps from app reviews with Bright Data** 23 steps · calls a model · Google Sheets, Slack](https://millionrounds.com/workflow/find-competitor-feature-gaps-from-app-reviews-with-bright-da)
- [**Generate comprehensive business analysis reports with Gemini** 23 steps · calls a model · Gmail, Google Docs](https://millionrounds.com/workflow/generate-comprehensive-business-analysis-reports-with-gemini)
- [**IPhone scraping + AI evaluation + Google Sheets & Airtable** 23 steps · calls a model · Airtable, Gmail](https://millionrounds.com/workflow/iphone-scraping-ai-evaluation-google-sheets-and-airtable)
- [**Track competitor prices and email AI insights** 23 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/track-competitor-prices-and-email-ai-insights)
