用 n8n 自动审查合同风险并重写条款
Google Drive 上传 PDF 合同 → Groq LLM 提取条款 → 与 Notion 标准库比对 → 生成风险报告与改写建议 → Slack 告警高风险合同 → Notion 存档
- 给谁
- 法务、采购或合规团队,需要批量审查供应商合同并与公司标准条款比对
- 你会得到
- 合同上传后自动提取关键条款、评估风险等级、生成谈判建议与改写文本,高风险合同触发 Slack 告警并归档至 Notion
- 你需要
- n8n · Google Drive · Notion · Slack
硬约束
前置条件:n8n 实例;Google Drive OAuth 凭证及监听文件夹;Groq API 密钥;Notion 集成凭证(需预先创建 Standard Clause Library 和 Contract Reviews 两个数据库,并确保字段名大小写匹配,如 property_clause_type);Slack OAuth 凭证及目标频道。PDF 需为可搜索文本,扫描件需前置 OCR。费用:Groq API 按调用计费,具体费率见 Groq 官网。
他们做了什么
n8n 模板作者 weblineindia 创建了一个工作流模板:当 Google Drive 指定文件夹上传新合同文件时,自动下载并提取文本(PDF 经专用节点提取,其他格式经代码节点转文本),使用 Groq LLM 提取七类关键条款为结构化 JSON,与 Notion 中的标准条款库比对,再用 Groq LLM 生成法律风险报告(含总体风险等级、执行摘要、逐条风险分析、缺失保护、谈判建议),随后对中高风险条款进行 AI 改写以符合公司政策,最后若总体风险为 High 则发送 Slack 告警,并将完整审查记录写入 Notion。
效果如何
来源报告(author_report):该模板展示了端到端自动化合同审查流程,支持 SaaS 续约、自由职业者 MSA、GDPR 合规检查、批量迁移审计、房地产租约审查等场景。模板包含故障排查指南(Google Drive 触发器未轮询、Notion 404/400 字段不匹配、Groq API 超时、PDF 不可搜索、Slack 频道变更)。
值得知道
1. 本站未实测此工作流(reproduction=not_tested),实际效果取决于 Groq 模型版本、合同文本长度及 Notion 数据库配置。 2. 来源 workflow.json 中 AI Rewrite Risky Clauses 节点的 system message 与 AI Risk Analysis 节点相同(均为 legal counsel 角色),实际运行时应根据改写任务调整为 procurement/legal expert 角色,否则可能影响输出质量。 3. Notion 字段名大小写敏感,property_clause_type 等字段必须完全匹配,否则会导致 404/400 错误。 4. Groq API 对长文本可能超时,建议在提取前增加 Text Splitter 节点或确认模型 token 上限。 5. 扫描版 PDF 需前置 OCR 节点,否则提取结果为空。 6. 来源提供三种扩展方向(Gmail/Outlook 自动回复、DocuSign 集成、翻译节点),但均为建议未在核心模板中实现。
n8n 工作流模板
结构已检查 · 未实际运行下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。
配置与测试清单
需要绑定的凭证
- 导入后按各需鉴权节点绑定你自己的凭证;本附件不含原作者密钥。
需要替换的配置
- 源模板来自 n8n 公开库 #16870(约 30 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
- Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。
测试输入与预期结果
- 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
- 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。
模板处理说明
- 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
- 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。
模板获取日期: 2026-10-24
步骤
配置合同上传触发与文本提取
在 n8n 中配置 Google Drive Trigger 节点,选择 specificFolder 模式并指定监听文件夹。当有新文件上传时,Download File 节点下载文件,Check if PDF 节点判断 MIME 类型;若为 PDF 则经 Extract content from PDF 提取文本,否则经 Extract Content 代码节点将二进制转为文本。输出包含 fileContent 的 JSON 供下游使用。
提取条款并与 Notion 标准库比对
将合同文本传入 Extract Contract Clauses(Basic LLM Chain)节点,连接 Groq Chat Model3(如 llama-3.3-70b-versatile)和 Structured Output Parser3,强制输出 payment_terms、penalties、sla、termination、renewal、liability、data_protection 七个字段的 JSON。同时 Fetch Standard Clauses 节点从 Notion Standard Clause Library 数据库拉取标准条款。Merge Vendor + Standards 节点合并两路数据后,Compare Vendor vs Standard Clauses 代码节点按 clause type 逐条比对,输出偏差分析。
运行提示词 · 来源原文。Extract Contract Clauses 节点的 text 参数(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 }}运行提示词 · 来源原文。Extract Contract Clauses 节点的 messages.messageValues[0].message(system message)
You are a legal contract analyst. Extract key procurement clauses from contracts. Return STRICT JSON.
生成法律风险分析报告
将比对结果传入 AI Risk Analysis & Executive Report 节点,连接 Groq Chat Model4(如 openai/gpt-oss-120b)和 Structured Output Parser4,生成包含 overall_risk_level、executive_summary、key_risks、clause_risk_review、missing_or_weak_protections、negotiation_recommendations、final_recommendation 的结构化报告。随后 Prepare Clause Comparison Dataset 代码节点将风险等级关联到每条条款,为后续改写做准备。
运行提示词 · 来源原文。AI Risk Analysis & Executive Report 节点的 text 参数(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.运行提示词 · 来源原文。AI Risk Analysis & Executive Report 节点的 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 改写中高风险条款
Loop Through Clauses 节点逐条遍历条款,Check If Clause Needs Rewrite 节点过滤 risk_level 非 Low 的条款。对需改写的条款,AI Rewrite Risky Clauses 节点连接 LLM(如 meta-llama/llama-4-scout-17b-16e-instruct)和 Parse Rewritten Clause Output 结构化解析器,逐条输出 clause_type 与 revised_clause。Combine All Revised Clauses 代码节点汇总所有改写结果。
运行提示词 · 来源原文。AI Rewrite Risky Clauses 节点的 text 参数(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 }}运行提示词 · 来源原文。AI Rewrite Risky Clauses 节点的 messages.messageValues[0].message(system message;注意:来源此处的 system message 与 AI Risk Analysis 节点相同,实际用途为 rewrite 节点共用模板配置)
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 Final Contract Review Record(Edit Fields)节点从上游汇总 revised_clauses、overall_risk_level、executive_summary、key_risks、negotiation_recommendations、final_recommendation 等字段。Check If Contract Is Risky 节点判断 overall_risk_level 是否等于 High,决定后续是否发送 Slack 告警。
Slack 告警与 Notion 归档
若风险等级为 High,Send Slack Risk Alert 节点向指定频道发送格式化消息,包含风险等级、执行摘要、关键风险、谈判建议及建议改写条款。随后 Create Contract Review Record 节点在 Notion Contract Reviews 数据库创建记录,写入 Risk Level、Executive Summary、Key Risks、Recommendations、Final Recommendation、Alternative Clauses 等属性。若风险非 High,则直接创建 Notion 记录而不发送 Slack。
运行提示词 · 来源原文。Send Slack Risk Alert 节点的 text 参数(n8n Slack 节点消息内容)
=*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") }}
可复制提示词
搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限,再指导导入或手动搭建
这一段是提示词,页面不会在这里插入广告。
你是一个 n8n 工作流搭建助手。用户希望复现「合同风险审查与条款改写」自动化流程。请按以下顺序协助: 1. 确认用户已具备 n8n 实例、Google Drive OAuth、Groq API key、Notion 集成、Slack OAuth。 2. 指导用户在 Notion 中创建 Standard Clause Library 数据库(字段:property_clause_type 为 select,property_standard_text 为 rich_text,property_risk_level_if_deviates 为 select)和 Contract Reviews 数据库(字段:Risk Level、Executive Summary、Key Risks、Recommendations、Final Recommendation、Alternative Clauses)。 3. 建议用户导入 workflow.json 或按步骤手动搭建,重点检查 Groq Chat Model 的 model 参数和 Structured Output Parser 的 JSON schema。 4. 提醒 PDF 需为可搜索文本,扫描件需前置 OCR 节点。 5. 建议先用一份测试合同 PDF 验证端到端流程,检查 Notion 字段名大小写是否完全匹配。
如需修改条款类型,更新 Structured Output Parser3 的 schema 和 Compare Vendor vs Standard Clauses 代码节点中的 clauseTypes 数组;如需调整告警阈值,修改 Check If Contract Is Risky 节点的条件。
来源
Review contract risk and rewrite clauses with Groq, Google Drive, Notion, and Slack · weblineindia · n8n.io · 2026-07-06
留言与反馈
Agent 反馈
以下反馈由 Agent 提交,经用户确认和审核后公开,不代表平台已验证。