{
  "name": "Lease Agreement Analyzer for Renters",
  "nodes": [
    {
      "parameters": {
        "content": "## \ud83c\udfe0 Lease Agreement Analyzer\n\n### What this workflow does\n1. Watches Drive for new lease PDFs\n2. Extracts rent, deposits, terms\n3. Flags red flags and unusual clauses\n4. Generates tenant advice\n5. Logs to comparison spreadsheet\n6. Alerts on high-risk leases\n\n### Setup steps\n1. Create \"Leases\" folder in Drive\n2. Get PDF Vector API key from pdfvector.com/api-keys\n3. Create Google Sheet with columns below\n4. Connect Slack for notifications\n5. Update folder ID, Sheet ID, channel ID\n\n### Sheet columns\nProperty Address, Landlord, Tenants, Monthly Rent, Security Deposit, Move-In Cost, Lease Start, Lease End, Pet Policy, Utilities Included, Late Fee, Early Termination, Red Flags, Risk Level, Tenant Advice, Analyzed Date\n\n### Perfect for\n- Renters reviewing leases\n- Property managers\n- Real estate agents",
        "height": 520,
        "width": 320,
        "color": 5
      },
      "id": "sticky-main",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        60,
        80
      ]
    },
    {
      "parameters": {
        "content": "## \ud83d\udea9 Red Flag Detection\n\nFlags these issues:\n- Excessive fees\n- Unreasonable penalties\n- Unusual clauses\n- Missing tenant protections\n- Vague language\n\n### Risk Levels\n- High: 2+ high-severity flags\n- Medium: 1 high or 3+ total flags\n- Low: Minor or no issues",
        "height": 240,
        "width": 260
      },
      "id": "sticky-flags",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        400,
        80
      ]
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "YOUR_FOLDER_ID",
          "mode": "list"
        },
        "event": "fileCreated",
        "options": {}
      },
      "id": "gdrive-trigger",
      "name": "Google Drive Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        140,
        340
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {}
      },
      "id": "gdrive-download",
      "name": "Download Lease",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        340,
        340
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "extract",
        "inputType": "file",
        "prompt": "Analyze this residential lease agreement and extract as flat fields. propertyAddress, landlordName, landlordCompany, landlordPhone, landlordEmail, tenantNames (comma-separated all tenant names), monthlyRent (number), securityDeposit (number), leaseStart (YYYY-MM-DD), leaseEnd (YYYY-MM-DD), leaseTerm, renewalTerms, autoRenewal (true/false), moveOutNotice (number of days), petsAllowed (true/false), petDeposit (number), petRent (number), petRestrictions, utilitiesIncluded (comma-separated list), parkingIncluded (true/false), parkingFee (number), latePaymentGracePeriod (number of days), latePaymentFee (number), earlyTerminationPenalty, landlordResponsibilities (semicolon-separated list), tenantResponsibilities (semicolon-separated list), highRedFlags (semicolon-separated HIGH severity issues), mediumRedFlags (semicolon-separated MEDIUM severity issues), lowRedFlags (semicolon-separated LOW severity issues), totalRedFlagCount (number).",
        "schema": "{\"type\": \"object\", \"properties\": {\"propertyAddress\": {\"type\": \"string\"}, \"landlordName\": {\"type\": \"string\"}, \"landlordCompany\": {\"type\": \"string\"}, \"landlordPhone\": {\"type\": \"string\"}, \"landlordEmail\": {\"type\": \"string\"}, \"tenantNames\": {\"type\": \"string\"}, \"monthlyRent\": {\"type\": \"number\"}, \"securityDeposit\": {\"type\": \"number\"}, \"leaseStart\": {\"type\": \"string\"}, \"leaseEnd\": {\"type\": \"string\"}, \"leaseTerm\": {\"type\": \"string\"}, \"renewalTerms\": {\"type\": \"string\"}, \"autoRenewal\": {\"type\": \"boolean\"}, \"moveOutNotice\": {\"type\": \"number\"}, \"petsAllowed\": {\"type\": \"boolean\"}, \"petDeposit\": {\"type\": \"number\"}, \"petRent\": {\"type\": \"number\"}, \"petRestrictions\": {\"type\": \"string\"}, \"utilitiesIncluded\": {\"type\": \"string\"}, \"parkingIncluded\": {\"type\": \"boolean\"}, \"parkingFee\": {\"type\": \"number\"}, \"latePaymentGracePeriod\": {\"type\": \"number\"}, \"latePaymentFee\": {\"type\": \"number\"}, \"earlyTerminationPenalty\": {\"type\": \"string\"}, \"landlordResponsibilities\": {\"type\": \"string\"}, \"tenantResponsibilities\": {\"type\": \"string\"}, \"highRedFlags\": {\"type\": \"string\"}, \"mediumRedFlags\": {\"type\": \"string\"}, \"lowRedFlags\": {\"type\": \"string\"}, \"totalRedFlagCount\": {\"type\": \"number\"}}, \"additionalProperties\": false}"
      },
      "id": "pdfvector-extract",
      "name": "PDF Vector - Analyze Lease",
      "type": "n8n-nodes-pdfvector.pdfVector",
      "typeVersion": 2,
      "position": [
        540,
        340
      ],
      "credentials": {
        "pdfVectorApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "combine",
        "combinationMode": "mergeByPosition",
        "options": {}
      },
      "id": "merge",
      "name": "Merge Data",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        740,
        340
      ]
    },
    {
      "parameters": {
        "operation": "ask",
        "inputType": "file",
        "question": "As a tenant advocate reviewing this lease agreement, provide:\n\n1. SUMMARY (2-3 sentences): Brief overview of this lease - is it standard or does it have unusual terms?\n\n2. TOP 3 NEGOTIATION POINTS: What should the tenant try to negotiate or get clarified before signing? Be specific.\n\n3. FAIRNESS RATING: Rate this lease as one of:\n   - Tenant-Friendly (favorable terms for renter)\n   - Neutral (standard/balanced terms)\n   - Landlord-Friendly (favors property owner)\n   Include a brief justification.\n\n4. WARNINGS: Any terms that could cause problems during tenancy or at move-out?"
      },
      "id": "pdfvector-advice",
      "name": "PDF Vector - Tenant Advice",
      "type": "n8n-nodes-pdfvector.pdfVector",
      "typeVersion": 2,
      "position": [
        940,
        340
      ],
      "credentials": {
        "pdfVectorApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const lease = $('PDF Vector - Analyze Lease').item.json.data || $('PDF Vector - Analyze Lease').item.json;\nconst advice = $input.first().json.answer || $input.first().json.markdown || '';\nconst fileName = $('Google Drive Trigger').item.json.name;\n\nconst monthlyRent = parseFloat(lease.monthlyRent) || 0;\nconst securityDeposit = parseFloat(lease.securityDeposit) || 0;\nconst petDeposit = parseFloat(lease.petDeposit) || 0;\nconst moveInCost = monthlyRent + securityDeposit + petDeposit;\n\nconst landlordInfo = [lease.landlordName, lease.landlordCompany].filter(Boolean).join(' (').replace(/(.+)/, '$1)').replace(/^(.+)\\)$/, '$1') || 'Not specified';\n\nlet petSummary = 'Not specified';\nif (lease.petsAllowed === true) {\n  petSummary = 'Allowed';\n  if (petDeposit) petSummary += ` - Deposit: $${petDeposit}`;\n  if (lease.petRent) petSummary += `, Monthly: $${lease.petRent}`;\n  if (lease.petRestrictions) petSummary += ` (${lease.petRestrictions})`;\n} else if (lease.petsAllowed === false) { petSummary = 'Not allowed'; }\n\nconst lateFee = lease.latePaymentFee\n  ? `$${lease.latePaymentFee} after ${lease.latePaymentGracePeriod || 0} days`\n  : 'Not specified';\n\nconst highFlags = (lease.highRedFlags || '').split(';').map(f => f.trim()).filter(Boolean);\nconst medFlags  = (lease.mediumRedFlags || '').split(';').map(f => f.trim()).filter(Boolean);\nconst lowFlags  = (lease.lowRedFlags || '').split(';').map(f => f.trim()).filter(Boolean);\nconst allFlags  = [\n  ...highFlags.map(f => `[High] ${f}`),\n  ...medFlags.map(f  => `[Medium] ${f}`),\n  ...lowFlags.map(f  => `[Low] ${f}`)\n];\nconst flagsSummary = allFlags.join('; ') || 'None identified';\n\nlet riskLevel = 'Low';\nif (highFlags.length >= 2) riskLevel = 'High';\nelse if (highFlags.length === 1 || allFlags.length >= 3) riskLevel = 'Medium';\n\nconst adviceShort = advice && advice.length > 500 ? advice.substring(0, 500) + '...' : advice;\n\nreturn [{ json: {\n  propertyAddress:  lease.propertyAddress  || 'Not specified',\n  landlord:         landlordInfo,\n  tenants:          lease.tenantNames       || 'Not specified',\n  monthlyRent,\n  securityDeposit,\n  moveInCost,\n  leaseStart:       lease.leaseStart        || 'Not specified',\n  leaseEnd:         lease.leaseEnd          || 'Not specified',\n  leaseTerm:        lease.leaseTerm         || 'Not specified',\n  autoRenewal:      lease.autoRenewal ? 'Yes' : 'No',\n  petPolicy:        petSummary,\n  utilities:        lease.utilitiesIncluded || 'None included',\n  lateFee,\n  earlyTermination: lease.earlyTerminationPenalty || 'Not specified',\n  moveOutNotice:    lease.moveOutNotice ? `${lease.moveOutNotice} days` : 'Not specified',\n  flagsSummary,\n  riskLevel,\n  tenantAdvice:      advice,\n  tenantAdviceShort: adviceShort,\n  fileName,\n  fileId: $('Google Drive Trigger').item.json.id,\n  processedAt: new Date().toISOString()\n}}];"
      },
      "id": "compile-analysis",
      "name": "Compile Analysis",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1140,
        340
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Property Address": "={{ $json.propertyAddress }}",
            "Landlord": "={{ $json.landlord }}",
            "Tenants": "={{ $json.tenants }}",
            "Monthly Rent": "={{ $json.monthlyRent }}",
            "Security Deposit": "={{ $json.securityDeposit }}",
            "Move-In Cost": "={{ $json.moveInCost }}",
            "Lease Start": "={{ $json.leaseStart }}",
            "Lease End": "={{ $json.leaseEnd }}",
            "Pet Policy": "={{ $json.petPolicy }}",
            "Utilities Included": "={{ $json.utilities }}",
            "Late Fee": "={{ $json.lateFee }}",
            "Early Termination": "={{ $json.earlyTermination }}",
            "Red Flags": "={{ $json.flagsSummary }}",
            "Risk Level": "={{ $json.riskLevel }}",
            "Tenant Advice": "={{ $json.tenantAdviceShort }}",
            "Analyzed Date": "={{ $json.processedAt.split('T')[0] }}"
          }
        },
        "options": {}
      },
      "id": "sheets-log",
      "name": "Log Lease Analysis",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.4,
      "position": [
        1340,
        340
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "high-risk-check",
              "leftValue": "={{ $('Compile Analysis').item.json.riskLevel }}",
              "rightValue": "High",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "if-high-risk",
      "name": "High Risk?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1540,
        340
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "YOUR_SLACK_CHANNEL_ID",
          "mode": "list"
        },
        "text": "=\ud83d\udea8 *High-Risk Lease Detected*\n\n*Property:* {{ $('Compile Analysis').item.json.propertyAddress }}\n*Rent:* ${{ $('Compile Analysis').item.json.monthlyRent }}/month\n*Move-In Cost:* ${{ $('Compile Analysis').item.json.moveInCost }}\n\n\u26a0\ufe0f *Red Flags:* {{ $('Compile Analysis').item.json.flagsSummary }}\n\n\ud83d\udccb Review before signing!",
        "otherOptions": {}
      },
      "id": "slack-alert",
      "name": "High Risk Alert",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        1740,
        240
      ],
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "YOUR_SLACK_CHANNEL_ID",
          "mode": "list"
        },
        "text": "=\u2705 *Lease Analyzed*\n\n*Property:* {{ $('Compile Analysis').item.json.propertyAddress }}\n*Rent:* ${{ $('Compile Analysis').item.json.monthlyRent }}/month\n*Term:* {{ $('Compile Analysis').item.json.leaseStart }} to {{ $('Compile Analysis').item.json.leaseEnd }}\n*Risk Level:* {{ $('Compile Analysis').item.json.riskLevel }}\n\n\ud83d\udccb *File:* {{ $('Compile Analysis').item.json.fileName }}",
        "otherOptions": {}
      },
      "id": "slack-notify",
      "name": "Analysis Complete",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        1740,
        440
      ],
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download Lease",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Lease": {
      "main": [
        [
          {
            "node": "PDF Vector - Analyze Lease",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "PDF Vector - Analyze Lease": {
      "main": [
        [
          {
            "node": "Merge Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Data": {
      "main": [
        [
          {
            "node": "PDF Vector - Tenant Advice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDF Vector - Tenant Advice": {
      "main": [
        [
          {
            "node": "Compile Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compile Analysis": {
      "main": [
        [
          {
            "node": "Log Lease Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Lease Analysis": {
      "main": [
        [
          {
            "node": "High Risk?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "High Risk?": {
      "main": [
        [
          {
            "node": "High Risk Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Analysis Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "PDF Vector"
    },
    {
      "name": "Real Estate"
    },
    {
      "name": "Lease"
    },
    {
      "name": "Tenant"
    },
    {
      "name": "Contract Analysis"
    }
  ],
  "meta": {
    "templateCredsSetupCompleted": false
  }
}