{
  "id": "ZVGB5GyY7mN6zCCu",
  "name": "Smart Telematics Behavioral Risk Scoring and Premium Adjustment Engine",
  "tags": [],
  "nodes": [
    {
      "id": "b84c9006-eddc-4d37-9df3-715558c43257",
      "name": "Daily/Weekly Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2176,
        80
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 2
            },
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 2
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "8162ae8f-94a4-435c-bbb7-612b6cf17ad3",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -1952,
        80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "telematicsApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Telematics API endpoint URL__>"
            },
            {
              "id": "id-2",
              "name": "premiumApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Premium system API endpoint URL__>"
            },
            {
              "id": "id-3",
              "name": "underwritingApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Underwriting rules API endpoint URL__>"
            },
            {
              "id": "id-4",
              "name": "riskThreshold",
              "type": "number",
              "value": 75
            },
            {
              "id": "id-5",
              "name": "alertEmail",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Risk alert recipient email__>"
            },
            {
              "id": "id-6",
              "name": "slackChannel",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Slack channel ID for alerts__>"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "bd5a09f0-0956-4513-aa55-4296e2cc7110",
      "name": "Fetch Telematics Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1728,
        80
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.telematicsApiUrl }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<__PLACEHOLDER_VALUE__API authentication token__>"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "52b47cf7-d0b8-4b22-8a3b-2b43a29ed8c6",
      "name": "Risk Scoring AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1504,
        80
      ],
      "parameters": {
        "text": "={{ $json }}",
        "options": {
          "systemMessage": "You are a telematics risk scoring AI specialized in analyzing vehicle behavioral data.\n\nYour task is to:\n1. Analyze the provided telematics data including speed patterns, braking behavior, cornering metrics, and acceleration patterns\n2. Calculate a comprehensive risk score from 0-100 where:\n   - 0-25: Low risk (safe driver)\n   - 26-50: Moderate risk (average driver)\n   - 51-75: Elevated risk (concerning patterns)\n   - 76-100: High risk (dangerous driving)\n3. Identify specific risky behaviors and patterns\n4. Provide detailed reasoning for the risk score\n5. Return structured output with risk score, risk level, identified patterns, and recommendations"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "6e427d82-59f3-41c7-ab05-aad0372d96f3",
      "name": "Anthropic Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -1496,
        304
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-3-5-sonnet-20241022"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "3da03df8-613c-46b2-907a-facc1bc4d105",
      "name": "Risk Score Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -1368,
        304
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"riskScore\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"description\": \"Overall risk score from 0-100\"\n\t\t},\n\t\t\"riskLevel\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Risk category: low, moderate, elevated, or high\"\n\t\t},\n\t\t\"riskyBehaviors\": {\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 risky driving patterns\"\n\t\t},\n\t\t\"reasoning\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Detailed explanation of the risk assessment\"\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\": \"Suggested actions or interventions\"\n\t\t},\n\t\t\"vehicleId\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Vehicle identifier from input data\"\n\t\t},\n\t\t\"driverId\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Driver identifier from input data\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "6c0c5c7d-8714-4362-a1d5-ad83b595206f",
      "name": "Calculate Premium Adjustment",
      "type": "n8n-nodes-base.set",
      "position": [
        -1152,
        80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "premiumAdjustmentPercent",
              "type": "number",
              "value": "={{ $json.riskScore <= 25 ? -10 : $json.riskScore <= 50 ? 0 : $json.riskScore <= 75 ? 15 : 30 }}"
            },
            {
              "id": "id-2",
              "name": "newPremiumMultiplier",
              "type": "number",
              "value": "={{ 1 + ($json.premiumAdjustmentPercent / 100) }}"
            },
            {
              "id": "id-3",
              "name": "adjustmentReason",
              "type": "string",
              "value": "={{ 'Risk score: ' + $json.riskScore + ' (' + $json.riskLevel + ')' }}"
            },
            {
              "id": "id-4",
              "name": "effectiveDate",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "08064466-067e-4f6b-afc6-375808be09aa",
      "name": "Update Premium in System",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -928,
        80
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.premiumApiUrl }}",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ { vehicleId: $json.vehicleId, driverId: $json.driverId, riskScore: $json.riskScore, premiumAdjustment: $json.premiumAdjustmentPercent, newMultiplier: $json.newPremiumMultiplier, reason: $json.adjustmentReason, effectiveDate: $json.effectiveDate } }}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<__PLACEHOLDER_VALUE__Premium API authentication token__>"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "b526c7c8-25c1-4360-b8ea-a2d76cc86ca8",
      "name": "Check for High Risk",
      "type": "n8n-nodes-base.if",
      "position": [
        -704,
        80
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $('Calculate Premium Adjustment').item.json.riskScore }}",
              "rightValue": "={{ $('Workflow Configuration').first().json.riskThreshold }}"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "6fa147ad-b26c-4258-b3f0-24cdcd5e16ae",
      "name": "Send Risk Alert Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -480,
        64
      ],
      "parameters": {
        "sendTo": "={{ $('Workflow Configuration').first().json.alertEmail }}",
        "message": "={{ 'HIGH RISK DRIVING BEHAVIOR DETECTED\\n\\nDriver ID: ' + $json.driverId + '\\nVehicle ID: ' + $json.vehicleId + '\\nRisk Score: ' + $json.riskScore + '/100\\nRisk Level: ' + $json.riskLevel.toUpperCase() + '\\n\\nRisky Behaviors Identified:\\n' + $json.riskyBehaviors.join('\\n- ') + '\\n\\nReasoning:\\n' + $json.reasoning + '\\n\\nRecommendations:\\n' + $json.recommendations.join('\\n- ') + '\\n\\nPremium Adjustment: ' + $json.premiumAdjustmentPercent + '%\\nEffective Date: ' + $json.effectiveDate }}",
        "options": {},
        "subject": "={{ 'HIGH RISK ALERT: Driver ' + $json.driverId + ' - Risk Score ' + $json.riskScore }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8e3d85fb-b599-480c-a1a0-4fc3cd444690",
      "name": "Send Slack Notification",
      "type": "n8n-nodes-base.slack",
      "position": [
        -464,
        240
      ],
      "parameters": {
        "text": "=:warning: *HIGH RISK ALERT*\n*Driver:* {{ $json.driverId }}\n*Vehicle:* {{ $json.vehicleId }}\n*Risk Score:* {{ $json.riskScore }}/100 ({{ $json.riskLevel }})\n*Premium Adjustment:* +{{ $json.premiumAdjustmentPercent }}%\n*Top Risky Behaviors:* {{ $json.riskyBehaviors.slice(0, 3).join(', ') }}",
        "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": "253b9261-e8da-4d4b-be47-d23cd091434a",
      "name": "Sync with Underwriting Rules",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -256,
        80
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.underwritingApiUrl }}",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ { vehicleId: $json.vehicleId, driverId: $json.driverId, riskScore: $json.riskScore, riskLevel: $json.riskLevel, riskyBehaviors: $json.riskyBehaviors, premiumAdjustment: $json.premiumAdjustmentPercent, syncTimestamp: $now.toISO() } }}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<__PLACEHOLDER_VALUE__Underwriting API authentication token__>"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "9775cb12-e3e0-4aaf-8bf0-5096b68b4447",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        -384
      ],
      "parameters": {
        "color": 6,
        "width": 560,
        "height": 288,
        "content": "## Prerequisites\nAnthropic API key, telematics data platform API access\n## Use Cases\nAuto insurance carriers implementing usage-based insurance programs\n## Customization\nModify AI prompts to incorporate additional risk factors like weather conditions\n## Benefits\nReduces premium calculation time from days to minutes"
      },
      "typeVersion": 1
    },
    {
      "id": "211ebaca-3aaf-4afe-9d40-f201ee3fc213",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        -336
      ],
      "parameters": {
        "width": 416,
        "height": 240,
        "content": "## Setup Steps\n1. Configure Schedule node for desired analysis frequency \n2. Set up HTTP node with telematics platform API  \n3. Add Anthropic API key to Chat Model node for behavioral risk analysis\n4. Connect policy management system API credentials in HTTP nodes \n5. Integrate Gmail and Slack with underwriting team addresses  "
      },
      "typeVersion": 1
    },
    {
      "id": "a4e6d45f-88af-4295-8a87-fe7caa4d0190",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2240,
        -336
      ],
      "parameters": {
        "width": 688,
        "height": 240,
        "content": "## How It Works\nThis workflow automates insurance premium adjustments by analyzing telematics data with AI-driven risk assessment and syncing changes across underwriting systems. Designed for carriers, actuaries, and underwriting teams managing usage-based insurance programs, it eliminates manual review of driving patterns, speed, braking, and mileage while ensuring compliance. Scheduled execution fetches telematics data via HTTP from vehicles or mobile apps. Anthropic Claude analyzes behavior with structured output parsing, generating risk scores from acceleration, harsh braking, speeding, and time-of-day driving. Calculator node applies scores to premiums, and HTTP node updates policy systems. High-risk cases trigger Gmail alerts to underwriting managers and Slack notifications to claims teams. Final HTTP sync ensures compliance across all systems."
      },
      "typeVersion": 1
    },
    {
      "id": "3d088e21-20e6-4fcb-824a-13682fe4bcb6",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 576,
        "content": "\n## **High-Risk Handling**\n**What:** IF node flags high-risk drivers, triggering Gmail alerts to underwriters and Slack  \n**Why:** Proactive flagging enables early intervention, while synchronized rule compliance  "
      },
      "typeVersion": 1
    },
    {
      "id": "51403dcf-bf95-487a-9fa8-5465e6793673",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1200,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 352,
        "content": "## **Premium Update**\n**What:** Calculator node applies risk scores to premium formulas;  \n**Why:** Automated calculations eliminate manual errors ."
      },
      "typeVersion": 1
    },
    {
      "id": "7f4d081f-97cd-43d4-9654-dc0e7e56d5ac",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2256,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 1040,
        "height": 496,
        "content": "## **Document Analysis & Risk Scoring**\n**What:** Schedule triggers periodic execution; HTTP node fetches telematics data.  \n**Why:** AI detects subtle risk patterns missed by rule-based systems, and automation \n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "10417ff9-dcef-4abc-bb80-4a3e08361f7c",
  "connections": {
    "Check for High Risk": {
      "main": [
        [
          {
            "node": "Send Risk Alert Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Slack Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Risk Scoring AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Daily/Weekly Schedule": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Telematics Data": {
      "main": [
        [
          {
            "node": "Risk Scoring AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Risk Scoring AI Agent": {
      "main": [
        [
          {
            "node": "Calculate Premium Adjustment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Risk Alert Email": {
      "main": [
        [
          {
            "node": "Sync with Underwriting Rules",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Fetch Telematics Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Slack Notification": {
      "main": [
        [
          {
            "node": "Sync with Underwriting Rules",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Risk Score Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Risk Scoring AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Update Premium in System": {
      "main": [
        [
          {
            "node": "Check for High Risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Premium Adjustment": {
      "main": [
        [
          {
            "node": "Update Premium in System",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}