{
  "id": "329TKIMcSCOoNN25",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Legal Case Intake and Contract Analysis Automation",
  "tags": [],
  "nodes": [
    {
      "id": "c998dd51-6432-4039-b99c-2ff388868e14",
      "name": "Case/Contract Intake Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -80,
        80
      ],
      "parameters": {
        "path": "case-intake",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "lastNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "bbe71f9f-4925-4cba-9527-ff8c852752bb",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        144,
        80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "litigationAttorney",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Litigation attorney Slack user ID__>"
            },
            {
              "id": "id-2",
              "name": "corporateAttorney",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Corporate attorney Slack user ID__>"
            },
            {
              "id": "id-3",
              "name": "familyLawAttorney",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Family Law attorney Slack user ID__>"
            },
            {
              "id": "id-4",
              "name": "sheetsDocumentId",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Google Sheets document ID__>"
            },
            {
              "id": "id-5",
              "name": "calendarId",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Google Calendar ID__>"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "4f8f41aa-c559-4ddd-8e0b-125aae55d200",
      "name": "Normalize Client and Case Info",
      "type": "n8n-nodes-base.set",
      "position": [
        368,
        80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "clientName",
              "type": "string",
              "value": "={{ $json.body.clientName || \"Unknown Client\" }}"
            },
            {
              "id": "id-2",
              "name": "clientEmail",
              "type": "string",
              "value": "={{ $json.body.clientEmail }}"
            },
            {
              "id": "id-3",
              "name": "caseType",
              "type": "string",
              "value": "={{ $json.body.caseType }}"
            },
            {
              "id": "id-4",
              "name": "caseDescription",
              "type": "string",
              "value": "={{ $json.body.caseDescription }}"
            },
            {
              "id": "id-5",
              "name": "intakeDate",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "74134bf8-d70b-4cff-b7fa-a8800dedc3da",
      "name": "Extract Contract Text",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        592,
        80
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1.1
    },
    {
      "id": "1890862e-dbe8-477a-982c-395fa6bc85c6",
      "name": "Analyze Contract and Extract Clauses",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        816,
        80
      ],
      "parameters": {
        "text": "=Contract text to analyze: {{ $json.text }}",
        "options": {
          "systemMessage": "You are a legal contract analysis assistant. Your task is to analyze the provided contract text and extract key information.\n\nExtract the following information:\n1. Contract parties (all parties involved)\n2. Contract type (e.g., employment, service agreement, lease, etc.)\n3. Key obligations for each party\n4. Important dates (effective date, termination date, renewal dates)\n5. Payment terms and amounts\n6. Termination clauses\n7. Liability and indemnification clauses\n8. Dispute resolution mechanisms\n9. Governing law and jurisdiction\n10. Any unusual or high-risk clauses\n\nReturn the extracted information in the structured JSON format defined by the output parser."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "83e81479-381a-4066-8cb5-2ad46d84a7c4",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        824,
        304
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "68d21fb0-1b9a-4063-8a1f-4dafb596787d",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        952,
        304
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"parties\": {\n      \"type\": \"array\",\n      \"items\": {\"type\": \"string\"},\n      \"description\": \"All parties involved in the contract\"\n    },\n    \"contractType\": {\n      \"type\": \"string\",\n      \"description\": \"Type of contract\"\n    },\n    \"keyObligations\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"party\": {\"type\": \"string\"},\n          \"obligation\": {\"type\": \"string\"}\n        }\n      }\n    },\n    \"importantDates\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"effectiveDate\": {\"type\": \"string\"},\n        \"terminationDate\": {\"type\": \"string\"},\n        \"renewalDates\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}\n      }\n    },\n    \"paymentTerms\": {\n      \"type\": \"string\",\n      \"description\": \"Payment terms and amounts\"\n    },\n    \"terminationClauses\": {\n      \"type\": \"string\",\n      \"description\": \"Summary of termination clauses\"\n    },\n    \"liabilityIndemnification\": {\n      \"type\": \"string\",\n      \"description\": \"Liability and indemnification details\"\n    },\n    \"disputeResolution\": {\n      \"type\": \"string\",\n      \"description\": \"Dispute resolution mechanism\"\n    },\n    \"governingLaw\": {\n      \"type\": \"string\",\n      \"description\": \"Governing law and jurisdiction\"\n    },\n    \"riskyClauses\": {\n      \"type\": \"array\",\n      \"items\": {\"type\": \"string\"},\n      \"description\": \"Unusual or high-risk clauses\"\n    }\n  },\n  \"required\": [\"parties\", \"contractType\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "b0db167d-b191-4dcb-93e7-816cba2dca26",
      "name": "Route by Case Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        1168,
        48
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Litigation",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.caseType }}",
                    "rightValue": "Litigation"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Corporate",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.caseType }}",
                    "rightValue": "Corporate"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Family Law",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.caseType }}",
                    "rightValue": "Family Law"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Other"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7aab1556-bc98-4c48-b6da-17c0b5746dc7",
      "name": "Log Case and Contract Info",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1392,
        80
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "clientEmail"
          ]
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Case Log"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').first().json.sheetsDocumentId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "dfe0a096-470c-4e83-b8bd-c9ed142889d9",
      "name": "Notify Responsible Attorney",
      "type": "n8n-nodes-base.slack",
      "position": [
        1616,
        80
      ],
      "parameters": {
        "select": "channel",
        "blocksUi": "=[\n  {\n    \"type\": \"header\",\n    \"text\": {\n      \"type\": \"plain_text\",\n      \"text\": \"\ud83d\udd14 New Case Intake: {{ $json.caseType }}\"\n    }\n  },\n  {\n    \"type\": \"section\",\n    \"fields\": [\n      {\n        \"type\": \"mrkdwn\",\n        \"text\": \"*Client:*\\n{{ $json.clientName }}\"\n      },\n      {\n        \"type\": \"mrkdwn\",\n        \"text\": \"*Email:*\\n{{ $json.clientEmail }}\"\n      },\n      {\n        \"type\": \"mrkdwn\",\n        \"text\": \"*Case Type:*\\n{{ $json.caseType }}\"\n      },\n      {\n        \"type\": \"mrkdwn\",\n        \"text\": \"*Intake Date:*\\n{{ $json.intakeDate }}\"\n      }\n    ]\n  },\n  {\n    \"type\": \"section\",\n    \"text\": {\n      \"type\": \"mrkdwn\",\n      \"text\": \"*Case Description:*\\n{{ $json.caseDescription }}\"\n    }\n  },\n  {\n    \"type\": \"section\",\n    \"text\": {\n      \"type\": \"mrkdwn\",\n      \"text\": \"*Contract Analysis Summary:*\\n\u2022 Parties: {{ $json.output.parties.join(', ') }}\\n\u2022 Contract Type: {{ $json.output.contractType }}\\n\u2022 Payment Terms: {{ $json.output.paymentTerms }}\"\n    }\n  }\n]",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.caseType === \"Litigation\" ? $('Workflow Configuration').first().json.litigationAttorney : $json.caseType === \"Corporate\" ? $('Workflow Configuration').first().json.corporateAttorney : $('Workflow Configuration').first().json.familyLawAttorney }}"
        },
        "messageType": "block",
        "otherOptions": {}
      },
      "typeVersion": 2.4
    },
    {
      "id": "96ec7424-958d-4e8e-bc81-883d6c8a55bb",
      "name": "Send Summary to Client",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1840,
        80
      ],
      "parameters": {
        "html": "=<html>\n<body>\n<h2>Dear {{ $json.clientName }},</h2>\n<p>Thank you for submitting your case to our firm. We have completed an initial review of your contract.</p>\n\n<h3>Case Information</h3>\n<ul>\n<li><strong>Case Type:</strong> {{ $json.caseType }}</li>\n<li><strong>Intake Date:</strong> {{ $json.intakeDate }}</li>\n</ul>\n\n<h3>Contract Analysis Summary</h3>\n<ul>\n<li><strong>Parties:</strong> {{ $json.output.parties.join(', ') }}</li>\n<li><strong>Contract Type:</strong> {{ $json.output.contractType }}</li>\n<li><strong>Payment Terms:</strong> {{ $json.output.paymentTerms }}</li>\n<li><strong>Governing Law:</strong> {{ $json.output.governingLaw }}</li>\n</ul>\n\n<p>Your assigned attorney will contact you within 24-48 hours to discuss next steps.</p>\n\n<p>Best regards,<br>Legal Team</p>\n</body>\n</html>",
        "options": {},
        "subject": "=Contract Review Summary - {{ $json.clientName }}",
        "toEmail": "={{ $json.clientEmail }}",
        "fromEmail": "<__PLACEHOLDER_VALUE__Law firm email address__>"
      },
      "typeVersion": 2.1
    },
    {
      "id": "7b5f569d-9e8f-4be7-92d9-c60b585219c5",
      "name": "Generate Contract Review PDF",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        2064,
        80
      ],
      "parameters": {
        "options": {
          "fileName": "={{ 'Contract_Review_' + $json.clientName + '_' + $now.toFormat('yyyy-MM-dd') + '.pdf' }}"
        },
        "operation": "html"
      },
      "typeVersion": 1.1
    },
    {
      "id": "be862047-165e-4656-8f03-d568b2377997",
      "name": "Schedule Case Follow-ups",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        2288,
        80
      ],
      "parameters": {
        "end": "={{ $now.plus({ days: 7, hours: 1 }).toISO() }}",
        "start": "={{ $now.plus({ days: 7 }).toISO() }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').first().json.calendarId }}"
        },
        "additionalFields": {
          "summary": "=Case Follow-up: {{ $json.clientName }} - {{ $json.caseType }}",
          "description": "=Follow-up meeting for case intake on {{ $json.intakeDate }}. Client: {{ $json.clientName }} ({{ $json.clientEmail }}). Case Type: {{ $json.caseType }}."
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "79743dc1-5fbf-4c3f-b8e5-772e8d9b9e00",
      "name": "Integrate with Practice Management Software",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2512,
        80
      ],
      "parameters": {
        "url": "<__PLACEHOLDER_VALUE__Practice management software API endpoint__>",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"clientName\": {{ $json.clientName }},\n  \"clientEmail\": {{ $json.clientEmail }},\n  \"caseType\": {{ $json.caseType }},\n  \"caseDescription\": {{ $json.caseDescription }},\n  \"intakeDate\": {{ $json.intakeDate }},\n  \"contractAnalysis\": {{ $json.output }}\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType"
      },
      "typeVersion": 4.3
    },
    {
      "id": "f7c7ecc9-e8df-4975-b0af-08c08c41d572",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 656,
        "content": "## Webhook & Config"
      },
      "typeVersion": 1
    },
    {
      "id": "bb68c09f-2974-4d5a-97b0-7eccdbbff188",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "height": 656,
        "content": "## AI logic & Routing"
      },
      "typeVersion": 1
    },
    {
      "id": "c674885e-db6f-4fe0-99fc-9f6acc8a4094",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 864,
        "height": 656,
        "content": "## Log & Notify"
      },
      "typeVersion": 1
    },
    {
      "id": "50377225-f278-4be5-8a07-b8125009a67c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2240,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 656,
        "content": "## Scheduling "
      },
      "typeVersion": 1
    },
    {
      "id": "efc1d1c9-efb0-4bac-a064-265f2881ab78",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -112
      ],
      "parameters": {
        "width": 336,
        "height": 560,
        "content": "## Main\nAutomates law firm case and contract management. AI extracts key contract clauses, routes cases to appropriate attorneys, logs details, sends client summaries, and schedules follow-ups.\n\n## Setup\n1. Connect Webhook for new contracts/cases\n2. Connect OpenAI for contract analysis\n3. Connect Google Sheets for case logging\n4. Connect Slack for attorney notifications\n5. Connect email for client summaries\n6. Connect PDF generation node\n7. Connect calendar for follow-ups\n8. Optional integration with practice management software\n\n**Author:** Hyrum Hurst, AI Automation Engineer\n**Company:** QuarterSmart\n**Contact:** hyrum@quartersmart.com\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ecc90292-4fa5-470b-b8b5-b0c6839851dc",
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze Contract and Extract Clauses",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Route by Case Type": {
      "main": [
        [
          {
            "node": "Log Case and Contract Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Contract Text": {
      "main": [
        [
          {
            "node": "Analyze Contract and Extract Clauses",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Summary to Client": {
      "main": [
        [
          {
            "node": "Generate Contract Review PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Normalize Client and Case Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Case Follow-ups": {
      "main": [
        [
          {
            "node": "Integrate with Practice Management Software",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Analyze Contract and Extract Clauses",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Log Case and Contract Info": {
      "main": [
        [
          {
            "node": "Notify Responsible Attorney",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Responsible Attorney": {
      "main": [
        [
          {
            "node": "Send Summary to Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Case/Contract Intake Webhook": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Contract Review PDF": {
      "main": [
        [
          {
            "node": "Schedule Case Follow-ups",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Client and Case Info": {
      "main": [
        [
          {
            "node": "Extract Contract Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Contract and Extract Clauses": {
      "main": [
        [
          {
            "node": "Route by Case Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}