{
  "name": "Ops Playbooks - Lead Intake Normalizer",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "lead-intake-normalizer",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "5f7d8a4e-3e84-4b4f-b3a6-0dcb90e4df01",
      "name": "Lead intake webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -520,
        0
      ],
      "webhookId": "opsplaybooks-lead-intake-normalizer"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "name",
              "name": "name",
              "value": "={{ $json.body.name || $json.query.name || '' }}",
              "type": "string"
            },
            {
              "id": "email",
              "name": "email",
              "value": "={{ $json.body.email || $json.query.email || '' }}",
              "type": "string"
            },
            {
              "id": "company",
              "name": "company",
              "value": "={{ $json.body.company || $json.query.company || '' }}",
              "type": "string"
            },
            {
              "id": "source",
              "name": "source",
              "value": "={{ $json.body.source || $json.query.source || 'unknown' }}",
              "type": "string"
            },
            {
              "id": "intent",
              "name": "intent",
              "value": "={{ $json.body.intent || $json.query.intent || 'not_provided' }}",
              "type": "string"
            },
            {
              "id": "lead_score",
              "name": "lead_score",
              "value": "={{ (($json.body.email || '').includes('@') ? 20 : 0) + (($json.body.company || '').length > 1 ? 20 : 0) + (($json.body.intent || '').length > 10 ? 20 : 0) }}",
              "type": "number"
            },
            {
              "id": "next_action",
              "name": "next_action",
              "value": "={{ (($json.body.intent || '').length > 10) ? 'Review lead and prepare personalized follow-up' : 'Ask for more context before routing' }}",
              "type": "string"
            },
            {
              "id": "received_at",
              "name": "received_at",
              "value": "={{ $now.toISO() }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "8a8f9dd4-60de-4efb-a4b9-8789fcb394d9",
      "name": "Normalize lead fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -260,
        0
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { ok: true, workflow: 'lead-intake-normalizer', lead: $json } }}",
        "options": {
          "responseCode": 200
        }
      },
      "id": "f7639431-0d65-41c3-8d08-e5d9d69daf2a",
      "name": "Return structured response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        20,
        0
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Lead intake webhook": {
      "main": [
        [
          {
            "node": "Normalize lead fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize lead fields": {
      "main": [
        [
          {
            "node": "Return structured response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f6fcf17b-f208-4304-bcf6-0b2ed2a4bc7f",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "opsplaybooks-lead-intake-normalizer",
  "tags": []
}
