{
  "id": "bDdmYkhVQFWWfoNs",
  "meta": {
    "instanceId": "b91e510ebae4127f953fd2f5f8d40d58ca1e71c746d4500c12ae86aad04c1502"
  },
  "name": "Intelligent Contract Lifecycle & Vendor Optimization System",
  "tags": [],
  "nodes": [
    {
      "id": "0e97c8ae-98f9-45ea-931e-20fea5a624bc",
      "name": "Daily Contract Monitor",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1248,
        256
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 6
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "12f1b39b-cc68-4ffb-8a1c-bf8ed0553f7a",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -1024,
        256
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "contractApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Contract Management System API URL__>"
            },
            {
              "id": "id-2",
              "name": "financialSystemApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Financial Planning System API URL__>"
            },
            {
              "id": "id-3",
              "name": "expirationThresholdDays",
              "type": "number",
              "value": 90
            },
            {
              "id": "id-4",
              "name": "pricingAnomalyThreshold",
              "type": "number",
              "value": 15
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "dec0261e-79aa-4bfd-aeef-af4388e19bd8",
      "name": "Contract Analysis Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -576,
        256
      ],
      "parameters": {
        "text": "=Contract data to analyze: {{ JSON.stringify($json) }}",
        "options": {
          "systemMessage": "=You are a contract management specialist analyzing vendor contracts across multiple properties.\n\nYour task is to:\n1. Review each contract for expiration dates within the next {{ $('Workflow Configuration').first().json.expirationThresholdDays }} days\n2. Detect pricing anomalies (increases exceeding {{ $('Workflow Configuration').first().json.pricingAnomalyThreshold }}% compared to market rates or previous terms)\n3. Identify renewal opportunities or risks\n4. Flag contracts requiring immediate attention\n5. Categorize issues by severity (critical, high, medium, low)\n\nReturn your analysis in the structured format defined by the output parser."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "6e59f836-eb80-41ec-bad3-5be017fd2c77",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -576,
        480
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "credential-id",
          "name": "openAiApi Credential"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "a33d400c-441a-40a8-8c02-29cc30cac4bc",
      "name": "Contract Analysis Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -368,
        480
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"contractId\": {\n      \"type\": \"string\"\n    },\n    \"vendorName\": {\n      \"type\": \"string\"\n    },\n    \"issueDetected\": {\n      \"type\": \"boolean\"\n    },\n    \"issueType\": {\n      \"type\": \"string\",\n      \"enum\": [\"expiring\", \"pricing_anomaly\", \"renewal_risk\"]\n    },\n    \"severity\": {\n      \"type\": \"string\",\n      \"enum\": [\"critical\", \"high\", \"medium\", \"low\"]\n    },\n    \"expirationDate\": {\n      \"type\": \"string\"\n    },\n    \"currentPrice\": {\n      \"type\": \"number\"\n    },\n    \"pricingChange\": {\n      \"type\": \"number\"\n    },\n    \"recommendation\": {\n      \"type\": \"string\"\n    },\n    \"requiresAction\": {\n      \"type\": \"boolean\"\n    }\n  }\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "a258f2cd-3c7c-4c37-96cf-fc5cafd45a4e",
      "name": "Check for Issues",
      "type": "n8n-nodes-base.if",
      "position": [
        -224,
        256
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ $json.issueDetected }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "1ce4cf8e-2153-483b-8d74-77428ee29e28",
      "name": "Negotiation Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        16,
        208
      ],
      "parameters": {
        "text": "=Contract requiring negotiation: {{ JSON.stringify($json) }}",
        "options": {
          "systemMessage": "You are an AI-powered contract negotiation specialist with expertise in vendor management and cost optimization.\n\nYour task is to:\n1. Analyze the contract issue and develop negotiation strategies\n2. Research market rates and competitive alternatives for the service\n3. Generate negotiation talking points and leverage factors\n4. Recommend whether to negotiate extension, seek replacement vendor, or renegotiate terms\n5. Estimate potential cost savings or risk mitigation value\n6. Draft initial outreach communication to vendor\n\nConsider factors like:\n- Contract history and vendor relationship\n- Market conditions and alternatives\n- Service criticality and switching costs\n- Negotiation leverage and timing\n\nReturn your recommendations in the structured format defined by the output parser."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "cce4931c-472c-4400-ba44-2465c91fe76f",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        16,
        432
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "credential-id",
          "name": "openAiApi Credential"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "5d25f723-5e67-4d2a-9c2d-8f69bd2bf788",
      "name": "Negotiation Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        176,
        416
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"contractId\": {\n      \"type\": \"string\"\n    },\n    \"negotiationStrategy\": {\n      \"type\": \"string\",\n      \"enum\": [\"extend\", \"replace\", \"renegotiate\"]\n    },\n    \"marketRate\": {\n      \"type\": \"number\"\n    },\n    \"competitiveAlternatives\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      }\n    },\n    \"leverageFactors\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      }\n    },\n    \"estimatedSavings\": {\n      \"type\": \"number\"\n    },\n    \"riskLevel\": {\n      \"type\": \"string\"\n    },\n    \"recommendedAction\": {\n      \"type\": \"string\"\n    },\n    \"draftCommunication\": {\n      \"type\": \"string\"\n    },\n    \"timeline\": {\n      \"type\": \"string\"\n    }\n  }\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "fad55f54-c7ce-43e8-a308-69ea69d29074",
      "name": "Financial Impact Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        352,
        208
      ],
      "parameters": {
        "text": "=Negotiation recommendation to analyze: {{ JSON.stringify($json) }}",
        "options": {
          "systemMessage": "You are a financial analyst specializing in CAPEX/OPEX planning and contract financial impact assessment.\n\nYour task is to:\n1. Calculate the financial impact of the proposed negotiation strategy\n2. Compare current contract costs vs. proposed changes\n3. Project annual and multi-year financial implications\n4. Categorize impacts as CAPEX or OPEX\n5. Assess ROI and payback period for contract changes\n6. Identify budget allocation adjustments needed\n7. Generate executive summary of financial recommendations\n\nProvide detailed financial analysis including:\n- Current annual cost\n- Projected cost with changes\n- Net savings/cost increase\n- CAPEX vs OPEX breakdown\n- Budget impact timeline\n- Risk-adjusted financial projections\n\nReturn your analysis in the structured format defined by the output parser."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "d283afe7-664e-499c-bfdf-abc03bd1e26e",
      "name": "OpenAI Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        368,
        432
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "credential-id",
          "name": "openAiApi Credential"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "6f3540ac-a426-4e09-890c-974d0e271ae3",
      "name": "Financial Impact Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        592,
        432
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"contractId\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"currentAnnualCost\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"projectedAnnualCost\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"netSavings\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"savingsPercentage\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"capexImpact\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"opexImpact\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"paybackPeriodMonths\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"roi\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"budgetAdjustments\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"properties\": {\n\t\t\t\t\"quarter\": {\n\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t},\n\t\t\t\t\"amount\": {\n\t\t\t\t\t\"type\": \"number\"\n\t\t\t\t},\n\t\t\t\t\"category\": {\n\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"riskAdjustedSavings\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"executiveSummary\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"recommendApproval\": {\n\t\t\t\"type\": \"boolean\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "5ff4953e-68ad-4e55-84cb-88b4bac12c7b",
      "name": "Update CAPEX/OPEX Plans",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        656,
        208
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.financialSystemApiUrl }}/budget/update",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ $json }}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "a8f42139-7505-4642-a084-4bad0543e094",
      "name": "No Issues - Log Status",
      "type": "n8n-nodes-base.set",
      "position": [
        48,
        560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "status",
              "type": "string",
              "value": "no_issues_detected"
            },
            {
              "id": "id-2",
              "name": "message",
              "type": "string",
              "value": "Contract analysis completed - no issues requiring action"
            },
            {
              "id": "id-3",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            },
            {
              "id": "id-4",
              "name": "contractId",
              "type": "string",
              "value": "={{ $json.contractId }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e94d606e-ae16-4b30-8906-ef9580bb0ff2",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -208
      ],
      "parameters": {
        "color": 4,
        "width": 368,
        "height": 224,
        "content": "## Prerequisites\nContract management system or data source; OpenAI API key; negotiation agent access \n\n## Use Cases\nCorporate legal departments automating contract risk assessment across portfolios "
      },
      "typeVersion": 1
    },
    {
      "id": "85932b02-6e18-44ba-8609-187ca3f4f925",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        -208
      ],
      "parameters": {
        "width": 368,
        "height": 224,
        "content": "## Setup Steps\n1. Configure contract data source and set up daily monitoring schedule.\n2. Connect OpenAI GPT-4 API  \n3. Set up negotiation agent credentials and financial modeling system connections.\n4. Define contract risk thresholds "
      },
      "typeVersion": 1
    },
    {
      "id": "fe0cecc1-4ba6-47b2-bb0d-20bb8e6b71b7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1248,
        -224
      ],
      "parameters": {
        "width": 720,
        "height": 256,
        "content": "## How It Works\nThis workflow automates daily contract monitoring, analysis, and negotiation by retrieving contract data, applying AI-driven legal analysis, identifying potential issues and risks, coordinating multi-agent negotiation workflows, and updating strategic plans. It continuously monitors contracts, performs GPT-4–based contract analysis with detailed risk identification, and flags problematic clauses and unfavorable terms. The system routes identified items to a negotiation agent for structured strategic discussion, applies financial impact analysis to evaluate deal implications, determines negotiation outcomes, logs decisions and results, and updates CAPEX and OPEX planning systems accordingly. Designed for legal departments, procurement teams, corporate counsel, and contract management offices, it supports automated contract risk assessment, informed negotiations, and data-driven strategic planning."
      },
      "typeVersion": 1
    },
    {
      "id": "bc22fb65-b133-4804-806f-ccf383be07f7",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        -208
      ],
      "parameters": {
        "color": 5,
        "width": 448,
        "height": 224,
        "content": "## Customization\nAdjust contract analysis criteria and risk thresholds \n\n## Benefits\nEliminates manual contract review, identifies hidden risks automatically "
      },
      "typeVersion": 1
    },
    {
      "id": "2d7c866d-818b-4d58-8d52-ee5236328276",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        64
      ],
      "parameters": {
        "color": 7,
        "width": 656,
        "height": 544,
        "content": "## Fetch & Monitor Contracts\nWhat: Retrieves contract data daily and tracks status across portfolio.\nWhy: Enables proactive monitoring and early identification of critical issues."
      },
      "typeVersion": 1
    },
    {
      "id": "257d4ab5-86c4-40a3-aa6d-79d4255fb73e",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        64
      ],
      "parameters": {
        "color": 7,
        "width": 928,
        "height": 704,
        "content": "## Route to Negotiation & Assess Financial Impact with Updating\nWhat: Forwards analysis to negotiation agent for strategic discussion.\nWhy: Enables intelligent, context-aware negotiation strategy based on legal analysis."
      },
      "typeVersion": 1
    },
    {
      "id": "d775dea4-cae2-459e-9b23-d1b38ce8746d",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        64
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 688,
        "content": "## Analyze Contract Terms\nWhat: Uses GPT-4 to analyze clauses, identify risks, flag problematic terms.\nWhy: Surfaces legal risks and negotiation opportunities  "
      },
      "typeVersion": 1
    },
    {
      "id": "37bedc01-6b6e-44eb-8c44-e1be01543a69",
      "name": "Fetch Contract Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -800,
        256
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.contractApiUrl }}/contracts",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "status",
              "value": "active"
            }
          ]
        }
      },
      "typeVersion": 4.3
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "5fc73125-a28b-422b-90be-fbd5bab0d4f4",
  "connections": {
    "Check for Issues": {
      "main": [
        [
          {
            "node": "Negotiation Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Issues - Log Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Negotiation Agent": {
      "main": [
        [
          {
            "node": "Financial Impact Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Contract Analysis Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Negotiation Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Financial Impact Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Contract Data": {
      "main": [
        [
          {
            "node": "Contract Analysis Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Contract Monitor": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Financial Impact Agent": {
      "main": [
        [
          {
            "node": "Update CAPEX/OPEX Plans",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Fetch Contract Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Contract Analysis Agent": {
      "main": [
        [
          {
            "node": "Check for Issues",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Negotiation Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Negotiation Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Financial Impact Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Financial Impact Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Contract Analysis Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Contract Analysis Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}