{
  "name": "Ascenda — Captura de leads (plantilla)",
  "nodes": [
    {
      "parameters": {
        "content": "## Plantilla de captura de leads — Ascenda\n\n1. Reemplaza el `path` del Webhook y agrégale un header secret o Basic Auth antes de usarlo en producción (ver checklist de seguridad: nunca dejes un webhook público sin protección mínima).\n2. Conecta el nodo **Notificar CRM / Slack** a tu URL real (Slack Incoming Webhook, tu CRM propio, o un HTTP endpoint).\n3. Ajusta el nodo **Validar lead** si tu formulario manda campos distintos a nombre/correo/teléfono/país/objetivo.\n\nDescargado desde ascendagencygroup.com/blog",
        "height": 260,
        "width": 380
      },
      "id": "sticky-intro",
      "name": "Léeme primero",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-40, -280]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "ascenda-leads",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook — nuevo lead",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [-40, 0],
      "webhookId": "REEMPLAZA-ESTE-ID"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "cond-email",
              "leftValue": "={{ $json.body.correo || $json.body.email }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "if-valida-lead",
      "name": "Validar lead",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [200, 0]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f-nombre",
              "name": "nombre",
              "type": "string",
              "value": "={{ $json.body.nombre || $json.body.name }}"
            },
            {
              "id": "f-correo",
              "name": "correo",
              "type": "string",
              "value": "={{ $json.body.correo || $json.body.email }}"
            },
            {
              "id": "f-telefono",
              "name": "telefono",
              "type": "string",
              "value": "={{ $json.body.telefono || $json.body.phone }}"
            },
            {
              "id": "f-pais",
              "name": "pais",
              "type": "string",
              "value": "={{ $json.body.pais || $json.body.country }}"
            },
            {
              "id": "f-objetivo",
              "name": "objetivo",
              "type": "string",
              "value": "={{ $json.body.objetivo || $json.body.goal || 'no especificado' }}"
            },
            {
              "id": "f-origen",
              "name": "origen",
              "type": "string",
              "value": "ascendagencygroup.com"
            },
            {
              "id": "f-fecha",
              "name": "recibido_en",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            }
          ]
        },
        "options": {}
      },
      "id": "set-shape-lead",
      "name": "Preparar datos del lead",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [440, -100]
    },
    {
      "parameters": {
        "content": "Pega aquí la URL real de tu CRM propio, tu webhook de Slack, o tu integración de WhatsApp Business. Este nodo es un placeholder — no envía nada hasta que lo configures.",
        "height": 180,
        "width": 300
      },
      "id": "sticky-http",
      "name": "Nota — conectar CRM/Slack",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [680, -320]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://REEMPLAZA-CON-TU-WEBHOOK-DE-CRM-O-SLACK",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}",
        "options": {}
      },
      "id": "http-notify-crm",
      "name": "Notificar CRM / Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [680, -100]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"success\": true, \"message\": \"Lead recibido\" } }}",
        "options": {}
      },
      "id": "respond-ok",
      "name": "Responder OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [920, -100]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseCode": 400,
        "responseBody": "={{ { \"success\": false, \"message\": \"Faltan datos requeridos (correo)\" } }}",
        "options": {}
      },
      "id": "respond-error",
      "name": "Responder error",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [440, 140]
    }
  ],
  "connections": {
    "Webhook — nuevo lead": {
      "main": [
        [
          {
            "node": "Validar lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validar lead": {
      "main": [
        [
          {
            "node": "Preparar datos del lead",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Responder error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Preparar datos del lead": {
      "main": [
        [
          {
            "node": "Notificar CRM / Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notificar CRM / Slack": {
      "main": [
        [
          {
            "node": "Responder OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "versionId": "ascenda-leads-template-v1"
}
