{
  "name": "WA Blast \u2014 Auto Reply on Lead Submission",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "landing-page-lead",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Landing Page Lead (Webhook)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "to",
              "value": "={{ $json.body.phone ?? $json.body.to ?? $json.body.number }}"
            },
            {
              "name": "message",
              "value": "=Hi {{ $json.body.name ?? 'there' }}, thanks for reaching out! We'll be in touch shortly."
            }
          ]
        },
        "options": {}
      },
      "id": "set-fields",
      "name": "Format to + message",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://wa.yourdomain.com/webhook/n8n",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Webhook-Secret",
              "value": "={{ $env.WA_WEBHOOK_SECRET }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "to",
              "value": "={{ $json.to }}"
            },
            {
              "name": "message",
              "value": "={{ $json.message }}"
            }
          ]
        },
        "options": {}
      },
      "id": "http-request",
      "name": "Send via WA Blast API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "status",
              "value": "={{ $json.ok ? 'sent' : 'error' }}"
            },
            {
              "name": "to",
              "value": "={{ $json.to }}"
            }
          ]
        },
        "options": {}
      },
      "id": "response-node",
      "name": "Webhook Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        900,
        300
      ]
    }
  ],
  "connections": {
    "Landing Page Lead (Webhook)": {
      "main": [
        [
          {
            "node": "Format to + message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format to + message": {
      "main": [
        [
          {
            "node": "Send via WA Blast API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send via WA Blast API": {
      "main": [
        [
          {
            "node": "Webhook Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "notes": [
      "SETUP:",
      "1. Import this file into n8n via Settings \u2192 Import workflow.",
      "2. In the 'Send via WA Blast API' node, replace wa.yourdomain.com with your real VPS domain.",
      "3. Add an n8n environment variable: WA_WEBHOOK_SECRET = (your WEBHOOK_SECRET from backend .env).",
      "4. Activate the workflow. Copy the webhook URL and paste it as the form action in your landing page.",
      "",
      "FIELD MAPPING (Format to + message node):",
      "- 'to' expression reads body.phone, body.to, or body.number \u2014 adjust to match your form field name.",
      "- 'message' uses body.name for personalisation \u2014 adjust or hard-code as needed.",
      "- To send a media file add a 'mediaUrl' body parameter in the HTTP Request node."
    ]
  }
}