{
  "name": "Formularios de Landing Page a WhatsApp y Sheets",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "landing-form-webhook",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "c3d4e5f6-0003-4a01-b001-ef1234567001",
      "name": "Webhook - Formulario Landing",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [250, 300]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "nombre",
              "value": "={{ $json.body.nombre || $json.body.name }}"
            },
            {
              "name": "correo",
              "value": "={{ $json.body.correo || $json.body.email }}"
            },
            {
              "name": "telefono",
              "value": "={{ $json.body.telefono || $json.body.phone }}"
            },
            {
              "name": "consulta",
              "value": "={{ $json.body.consulta || $json.body.message || '' }}"
            },
            {
              "name": "fecha",
              "value": "={{ $now.toISO() }}"
            },
            {
              "name": "fuente",
              "value": "={{ $json.headers.referer || 'Landing Page' }}"
            }
          ]
        },
        "options": {}
      },
      "id": "c3d4e5f6-0003-4a02-b002-ef1234567002",
      "name": "Set - Estructurar Datos",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [500, 300]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "byName",
          "value": "Leads Landing"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {}
        },
        "options": {}
      },
      "id": "c3d4e5f6-0003-4a03-b003-ef1234567003",
      "name": "Google Sheets - Mini CRM",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [750, 300],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://graph.facebook.com/v17.0/FROM_PHONE_NUMBER_ID/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"messaging_product\": \"whatsapp\",\n  \"to\": \"{{ $json.telefono }}\",\n  \"type\": \"text\",\n  \"text\": {\n    \"body\": \"¡Hola {{ $json.nombre }}! 👋 Gracias por contactarnos. Hemos recibido tu solicitud y un asesor se comunicará contigo en las próximas horas. ¡Que tengas un excelente día!\"\n  }\n}",
        "options": {}
      },
      "id": "c3d4e5f6-0003-4a04-b004-ef1234567004",
      "name": "WhatsApp - Mensaje de Bienvenida",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [1000, 200]
    },
    {
      "parameters": {
        "sendTo": "=dueño@negocio.com",
        "subject": "=Nuevo Lead desde Landing Page: {{ $json.nombre }}",
        "emailType": "html",
        "message": "=<h2>Nuevo Prospecto</h2><table border='1' cellpadding='8'><tr><td><strong>Nombre:</strong></td><td>{{ $json.nombre }}</td></tr><tr><td><strong>Correo:</strong></td><td>{{ $json.correo }}</td></tr><tr><td><strong>Teléfono:</strong></td><td>{{ $json.telefono }}</td></tr><tr><td><strong>Consulta:</strong></td><td>{{ $json.consulta }}</td></tr><tr><td><strong>Fuente:</strong></td><td>{{ $json.fuente }}</td></tr><tr><td><strong>Fecha:</strong></td><td>{{ $json.fecha }}</td></tr></table>",
        "options": {}
      },
      "id": "c3d4e5f6-0003-4a05-b005-ef1234567005",
      "name": "Gmail - Notificar al Dueño",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [1000, 400],
      "credentials": {
        "gmailOAuth2": {
          "id": "",
          "name": "Gmail account"
        }
      }
    }
  ],
  "connections": {
    "Webhook - Formulario Landing": {
      "main": [
        [
          {
            "node": "Set - Estructurar Datos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set - Estructurar Datos": {
      "main": [
        [
          {
            "node": "Google Sheets - Mini CRM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Mini CRM": {
      "main": [
        [
          {
            "node": "WhatsApp - Mensaje de Bienvenida",
            "type": "main",
            "index": 0
          },
          {
            "node": "Gmail - Notificar al Dueño",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "name": "lead-generation"
    },
    {
      "name": "landing-page"
    },
    {
      "name": "whatsapp"
    }
  ]
}
