π¬ Analyze contract risk and red flags with OpenAI from a web form
β‘ 22 views Β· π¬ Document Extraction & Analysis
Description
Quick overview
This workflow collects pasted contract or terms-of-service text via an n8n Form and uses OpenAI to generate a structured risk score, plain-English summary, and flagged clauses, then returns a color-coded HTML report to the submitter.
How it works
- Receives a submission from an n8n Form containing the contract text, the submitterβs role, and an optional document type.
- Normalizes the submitted fields and checks the contract text is at least 200 characters long.
- If the text is too short, returns an HTML message asking the user to paste more content.
- Truncates very long submissions to stay within model limits and notes whether truncation occurred.
- Sends the prepared text to OpenAI with instructions to return a structured JSON risk report (overall risk score, reason, summary, and flagged clauses).
- Formats the AI output into a color-coded HTML report and displays it as the form completion response.
Setup
- Add an OpenAI API credential to the OpenAI Chat Model node and select the model you want to use.
- Activate the workflow and use the Form Trigger production URL to share or embed the form where users will submit contract text.
- Optionally adjust the minimum length check (200 characters) and the truncation limit (14,000 characters) to match your preferred validation and model context size.
π Nodes Used
Basic LLM Chain, OpenAI Chat Model, Structured Output Parser, n8n Form Trigger, n8n Form
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File