{
  "name": "Lead Scoring → GHL Tag (abuusof.com)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "new-lead",
        "options": {}
      },
      "id": "7d3e4c32-3333-4c03-7e03-c3d4e5f6a701",
      "name": "New lead (Webhook)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [0, 0],
      "webhookId": "new-lead"
    },
    {
      "parameters": {
        "jsCode": "// Simple transparent lead score — tune the weights to your business.\nconst b = $input.first().json.body || {};\nlet score = 0;\nif (b.phone) score += 25;                      // gave a phone number\nif (b.email && !/gmail|yahoo|hotmail|outlook/i.test(b.email)) score += 20; // business email\nif ((b.message || '').length > 80) score += 15; // wrote a real message\nif (b.budget && Number(b.budget) >= 1000) score += 25;\nif (b.source === 'referral') score += 15;\nconst band = score >= 60 ? 'hot-lead' : score >= 30 ? 'warm-lead' : 'cold-lead';\nreturn [{ json: { ...b, score, band } }];"
      },
      "id": "7d3e4c32-3333-4c03-7e03-c3d4e5f6a702",
      "name": "Score the lead",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [220, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://services.leadconnectorhq.com/contacts/upsert",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_PRIVATE_INTEGRATION_TOKEN" },
            { "name": "Version", "value": "2021-07-28" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ locationId: 'YOUR_LOCATION_ID', email: $json.email, phone: $json.phone, firstName: $json.firstName, lastName: $json.lastName, tags: [$json.band, 'score:' + $json.score] }) }}",
        "options": {}
      },
      "id": "7d3e4c32-3333-4c03-7e03-c3d4e5f6a703",
      "name": "Upsert contact with band tag",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [440, 0]
    }
  ],
  "connections": {
    "New lead (Webhook)": { "main": [[{ "node": "Score the lead", "type": "main", "index": 0 }]] },
    "Score the lead": { "main": [[{ "node": "Upsert contact with band tag", "type": "main", "index": 0 }]] }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" },
  "meta": {
    "notes": "POST lead form data (email, phone, firstName, lastName, message, budget, source) to the webhook. The Code node scores it; the contact lands in GHL tagged hot/warm/cold-lead so your GHL workflows can route it. Replace token + location ID. From abuusof.com/connect-n8n-to-gohighlevel/"
  }
}
