{
  "id": "9R04CU3OC8gLq0Hu",
  "name": "Autonomous Disaster Response and Property Damage Prediction System",
  "tags": [],
  "nodes": [
    {
      "id": "eef65832-1dfd-4d9d-ad29-4658b90c1e48",
      "name": "\u23f0 Check for Disaster Alerts",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -176,
        240
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "11f0264d-9f66-450a-8012-ed442dc62cf0",
      "name": "\ud83d\udd00 Combine All Alerts",
      "type": "n8n-nodes-base.merge",
      "position": [
        496,
        144
      ],
      "parameters": {
        "mode": "combine",
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "8b9fa997-b1ec-41d6-ad57-ff18d0f80553",
      "name": "\ud83d\udcca Get Property Database",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        944,
        144
      ],
      "parameters": {
        "columns": {
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "property_id"
          ]
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('\u2699\ufe0f Workflow Configuration').item.json.propertySheetName }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('\u2699\ufe0f Workflow Configuration').item.json.propertySheetId }}"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "ed17faf0-4db6-4f61-a695-d87cf719a496",
      "name": "\ud83d\udcc5 Schedule Maintenance Teams",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        1968,
        144
      ],
      "parameters": {
        "end": "={{ $json.maintenance_end_time }}",
        "start": "={{ $json.maintenance_start_time }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "636ef7d7-e2fd-4d2b-aa76-a64f795a99b8",
      "name": "\u2709\ufe0f Send Report to Property Owners",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2544,
        112
      ],
      "parameters": {
        "sendTo": "={{ $json.property_owner_email }}",
        "message": "=<h2>Property Disaster Impact Report</h2>\n<p>Dear {{ $json.property_owner_name }},</p>\n<p>Our automated monitoring system has detected a potential disaster event that may affect your property at <strong>{{ $json.property_address }}</strong>.</p>\n\n<h3>Damage Assessment:</h3>\n<ul>\n  <li><strong>Risk Level:</strong> {{ $json.damage_level }}</li>\n  <li><strong>Estimated Repair Cost:</strong> ${{ $json.estimated_repair_cost }}</li>\n  <li><strong>Insurance Claim:</strong> ${{ $json.insurance_claim_amount }}</li>\n</ul>\n\n<h3>Disaster Details:</h3>\n<p>{{ $json.disaster_description }}</p>\n\n<h3>Next Steps:</h3>\n<p>{{ $json.recommended_actions }}</p>\n\n<p>A maintenance team has been automatically scheduled to inspect the property. You will receive further updates.</p>\n\n<p>Best regards,<br>Disaster Response Team</p>",
        "options": {},
        "subject": "=\ud83d\udea8 Property Alert: Disaster Impact Assessment for {{ $json.property_address }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "c710aceb-0595-4004-b486-f9520da1fadc",
      "name": "\u2709\ufe0f Send Report to Insurers",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2560,
        304
      ],
      "parameters": {
        "sendTo": "={{ $('\u2699\ufe0f Workflow Configuration').item.json.insurerEmail }}",
        "message": "=<h2>Automated Insurance Claim Report</h2>\n\n<h3>Property Information:</h3>\n<ul>\n  <li><strong>Property ID:</strong> {{ $json.property_id }}</li>\n  <li><strong>Address:</strong> {{ $json.property_address }}</li>\n  <li><strong>Owner:</strong> {{ $json.property_owner_name }}</li>\n</ul>\n\n<h3>Claim Details:</h3>\n<ul>\n  <li><strong>Estimated Damage:</strong> ${{ $json.estimated_repair_cost }}</li>\n  <li><strong>Claim Amount:</strong> ${{ $json.insurance_claim_amount }}</li>\n  <li><strong>Damage Level:</strong> {{ $json.damage_level }}</li>\n  <li><strong>Event Type:</strong> {{ $json.disaster_type }}</li>\n</ul>\n\n<h3>AI Assessment:</h3>\n<p>{{ $json.damage_assessment_details }}</p>\n\n<p>This claim was generated automatically based on real-time disaster monitoring and AI-powered damage assessment.</p>",
        "options": {},
        "subject": "=Insurance Claim Notification: {{ $json.property_address }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "58d4ce49-d991-46ba-b8bc-39131fab3acc",
      "name": "\ud83d\udd0d Parse and Filter Active Alerts",
      "type": "n8n-nodes-base.code",
      "position": [
        720,
        144
      ],
      "parameters": {
        "jsCode": "// Parse and filter active disaster alerts\nconst weatherAlerts = $input.first().json.weatherAlerts || [];\nconst seismicAlerts = $input.first().json.seismicAlerts || [];\nconst floodAlerts = $input.first().json.floodAlerts || [];\n\n// Combine all alerts\nconst allAlerts = [\n  ...weatherAlerts.map(a => ({...a, type: 'weather'})),\n  ...seismicAlerts.map(a => ({...a, type: 'seismic'})),\n  ...floodAlerts.map(a => ({...a, type: 'flood'}))\n];\n\n// Filter for active/severe alerts only\nconst activeAlerts = allAlerts.filter(alert => {\n  const isActive = alert.status === 'active' || alert.active === true;\n  const isSevere = ['severe', 'extreme', 'warning'].some(keyword => \n    JSON.stringify(alert).toLowerCase().includes(keyword)\n  );\n  return isActive && isSevere;\n});\n\n// Extract affected zones/coordinates\nconst affectedAreas = activeAlerts.map(alert => ({\n  alertId: alert.id || alert.guid,\n  alertType: alert.type,\n  severity: alert.severity || 'unknown',\n  area: alert.area || alert.geometry || alert.location,\n  coordinates: alert.coordinates || alert.geometry?.coordinates,\n  description: alert.description || alert.title,\n  timestamp: alert.timestamp || alert.pubDate || new Date().toISOString()\n}));\n\nreturn affectedAreas.map(area => ({ json: area }));"
      },
      "typeVersion": 2
    },
    {
      "id": "e33c33ab-02d6-4b39-966e-e7b26303d972",
      "name": "\ud83d\uddfa\ufe0f Map Affected Properties",
      "type": "n8n-nodes-base.code",
      "position": [
        1168,
        144
      ],
      "parameters": {
        "jsCode": "// Map properties to affected disaster zones\nconst alerts = $input.first().json;\nconst properties = $('\ud83d\udcca Get Property Database').all();\n\n// Function to check if property is in affected area\nfunction isPropertyAffected(property, alert) {\n  // Simple proximity check (in real scenario, use proper geo-spatial library)\n  if (alert.coordinates && property.latitude && property.longitude) {\n    const distance = Math.sqrt(\n      Math.pow(alert.coordinates[0] - property.longitude, 2) +\n      Math.pow(alert.coordinates[1] - property.latitude, 2)\n    );\n    return distance < 0.5; // ~50km radius approximation\n  }\n  \n  // Fallback: check if property's city/region matches alert area\n  if (alert.area && property.city) {\n    return alert.area.toLowerCase().includes(property.city.toLowerCase());\n  }\n  \n  return false;\n}\n\n// Map affected properties\nconst affectedProperties = [];\n\nfor (const property of properties) {\n  const relevantAlerts = [];\n  \n  // Check each alert\n  for (const alert of Array.isArray(alerts) ? alerts : [alerts]) {\n    if (isPropertyAffected(property.json, alert)) {\n      relevantAlerts.push(alert);\n    }\n  }\n  \n  // If property is affected, add to output\n  if (relevantAlerts.length > 0) {\n    affectedProperties.push({\n      json: {\n        ...property.json,\n        affectedAlerts: relevantAlerts,\n        alertCount: relevantAlerts.length,\n        highestSeverity: Math.max(...relevantAlerts.map(a => \n          a.severity === 'extreme' ? 3 : a.severity === 'severe' ? 2 : 1\n        ))\n      }\n    });\n  }\n}\n\nreturn affectedProperties;"
      },
      "typeVersion": 2
    },
    {
      "id": "60d78877-cb38-4ee6-9269-8027d7face6e",
      "name": "\ud83d\udcb0 Calculate Insurance Claims",
      "type": "n8n-nodes-base.code",
      "position": [
        1744,
        144
      ],
      "parameters": {
        "jsCode": "// Calculate preliminary insurance claim estimates\nconst properties = $input.all();\n\nconst claimCalculations = properties.map(item => {\n  const property = item.json;\n  \n  // Base calculations\n  const propertyValue = property.property_value || 500000;\n  const severityMultiplier = {\n    3: 0.30,  // Extreme: 30% damage\n    2: 0.15,  // Severe: 15% damage\n    1: 0.05   // Moderate: 5% damage\n  }[property.highestSeverity] || 0.05;\n  \n  const estimatedDamage = propertyValue * severityMultiplier;\n  const deductible = property.insurance_deductible || 5000;\n  const claimAmount = Math.max(0, estimatedDamage - deductible);\n  \n  // Determine damage level\n  const damageLevel = property.highestSeverity === 3 ? 'Critical' :\n                      property.highestSeverity === 2 ? 'Severe' : 'Moderate';\n  \n  // Schedule maintenance window (24-72 hours from now based on severity)\n  const hoursUntilMaintenance = property.highestSeverity === 3 ? 4 :\n                                 property.highestSeverity === 2 ? 24 : 72;\n  const maintenanceStart = new Date(Date.now() + hoursUntilMaintenance * 3600000);\n  const maintenanceEnd = new Date(maintenanceStart.getTime() + 2 * 3600000); // 2 hour window\n  \n  return {\n    json: {\n      ...property,\n      estimated_repair_cost: Math.round(estimatedDamage),\n      insurance_claim_amount: Math.round(claimAmount),\n      damage_level: damageLevel,\n      maintenance_start_time: maintenanceStart.toISOString(),\n      maintenance_end_time: maintenanceEnd.toISOString(),\n      disaster_type: property.affectedAlerts[0]?.type || 'unknown',\n      disaster_description: property.affectedAlerts.map(a => a.description).join('; ')\n    }\n  };\n});\n\nreturn claimCalculations;"
      },
      "typeVersion": 2
    },
    {
      "id": "38282ee2-4a74-4ace-a51e-99082013b8c2",
      "name": "\u2699\ufe0f Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        48,
        240
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3.3
    },
    {
      "id": "51c6deff-50e6-4187-a0cf-05a6b690dd3c",
      "name": "\ud83c\udf24\ufe0f Fetch Weather Alerts",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        272,
        48
      ],
      "parameters": {
        "url": "=https://api.openweathermap.org/data/2.5/onecall",
        "options": {
          "response": {
            "response": {
              "neverError": true,
              "responseFormat": "json"
            }
          }
        },
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "queryAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "lat",
              "value": "={{ $('\u2699\ufe0f Workflow Configuration').item.json.monitoredLocations.split('|')[0].split(',')[0] }}"
            },
            {
              "name": "lon",
              "value": "={{ $('\u2699\ufe0f Workflow Configuration').item.json.monitoredLocations.split('|')[0].split(',')[1] }}"
            },
            {
              "name": "exclude",
              "value": "minutely,hourly,daily"
            },
            {
              "name": "appid",
              "value": "={{ $('\u2699\ufe0f Workflow Configuration').item.json.openWeatherApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4d5128ce-5295-43b7-9af9-f772cb5bcb8a",
      "name": "\ud83c\udf0d Fetch Seismic Alerts (RSS)",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        272,
        240
      ],
      "parameters": {
        "url": "={{ $('\u2699\ufe0f Workflow Configuration').item.json.usgsEarthquakeFeed }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "009568d4-4591-42e6-8f5e-8545d36af52a",
      "name": "\ud83d\udca7 Fetch Flood Alerts (RSS)",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        272,
        432
      ],
      "parameters": {
        "url": "={{ $('\u2699\ufe0f Workflow Configuration').item.json.noaaFloodFeed }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "8e0cfb56-7f03-4b8d-a4a2-cae9928ffd3d",
      "name": "\ud83e\udd16 Damage Prediction Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1392,
        144
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.7
    },
    {
      "id": "3c3f23e0-166a-40d1-bd99-500c4e865835",
      "name": "\ud83d\udcdd Report Generation Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2192,
        144
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.7
    },
    {
      "id": "afa1e1ce-59e5-49c3-93f4-0ec0c0079f3b",
      "name": "\ud83e\udde0 OpenAI GPT-4",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1392,
        384
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "416193ec-0f1e-49a9-83fc-34775dc9fc42",
      "name": "\ud83e\udde0 OpenAI GPT-4 for Reports",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2192,
        384
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "b96435b3-ed28-437d-ab0e-79977b34e317",
      "name": "\ud83d\udce5 Alert Ingestion & Normalization",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -304
      ],
      "parameters": {
        "width": 892,
        "height": 231,
        "content": "## How It Works\nThis automated disaster response workflow streamlines emergency management by monitoring multiple alert sources and coordinating property protection teams. Designed for property managers, insurance companies, and emergency response organizations, it solves the critical challenge of rapidly identifying at-risk properties and deploying resources during disasters.The system continuously monitors weather, seismic, and flood alerts from authoritative sources. When threats are detected, it cross-references property databases to identify affected locations, calculates insurance exposure, and generates damage assessments using OpenAI's GPT-4. Teams receive automated maintenance schedules while property owners and insurers get instant email notifications with comprehensive reports. This eliminates manual monitoring, reduces response time from hours to minutes, and ensures no vulnerable properties are overlooked during emergencies."
      },
      "typeVersion": 1
    },
    {
      "id": "2643785c-1182-4751-862a-fd5a25a9d30f",
      "name": "\ud83d\uddfa\ufe0f Property Impact Identification & Mapping",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        -288
      ],
      "parameters": {
        "width": 444,
        "height": 199,
        "content": "## Setup Steps\n1. Configure alert fetch nodes with weather/seismic/flood \n2. Connect property database credentials \n3. Add OpenAI API key for GPT-4 damage assessments\n4. Set up Gmail/SMTP credentials for owner\n5. Customize insurance calculation formulas"
      },
      "typeVersion": 1
    },
    {
      "id": "f386654a-05a5-4a04-8195-e218a127ec91",
      "name": "\ud83e\udd16 AI Damage & Claim Estimation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        -384
      ],
      "parameters": {
        "color": 6,
        "width": 748,
        "height": 295,
        "content": "## Prerequisites\nWeather/seismic/flood alert API access, property database (SQL/Sheets/Airtable) \n## Use Cases\nInsurance companies automating claims preparation, property management firms protecting rental portfolios \n## Customization\nModify alert source APIs, adjust damage assessment prompts \n## Benefits\nReduces emergency response time by 90%, eliminates manual alert monitoring \n"
      },
      "typeVersion": 1
    },
    {
      "id": "bd176f10-4dbd-4b53-b279-d78f6c71dfed",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 1536,
        "height": 704,
        "content": "## Maintenance Scheduling\n\n**What:** Automatically creates maintenance tasks for affected properties.\n**Why:** Rapid task creation reduces response time and minimizes secondary damage."
      },
      "typeVersion": 1
    },
    {
      "id": "2c86da16-d824-4b62-866d-2c3dd71b098a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1328,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 1104,
        "height": 704,
        "content": "## Report Generation (AI)\n\n**What:** Generates structured incident and impact reports using AI.\n**Why:** Clear, standardized reports ensure stakeholders receive accurate, decision-ready information."
      },
      "typeVersion": 1
    },
    {
      "id": "fa251623-f8df-45a8-b178-e0f13f0432cf",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2448,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 688,
        "content": "## Stakeholder Notifications\n\n**What:** Sends reports to property owners and insurers via email.\n**Why:** Timely communication builds trust and enables faster recovery actions."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "d41e6ae7-9292-4fe4-a371-097101831fa4",
  "connections": {
    "\ud83e\udde0 OpenAI GPT-4": {
      "ai_languageModel": [
        [
          {
            "node": "\ud83e\udd16 Damage Prediction Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udd00 Combine All Alerts": {
      "main": [
        [
          {
            "node": "\ud83d\udd0d Parse and Filter Active Alerts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udcca Get Property Database": {
      "main": [
        [
          {
            "node": "\ud83d\uddfa\ufe0f Map Affected Properties",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83c\udf24\ufe0f Fetch Weather Alerts": {
      "main": [
        [
          {
            "node": "\ud83d\udd00 Combine All Alerts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udcdd Report Generation Agent": {
      "main": [
        [
          {
            "node": "\u2709\ufe0f Send Report to Property Owners",
            "type": "main",
            "index": 0
          },
          {
            "node": "\u2709\ufe0f Send Report to Insurers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83e\udd16 Damage Prediction Agent": {
      "main": [
        [
          {
            "node": "\ud83d\udcb0 Calculate Insurance Claims",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u23f0 Check for Disaster Alerts": {
      "main": [
        [
          {
            "node": "\u2699\ufe0f Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u2699\ufe0f Workflow Configuration": {
      "main": [
        [
          {
            "node": "\ud83c\udf24\ufe0f Fetch Weather Alerts",
            "type": "main",
            "index": 0
          },
          {
            "node": "\ud83c\udf0d Fetch Seismic Alerts (RSS)",
            "type": "main",
            "index": 0
          },
          {
            "node": "\ud83d\udca7 Fetch Flood Alerts (RSS)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83e\udde0 OpenAI GPT-4 for Reports": {
      "ai_languageModel": [
        [
          {
            "node": "\ud83d\udcdd Report Generation Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "\ud83c\udf0d Fetch Seismic Alerts (RSS)": {
      "main": [
        [
          {
            "node": "\ud83d\udd00 Combine All Alerts",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "\ud83d\udcb0 Calculate Insurance Claims": {
      "main": [
        [
          {
            "node": "\ud83d\udcc5 Schedule Maintenance Teams",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udcc5 Schedule Maintenance Teams": {
      "main": [
        [
          {
            "node": "\ud83d\udcdd Report Generation Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\uddfa\ufe0f Map Affected Properties": {
      "main": [
        [
          {
            "node": "\ud83e\udd16 Damage Prediction Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udd0d Parse and Filter Active Alerts": {
      "main": [
        [
          {
            "node": "\ud83d\udcca Get Property Database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}