{
  "name": "Real Estate Lead Scoring and Routing",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "real-estate-lead-score",
        "responseMode": "onReceived",
        "options": {}
      },
      "id": "ee2ceb7b-aca4-4494-af5d-3f27ce465e8d",
      "name": "New Lead",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const x=$json.body||$json; let score=0; if(Number(x.budget)>=10000000) score+=35; if(x.timeline==='0-3 months') score+=25; if(x.financing_ready) score+=20; if(x.location) score+=10; if(x.property_type) score+=10; return [{json:{...x,lead_score:score}}];"
      },
      "id": "c0c2985a-4ba0-45d9-88e6-1d58234fa58f",
      "name": "Calculate Score",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        0
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.lead_score }}",
                    "rightValue": 70,
                    "operator": {
                      "type": "number",
                      "operation": "gte"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "high-intent"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "id": "9f14038a-66ad-4d8d-9594-a9765b6948ba",
      "name": "Route by Score",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 2,
      "position": [
        520,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.SALES_ALERT_WEBHOOK }}",
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "application/json",
        "body": "={{ JSON.stringify($json) }}",
        "options": {}
      },
      "id": "4d6bc626-5860-4c59-9abf-31fce4269694",
      "name": "Notify Sales",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        780,
        -80
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.NURTURE_QUEUE_ENDPOINT }}",
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "application/json",
        "body": "={{ JSON.stringify($json) }}",
        "options": {}
      },
      "id": "338db34b-89fd-4862-a905-9a11cc1c31a6",
      "name": "Add Nurture Queue",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        780,
        100
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "New Lead": {
      "main": [
        [
          {
            "node": "Calculate Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Score": {
      "main": [
        [
          {
            "node": "Route by Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Score": {
      "main": [
        [
          {
            "node": "Notify Sales",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add Nurture Queue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "dd056498-28b5-42f0-9212-097283da12e2",
  "meta": {
    "templateCredsSetupCompleted": false,
    "kumoDraftAsset": true,
    "credentialPlaceholdersRequired": true
  },
  "tags": []
}