{
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "recibir-email",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "2be5fb38-03b8-46b7-b3c5-4f45a300ce4b",
      "name": "Recibir Email",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "companyName",
              "value": "MGA Tech Consulting",
              "type": "string"
            },
            {
              "id": "id-2",
              "name": "companyLogo",
              "value": "https://github.com/Mgobeaalcoba/Mgobeaalcoba.github.io/blob/main/assets/images/logo_oscuro.png?raw=true",
              "type": "string"
            },
            {
              "id": "id-3",
              "name": "fromEmail",
              "value": "mariano@mgatc.com",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "id": "59fac4f3-b2b0-4b37-865d-64da182df5cf",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        224,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "email",
              "value": "={{ $json.body.email }}",
              "type": "string"
            },
            {
              "id": "id-4",
              "name": "fechaRecepcion",
              "value": "={{ $now.toISO() }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "id": "1b1250c9-6361-4dc0-b46f-459c4b3d1b7b",
      "name": "Preparar Datos",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        448,
        0
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "{{ GOOGLE_SHEETS_DOCUMENT_ID }}",
          "mode": "list",
          "cachedResultName": "Suscriptions Web",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/{{ GOOGLE_SHEETS_DOCUMENT_ID }}/edit"
        },
        "sheetName": {
          "__rl": true,
          "value": "{{ GOOGLE_SHEETS_SHEET_ID }}",
          "mode": "list",
          "cachedResultName": "newsletter",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/{{ GOOGLE_SHEETS_DOCUMENT_ID }}/edit#gid={{ GOOGLE_SHEETS_SHEET_ID }}"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Email": "={{ $json.email }}",
            "Fecha de Registro": "={{ $json.fechaRecepcion.toDateTime().format('yyyy-MM-dd HH:mm:ss') }}",
            "Origen": "={{ $json.headers.origin }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Fecha de Registro",
              "displayName": "Fecha de Registro",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Origen",
              "displayName": "Origen",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        656,
        0
      ],
      "id": "5f095bd8-7db7-44f6-9374-b78e43923011",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "{{ ADMIN_EMAIL }}",
        "subject": "=\ud83d\ude80 Nueva Solicitud de Suscripci\u00f3n: {{ $('Preparar Datos').item.json.email }}",
        "message": "=<!DOCTYPE html>\n<html>\n<head>\n    <style>\n        body { font-family: 'Segoe UI', Arial, sans-serif; line-height: 1.6; color: #2c3e50; margin: 0; padding: 0; }\n        .container { max-width: 600px; margin: 0 auto; border: 1px solid #eee; border-radius: 8px; overflow: hidden; }\n        /* Header unificado con el estilo del cliente para resaltar el logo */\n        .header { text-align: center; padding: 30px 0; background: linear-gradient(135deg, #0066cc 0%, #003366 100%); color: white; }\n        .logo { max-width: 180px; height: auto; }\n        .content { padding: 30px; background-color: #ffffff; }\n        .data-table { width: 100%; margin: 20px 0; border-collapse: collapse; }\n        .data-table td { padding: 12px; border-bottom: 1px solid #f0f0f0; }\n        .label { font-weight: bold; color: #0066cc; width: 35%; text-transform: uppercase; font-size: 12px; }\n        .button-sheet { \n            display: inline-block; \n            padding: 14px 30px; \n            background-color: #28a745; \n            color: #ffffff !important; \n            text-decoration: none; \n            border-radius: 6px; \n            font-weight: bold; \n            margin-top: 10px;\n            box-shadow: 0 4px 6px rgba(0,0,0,0.1);\n        }\n    </style>\n</head>\n<body>\n    <div class=\"container\">\n        <div class=\"header\">\n            <img src=\"{{ $('Workflow Configuration').first().json.companyLogo }}\" alt=\"MGA Tech\" class=\"logo\">\n            <h3 style=\"margin: 10px 0 0 0; opacity: 0.9;\">Nuevo Lead Detectado</h3>\n        </div>\n\n        <div class=\"content\">\n            <table class=\"data-table\">\n                <tr><td class=\"label\">Email:</td><td><a href=\"mailto:{{ $json.Email }}\" style=\"color: #0066cc;\">{{ $json.Email }}</a></td></tr>\n            </table>\n            \n            <center>\n                <a href=\"https://docs.google.com/spreadsheets/d/{{ GOOGLE_SHEETS_DOCUMENT_ID }}/edit\" class=\"button-sheet\">\n                    Gestionar en Google Sheets\n                </a>\n            </center>\n        </div>\n    </div>\n</body>\n</html>",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        864,
        80
      ],
      "id": "e5994d0a-1966-43b0-932b-bcf670d01b81",
      "name": "Notificaci\u00f3n a Mariano",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $('Preparar Datos').first().json.email }}",
        "subject": "Confirmaci\u00f3n de Recepci\u00f3n - MGA Tech Consulting",
        "message": "=<!DOCTYPE html> <html> <head>     <style>         body { font-family: 'Segoe UI', Arial, sans-serif; line-height: 1.6; color: #2c3e50; margin: 0; padding: 0; }         .container { max-width: 600px; margin: 0 auto; padding: 20px; border: 1px solid #eee; }         .header { text-align: center; padding: 30px 0; background: linear-gradient(135deg, #0066cc 0%, #003366 100%); color: white; border-radius: 8px 8px 0 0; }         .logo { max-width: 180px; height: auto; filter: brightness(0) invert(1); }         .content { padding: 30px; background-color: #ffffff; }         .footer { text-align: center; padding: 25px; border-top: 1px solid #eee; color: #888; font-size: 13px; background-color: #f9f9f9; border-radius: 0 0 8px 8px; }                  .welcome-badge { display: inline-block; background: #e1effe; color: #0066cc; padding: 5px 15px; border-radius: 20px; font-weight: bold; font-size: 14px; margin-bottom: 15px; }         .highlight-box { background-color: #f4f7fa; padding: 20px; border-left: 5px solid #0066cc; margin: 25px 0; border-radius: 4px; }                  .topic-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 15px; }         .topic-tag { background: #eee; padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: bold; color: #555; }                  .button { display: inline-block; padding: 12px 25px; background-color: pink; color: white; text-decoration: none; border-radius: 5px; font-weight: bold; margin-top: 20px; }     </style> </head> <body>     <div class=\"container\">         <div class=\"header\">             <img src=\"{{ $('Workflow Configuration').first().json.companyLogo }}\" alt=\"{{ $('Workflow Configuration').first().json.companyName }}\" class=\"logo\">             <h1 style=\"margin: 10px 0 0 0; font-size: 24px;\">Data & AI Insights</h1>         </div>          <div class=\"content\">             <div class=\"welcome-badge\">\ud83d\ude80 Suscripci\u00f3n Confirmada</div>                          <h2>\u00a1Hola, {{ $json.name || 'Entusiasta de la Tecnolog\u00eda' }}!</h2>                          <p>Es un placer darte la bienvenida a nuestra comunidad. A partir de ahora, est\u00e1s conectado con la vanguardia de la transformaci\u00f3n digital.</p>                          <div class=\"highlight-box\">                 <p style=\"margin-top: 0;\"><strong>Resumen de tu suscripci\u00f3n:</strong></p>                 <p style=\"margin-bottom: 5px;\">\ud83d\udcc5 <strong>Fecha de inicio:</strong> {{ $('Preparar Datos').first().json.fechaRecepcion }}</p>                 <p style=\"margin-bottom: 5px;\">\ud83d\udce7 <strong>Email registrado:</strong> {{ $('Append row in sheet').item.json.Email }}</p>                 <div class=\"topic-grid\">                     <span class=\"topic-tag\">#DataAnalytics</span>                     <span class=\"topic-tag\">#GenAI</span>                     <span class=\"topic-tag\">#Automation</span>                     <span class=\"topic-tag\">#Efficiency</span>                 </div>             </div>              <h3>\u00bfQu\u00e9 puedes esperar de nosotros?</h3>             <ul>                 <li><strong>Data & Analytics:</strong> Estrategias para convertir datos crudos en decisiones de negocio.</li>                 <li><strong>Generative AI:</strong> Implementaciones reales de LLMs y modelos predictivos.</li>                 <li><strong>Automations:</strong> C\u00f3mo conectar n8n, Make y APIs para escalar tus procesos.</li>             </ul>              <p>Estamos procesando tu primera dosis de contenido t\u00e9cnico y casos de \u00e9xito que te enviaremos en breve.</p>                          <center>                 <a href=\"https://mgobeaalcoba.github.io/blog.html\" class=\"button\">Explorar Recursos Actuales</a>             </center>              <p style=\"margin-top: 30px;\">Saludos cordiales,<br>             <strong>El equipo de {{ $('Workflow Configuration').first().json.companyName }}</strong></p>         </div>          <div class=\"footer\">             <p>Recibiste este correo porque te suscribiste a trav\u00e9s de nuestro portal.</p>             <p>&copy; 2026 {{ $('Workflow Configuration').first().json.companyName }}. Todos los derechos reservados.</p>             <p>Transformando el futuro a trav\u00e9s de los datos y la IA.</p>         </div>     </div> </body> </html>",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        864,
        -128
      ],
      "id": "28d38124-0a18-48db-bb6c-df3a867a925c",
      "name": "Notificaci\u00f3n al Lead",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Recibir Email": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Preparar Datos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Preparar Datos": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Notificaci\u00f3n al Lead",
            "type": "main",
            "index": 0
          },
          {
            "node": "Notificaci\u00f3n a Mariano",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notificaci\u00f3n al Lead": {
      "main": [
        []
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "_documentation": {
    "name": "Newsletter Subscription Handler",
    "version": "1.0",
    "description": "Handles newsletter subscription requests from the site. Saves the subscriber email to Google Sheets and sends two emails: a welcome confirmation to the subscriber and an admin notification.",
    "trigger": "Webhook POST \u2014 path: /webhook/recibir-email",
    "payload_expected": {
      "email": "...",
      "name": "(optional)"
    },
    "placeholders_to_fill": [
      "{{ GOOGLE_SHEETS_DOCUMENT_ID }} \u2014 ID of the Google Sheets spreadsheet",
      "{{ GOOGLE_SHEETS_SHEET_ID }} \u2014 Sheet tab ID (numeric gid or \"gid=0\" for first tab)",
      "{{ ADMIN_EMAIL }} \u2014 Admin email for new-subscriber notifications",
      "{{ CREDENTIAL_ID }} \u2014 Auto-assigned by n8n",
      "{{ WEBHOOK_ID }} \u2014 Auto-assigned by n8n"
    ],
    "credentials_required": [
      "Google Sheets OAuth2 (Sheets mariano@mgatc.com)",
      "Gmail OAuth2 (mariano@mgatc.com Gmail)"
    ]
  }
}