AutomationFlowsAI & RAG › AI Contract Review & Risk Analysis

AI Contract Review & Risk Analysis

AI Contract Review & Risk Analysis. Uses googleDriveTrigger, googleDrive, n8n-nodes-pdfvector, googleSheets. Event-driven trigger; 10 nodes.

Event trigger★★★★☆ complexity10 nodesGoogle Drive TriggerGoogle DriveN8N Nodes PdfvectorGoogle SheetsSlack
AI & RAG Trigger: Event Nodes: 10 Complexity: ★★★★☆

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "AI Contract Review & Risk Analysis",
  "nodes": [
    {
      "parameters": {
        "content": "## \ud83d\udccb Contract Review\n\n### What this workflow does\n1. Watches Drive for new contracts\n2. Pulls out terms and parties\n3. Flags risky clauses\n4. Writes a quick summary\n5. Sets review status\n6. Sends Slack report\n\n### Setup steps\n1. Create \"Contracts\" folder in Google Drive\n2. Get PDF Vector API key from pdfvector.com/api-keys\n3. Create Google Sheet with columns below\n4. Connect Slack and pick your channel\n5. Update folder ID, Sheet ID, channel ID\n\n### Sheet columns\nFile Name, Contract Type, Parties, Effective Date, Expiration Date, Value, Auto Renewal, Termination Notice, High Risks, Medium Risks, Review Status, Contract Link, Reviewed Date\n\n### Perfect for\n- Legal teams\n- Business ops\n- Procurement",
        "height": 480,
        "width": 364,
        "color": 5
      },
      "id": "064fd578-3a4c-4546-adda-17552d95c334",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        128,
        -240
      ]
    },
    {
      "parameters": {
        "content": "## \u26a0\ufe0f Risk Levels\n\n- High \u2192 Legal review needed\n- Medium \u2192 Review recommended\n- Low \u2192 Ready to sign",
        "height": 220,
        "width": 400
      },
      "id": "f37a145d-45f9-478a-aea4-638bc6683af3",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        960,
        -176
      ]
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "YOUR_FOLDER_ID",
          "mode": "list",
          "cachedResultName": "Contracts"
        },
        "event": "fileCreated",
        "options": {}
      },
      "id": "5b816d86-63c9-4f0a-8a76-ff5d41b7ea90",
      "name": "Google Drive Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        256,
        80
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "notes": "Watch for new contracts to review"
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": "={{ $json.id }}",
        "options": {}
      },
      "id": "65478e53-9d51-43b5-9d5f-cd2aad07e8cb",
      "name": "Download Contract",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        496,
        80
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "extract",
        "inputType": "file",
        "prompt": "Analyze this contract and extract as flat fields. contractType (one of: Service Agreement, Employment Contract, NDA, Lease Agreement, Sales Contract, Partnership Agreement, License Agreement, Other), party1Name, party1Role, party2Name, party2Role, effectiveDate (YYYY-MM-DD), expirationDate (YYYY-MM-DD), autoRenewal (true/false), renewalTerms, totalValue (number), paymentTerms, terminationNoticeDays (number), terminationClauses (semicolon-separated list), liabilityLimitations, nonCompeteClause (true/false), nonCompeteDetails, highRiskFlags (semicolon-separated list of HIGH severity risks), mediumRiskFlags (semicolon-separated list of MEDIUM severity risks), lowRiskFlags (semicolon-separated list of LOW severity risks), highRiskCount (number), mediumRiskCount (number).",
        "schema": "{\"type\": \"object\", \"properties\": {\"contractType\": {\"type\": \"string\"}, \"party1Name\": {\"type\": \"string\"}, \"party1Role\": {\"type\": \"string\"}, \"party2Name\": {\"type\": \"string\"}, \"party2Role\": {\"type\": \"string\"}, \"effectiveDate\": {\"type\": \"string\"}, \"expirationDate\": {\"type\": \"string\"}, \"autoRenewal\": {\"type\": \"boolean\"}, \"renewalTerms\": {\"type\": \"string\"}, \"totalValue\": {\"type\": \"number\"}, \"paymentTerms\": {\"type\": \"string\"}, \"terminationNoticeDays\": {\"type\": \"number\"}, \"terminationClauses\": {\"type\": \"string\"}, \"liabilityLimitations\": {\"type\": \"string\"}, \"nonCompeteClause\": {\"type\": \"boolean\"}, \"nonCompeteDetails\": {\"type\": \"string\"}, \"highRiskFlags\": {\"type\": \"string\"}, \"mediumRiskFlags\": {\"type\": \"string\"}, \"lowRiskFlags\": {\"type\": \"string\"}, \"highRiskCount\": {\"type\": \"number\"}, \"mediumRiskCount\": {\"type\": \"number\"}}, \"additionalProperties\": false}"
      },
      "id": "df895e74-25d1-4913-91c3-30a9c5b28d0a",
      "name": "PDF Vector - Analyze Contract",
      "type": "n8n-nodes-pdfvector.pdfVector",
      "typeVersion": 2,
      "position": [
        656,
        -96
      ],
      "credentials": {
        "pdfVectorApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "combine",
        "combinationMode": "mergeByPosition",
        "options": {}
      },
      "id": "f4ad5c8a-97bd-4bc8-99fe-56638f563438",
      "name": "Merge Data",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        832,
        64
      ]
    },
    {
      "parameters": {
        "operation": "ask",
        "inputType": "file",
        "question": "Provide a brief executive summary of this contract (2-3 sentences), list the top 3 things the signer should be aware of, and give an overall risk rating (Low/Medium/High) with justification."
      },
      "id": "06b75976-6f60-46db-bfe3-28982f88ac33",
      "name": "PDF Vector - Executive Summary",
      "type": "n8n-nodes-pdfvector.pdfVector",
      "typeVersion": 2,
      "position": [
        1040,
        64
      ],
      "credentials": {
        "pdfVectorApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const contract = $('PDF Vector - Analyze Contract').item.json.data || $('PDF Vector - Analyze Contract').item.json;\nconst summary = $input.first().json.answer || $input.first().json.markdown || '';\nconst fileName = $('Google Drive Trigger').item.json.name;\n\nconst highRisks  = parseInt(contract.highRiskCount)   || 0;\nconst medRisks   = parseInt(contract.mediumRiskCount) || 0;\n\nconst partiesList = [\n  contract.party1Name ? `${contract.party1Name} (${contract.party1Role || 'Party A'})` : null,\n  contract.party2Name ? `${contract.party2Name} (${contract.party2Role || 'Party B'})` : null\n].filter(Boolean).join(', ') || 'Not specified';\n\nconst risksList = [\n  ...(contract.highRiskFlags   || '').split(';').map(r => r.trim()).filter(Boolean).map(r => `[High] ${r}`),\n  ...(contract.mediumRiskFlags || '').split(';').map(r => r.trim()).filter(Boolean).map(r => `[Medium] ${r}`),\n  ...(contract.lowRiskFlags    || '').split(';').map(r => r.trim()).filter(Boolean).map(r => `[Low] ${r}`)\n].join('\\n') || 'No significant risks identified';\n\nlet reviewStatus = 'Ready for Signature';\nif (highRisks > 0)    reviewStatus = 'Requires Legal Review';\nelse if (medRisks >= 2) reviewStatus = 'Review Recommended';\n\nreturn [{ json: {\n  ...contract,\n  executiveSummary:   summary,\n  partiesList,\n  risksList,\n  highRiskCount:  highRisks,\n  mediumRiskCount: medRisks,\n  reviewStatus,\n  fileName,\n  fileId: $('Google Drive Trigger').item.json.id,\n  processedAt: new Date().toISOString()\n}}];"
      },
      "id": "fd623fe4-996a-4f50-8d61-034ecf2452ae",
      "name": "Compile Review",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1248,
        64
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list",
          "cachedResultName": "Contract Tracker"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Contract Review"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "File Name": "={{ $json.fileName }}",
            "Contract Type": "={{ $json.contractType }}",
            "Parties": "={{ $json.partiesList }}",
            "Effective Date": "={{ $json.effectiveDate || 'N/A' }}",
            "Expiration Date": "={{ $json.expirationDate || 'N/A' }}",
            "Value": "={{ $json.totalValue || 'N/A' }}",
            "Auto Renewal": "={{ $json.autoRenewal ? 'Yes' : 'No' }}",
            "Termination Notice": "={{ $json.terminationNoticeDays || 'N/A' }} days",
            "High Risks": "={{ $json.highRiskCount }}",
            "Medium Risks": "={{ $json.mediumRiskCount }}",
            "Review Status": "={{ $json.reviewStatus }}",
            "Contract Link": "=https://drive.google.com/file/d/{{ $json.fileId }}/view",
            "Reviewed Date": "={{ $json.processedAt.split('T')[0] }}"
          }
        },
        "options": {}
      },
      "id": "5bbff199-b29f-43fb-a573-de1d62e2c20f",
      "name": "Log Contract Review",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.4,
      "position": [
        1440,
        64
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "YOUR_CHANNEL_ID",
          "mode": "list",
          "cachedResultName": "#contract-reviews"
        },
        "text": "=\ud83d\udcdd *Contract Review Complete*\n\n*File:* {{ $('Compile Review').item.json.fileName }}\n*Type:* {{ $('Compile Review').item.json.contractType }}\n*Parties:* {{ $('Compile Review').item.json.partiesList }}\n\n\ud83d\udccb *Executive Summary*\n{{ $('Compile Review').item.json.executiveSummary }}\n\n\u26a0\ufe0f *Risk Assessment*\n\u2022 High Risks: {{ $('Compile Review').item.json.highRiskCount }}\n\u2022 Medium Risks: {{ $('Compile Review').item.json.mediumRiskCount }}\n\n{{ $('Compile Review').item.json.risksList }}\n\n\ud83c\udff7\ufe0f *Status:* {{ $('Compile Review').item.json.reviewStatus }}\n\n<https://drive.google.com/file/d/{{ $('Compile Review').item.json.fileId }}/view|View Contract>",
        "otherOptions": {}
      },
      "id": "0e950e68-35d9-4b59-ad24-109028c95e0b",
      "name": "Send Review Report",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.1,
      "position": [
        1648,
        64
      ],
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download Contract",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Contract": {
      "main": [
        [
          {
            "node": "PDF Vector - Analyze Contract",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "PDF Vector - Analyze Contract": {
      "main": [
        [
          {
            "node": "Merge Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Data": {
      "main": [
        [
          {
            "node": "PDF Vector - Executive Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDF Vector - Executive Summary": {
      "main": [
        [
          {
            "node": "Compile Review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compile Review": {
      "main": [
        [
          {
            "node": "Log Contract Review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Contract Review": {
      "main": [
        [
          {
            "node": "Send Review Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": [
    {
      "name": "Legal"
    },
    {
      "name": "PDF Vector"
    },
    {
      "name": "Contracts"
    }
  ]
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

About this workflow

AI Contract Review & Risk Analysis. Uses googleDriveTrigger, googleDrive, n8n-nodes-pdfvector, googleSheets. Event-driven trigger; 10 nodes.

Source: https://github.com/khanhduyvt0101/workflows/blob/main/n8n-workflows/contract-review-risk-analysis.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →