{
  "id": "GucZHJuMgQFWIX3W",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI Qwen-Max Investor Portfolio Risk & Compliance Dashboard",
  "tags": [],
  "nodes": [
    {
      "id": "26bb315e-bf10-4202-9e9f-02529aea4abd",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -928,
        400
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 6
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "a946902a-a034-4d5d-a036-14d3f72b16e3",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -704,
        400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "financialApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Financial Data API Endpoint URL__>"
            },
            {
              "id": "id-2",
              "name": "operationalApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Operational Data API Endpoint URL__>"
            },
            {
              "id": "id-3",
              "name": "legalApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Legal Data API Endpoint URL__>"
            },
            {
              "id": "id-4",
              "name": "insuranceApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Insurance Data API Endpoint URL__>"
            },
            {
              "id": "id-5",
              "name": "regulatoryApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Regulatory Data API Endpoint URL__>"
            },
            {
              "id": "id-6",
              "name": "correctionWorkflowUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Correction Workflow Webhook URL__>"
            },
            {
              "id": "id-7",
              "name": "investorEmails",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Comma-separated investor email addresses__>"
            },
            {
              "id": "id-8",
              "name": "slackChannel",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Slack channel ID for alerts__>"
            },
            {
              "id": "id-9",
              "name": "riskThreshold",
              "type": "number",
              "value": 70
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "d2cef0dd-9c35-4907-8a1a-622df337c2ee",
      "name": "Fetch Financial Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -480,
        16
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.financialApiUrl }}",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "416e61b3-3712-42c3-bd7e-3f98b35ccc1a",
      "name": "Fetch Operational Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -480,
        208
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.operationalApiUrl }}",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "ab99328e-7f8b-4596-bb39-8e59054c30ce",
      "name": "Fetch Legal Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -480,
        400
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.legalApiUrl }}",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "05703848-ad9a-4c3b-93d7-41cb5bcfed0d",
      "name": "Fetch Insurance Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -480,
        592
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.insuranceApiUrl }}",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "75896017-68a2-4445-9943-e59295fb51e9",
      "name": "Fetch Regulatory Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -480,
        784
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.regulatoryApiUrl }}",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "c420708f-585f-428e-a571-77ddecb3e6ab",
      "name": "Risk Assessment AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -32,
        112
      ],
      "parameters": {
        "text": "={{ $json }}",
        "options": {
          "systemMessage": "You are an expert risk assessment and compliance analyst for real estate investment portfolios.\n\nYour task is to:\n1. Analyze the consolidated financial, operational, legal, insurance, and regulatory data for each property\n2. Calculate risk scores (0-100, where 100 is highest risk) for each category:\n   - Financial Risk: Cash flow issues, debt ratios, revenue trends\n   - Operational Risk: Maintenance issues, occupancy rates, management quality\n   - Legal Risk: Pending litigation, contract issues, zoning violations\n   - Insurance Risk: Coverage gaps, claims history, policy expiration\n   - Regulatory Risk: Code violations, permit issues, compliance gaps\n3. Calculate an overall risk score as a weighted average\n4. Identify specific compliance issues that require immediate attention\n5. Provide actionable recommendations to mitigate identified risks\n\nBe thorough, objective, and prioritize issues by severity and urgency."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "4f4feb5a-f6ca-4c0c-8b85-4a67737a742f",
      "name": "Risk Score Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        144,
        336
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"propertyId\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Unique identifier for the property\"\n\t\t},\n\t\t\"propertyName\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Name of the property\"\n\t\t},\n\t\t\"overallRiskScore\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"description\": \"Overall risk score from 0-100\"\n\t\t},\n\t\t\"financialRisk\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"description\": \"Financial risk score from 0-100\"\n\t\t},\n\t\t\"operationalRisk\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"description\": \"Operational risk score from 0-100\"\n\t\t},\n\t\t\"legalRisk\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"description\": \"Legal risk score from 0-100\"\n\t\t},\n\t\t\"insuranceRisk\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"description\": \"Insurance risk score from 0-100\"\n\t\t},\n\t\t\"regulatoryRisk\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"description\": \"Regulatory compliance risk score from 0-100\"\n\t\t},\n\t\t\"complianceIssues\": {\n\t\t\t\"type\": \"array\",\n\t\t\t\"items\": {\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t\"description\": \"List of identified compliance issues\"\n\t\t},\n\t\t\"recommendations\": {\n\t\t\t\"type\": \"array\",\n\t\t\t\"items\": {\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t\"description\": \"Recommended actions to mitigate risks\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "4913453b-8be0-4467-85c0-811ef3f891f7",
      "name": "Check for High Risk or Compliance Issues",
      "type": "n8n-nodes-base.if",
      "position": [
        320,
        112
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $('Risk Assessment AI Agent').item.json.overallRiskScore }}",
              "rightValue": "={{ $('Workflow Configuration').first().json.riskThreshold }}"
            },
            {
              "id": "id-2",
              "operator": {
                "type": "array",
                "operation": "lengthGt"
              },
              "leftValue": "={{ $('Risk Assessment AI Agent').item.json.complianceIssues }}",
              "rightValue": "0"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "8d3a89c5-c57e-47ad-a48e-66d935d82751",
      "name": "Generate Corrective Actions",
      "type": "n8n-nodes-base.code",
      "position": [
        544,
        128
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst correctionActions = [];\n\nfor (const item of items) {\n  const data = item.json;\n  \n  const action = {\n    propertyId: data.propertyId,\n    propertyName: data.propertyName,\n    overallRiskScore: data.overallRiskScore,\n    urgency: data.overallRiskScore >= 80 ? 'critical' : 'high',\n    complianceIssues: data.complianceIssues || [],\n    recommendations: data.recommendations || [],\n    timestamp: new Date().toISOString(),\n    actionType: 'risk_mitigation'\n  };\n  \n  correctionActions.push({ json: action });\n}\n\nreturn correctionActions;"
      },
      "typeVersion": 2
    },
    {
      "id": "45fd94e8-035f-4b0e-a649-7e4e33e61122",
      "name": "Trigger Correction Workflow",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        768,
        128
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.correctionWorkflowUrl }}",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ $json }}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.3
    },
    {
      "id": "b425b6cc-5f8e-4131-ba18-f575d2105b4c",
      "name": "Format Report Data",
      "type": "n8n-nodes-base.set",
      "position": [
        544,
        320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "reportTitle",
              "type": "string",
              "value": "Portfolio Risk & Compliance Report"
            },
            {
              "id": "id-2",
              "name": "reportDate",
              "type": "string",
              "value": "={{ $now.format('MMMM dd, yyyy') }}"
            },
            {
              "id": "id-3",
              "name": "propertyId",
              "type": "string",
              "value": "={{ $json.propertyId }}"
            },
            {
              "id": "id-4",
              "name": "propertyName",
              "type": "string",
              "value": "={{ $json.propertyName }}"
            },
            {
              "id": "id-5",
              "name": "overallRiskScore",
              "type": "number",
              "value": "={{ $json.overallRiskScore }}"
            },
            {
              "id": "id-6",
              "name": "riskLevel",
              "type": "string",
              "value": "={{ $json.overallRiskScore >= 80 ? 'Critical' : $json.overallRiskScore >= 60 ? 'High' : $json.overallRiskScore >= 40 ? 'Medium' : 'Low' }}"
            },
            {
              "id": "id-7",
              "name": "financialRisk",
              "type": "number",
              "value": "={{ $json.financialRisk }}"
            },
            {
              "id": "id-8",
              "name": "operationalRisk",
              "type": "number",
              "value": "={{ $json.operationalRisk }}"
            },
            {
              "id": "id-9",
              "name": "legalRisk",
              "type": "number",
              "value": "={{ $json.legalRisk }}"
            },
            {
              "id": "id-10",
              "name": "insuranceRisk",
              "type": "number",
              "value": "={{ $json.insuranceRisk }}"
            },
            {
              "id": "id-11",
              "name": "regulatoryRisk",
              "type": "number",
              "value": "={{ $json.regulatoryRisk }}"
            },
            {
              "id": "id-12",
              "name": "complianceIssues",
              "type": "string",
              "value": "={{ $json.complianceIssues.join(', ') }}"
            },
            {
              "id": "id-13",
              "name": "recommendations",
              "type": "string",
              "value": "={{ $json.recommendations.join(', ') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "752ec1eb-42c3-498e-9591-ac27f67f2d7f",
      "name": "Send Report to Investors via Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        768,
        320
      ],
      "parameters": {
        "sendTo": "={{ $('Workflow Configuration').first().json.investorEmails }}",
        "message": "=<h2>{{ $json.reportTitle }}</h2><p><strong>Report Date:</strong> {{ $json.reportDate }}</p><hr><h3>Property: {{ $json.propertyName }} ({{ $json.propertyId }})</h3><p><strong>Overall Risk Score:</strong> {{ $json.overallRiskScore }} - <span style=\"color: {{ $json.riskLevel === \"Critical\" ? \"red\" : $json.riskLevel === \"High\" ? \"orange\" : \"green\" }}\">{{ $json.riskLevel }}</span></p><h4>Risk Breakdown:</h4><ul><li>Financial Risk: {{ $json.financialRisk }}</li><li>Operational Risk: {{ $json.operationalRisk }}</li><li>Legal Risk: {{ $json.legalRisk }}</li><li>Insurance Risk: {{ $json.insuranceRisk }}</li><li>Regulatory Risk: {{ $json.regulatoryRisk }}</li></ul><h4>Compliance Issues:</h4><p>{{ $json.complianceIssues || \"None identified\" }}</p><h4>Recommendations:</h4><p>{{ $json.recommendations }}</p><hr><p><em>This is an automated report from your Portfolio Risk & Compliance AI Dashboard.</em></p>",
        "options": {},
        "subject": "=Portfolio Risk & Compliance Report - {{ $json.reportDate }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c2318ad6-30e6-4496-a257-ee19ffa4b4ae",
      "name": "Send Alert to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        992,
        128
      ],
      "parameters": {
        "text": "=:warning: *High Risk Alert - Corrective Action Triggered*\n\n*Property:* {{ $json.propertyName }} ({{ $json.propertyId }})\n*Risk Score:* {{ $json.overallRiskScore }}\n*Urgency:* {{ $json.urgency }}\n\n*Compliance Issues:*\n{{ $json.complianceIssues.join(\"\\n\") }}\n\n*Recommended Actions:*\n{{ $json.recommendations.join(\"\\n\") }}\n\n*Timestamp:* {{ $json.timestamp }}\n\nCorrection workflow has been triggered automatically.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').first().json.slackChannel }}"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "3d634aa9-0ddb-4bda-a59f-67f958baac02",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -32,
        352
      ],
      "parameters": {
        "model": "qwen/qwen-max",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "32ec8539-f824-49b6-b7da-df877116692d",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        -208,
        64
      ],
      "parameters": {
        "numberInputs": 5
      },
      "typeVersion": 3.2
    },
    {
      "id": "0f1eb7ce-a652-47e4-bc3f-3bab654e4700",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -304
      ],
      "parameters": {
        "width": 272,
        "height": 240,
        "content": "## Setup Steps\n1. Configure hourly/daily schedule trigger. \n2. Authenticate all five data APIs. \n3. Set OpenRouter credentials. \n4. Configure Slack webhook. \n5. Set Gmail for email distribution. \n6. Define risk thresholds and compliance rules."
      },
      "typeVersion": 1
    },
    {
      "id": "c16fb42b-ac7b-43be-88f2-b3b81e8034ab",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -320
      ],
      "parameters": {
        "width": 656,
        "height": 256,
        "content": "## How It Works\nAutomates financial risk evaluation by intelligently consolidating information from five critical sources: financial, operational, legal, insurance, and regulatory systems. Hourly triggers enable continuous, AI-driven risk assessment using the OpenRouter Chat Model, producing dynamic risk scores while simultaneously identifying emerging compliance gaps and potential exposure areas. High-risk findings automatically initiate corrective actions, trigger secondary investigations, and send real-time alerts through Slack notifications as well as investor email updates. Designed for financial institutions, compliance teams, risk managers, and investment firms, it provides continuous, scalable, and fully data-driven monitoring of risk across complex regulatory and operational environments."
      },
      "typeVersion": 1
    },
    {
      "id": "a3b16e6f-19fe-44b7-ba31-ffd3305b1673",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        -400
      ],
      "parameters": {
        "color": 5,
        "width": 640,
        "height": 336,
        "content": "## Prerequisites\nOpenRouter API key, five data source APIs, Slack access, Gmail account, investor contacts \n\n## Use Cases\nBanking risk audits, insurance compliance monitoring, portfolio risk tracking \n\n## Customization\nSwap AI models, modify data sources, adjust thresholds \n\n## Benefits\n90% faster risk assessment, eliminates manual aggregation "
      },
      "typeVersion": 1
    },
    {
      "id": "a81b40e2-5a4e-4905-a75f-58c4c342e7c5",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 544,
        "height": 752,
        "content": "## Risk Assessment AI & Scoring\n- Evaluates risk; generates numerical scores.\n- Extracts structured output; identifies severity.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9b1b7c8c-06df-4cb6-8ed7-b48310fd4290",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 704,
        "height": 800,
        "content": "\n## Trigger Corrections & Alert\n- Implements automated responses.\n- Generates reports; sends Slack notifications."
      },
      "typeVersion": 1
    },
    {
      "id": "8e3dd213-c923-4478-8a80-0e4ce7c12530",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 864,
        "height": 1008,
        "content": "## Schedule Trigger and Fetch Data\n- Initiates assessment hourly for continuous monitoring.\n- Aggregates five data types into unified dataset."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "600b1301-de13-4ab0-ab71-30d23d779535",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Risk Assessment AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Legal Data": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Report Data": {
      "main": [
        [
          {
            "node": "Send Report to Investors via Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Financial Data": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Insurance Data": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "Fetch Regulatory Data": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 4
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Risk Assessment AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Operational Data": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Fetch Financial Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Operational Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Legal Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Insurance Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Regulatory Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Risk Assessment AI Agent": {
      "main": [
        [
          {
            "node": "Check for High Risk or Compliance Issues",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Risk Score Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Risk Assessment AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Generate Corrective Actions": {
      "main": [
        [
          {
            "node": "Trigger Correction Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger Correction Workflow": {
      "main": [
        [
          {
            "node": "Send Alert to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for High Risk or Compliance Issues": {
      "main": [
        [
          {
            "node": "Generate Corrective Actions",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Format Report Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}