{
  "name": "Missed-Lead Instant Follow-Up & Owner Alert",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "lead-intake",
        "options": {}
      },
      "id": "1",
      "name": "Webhook: Inbound Form Lead",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300],
      "webhookId": "lead-intake"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "email-validation",
              "leftValue": "={{ $json.body.email }}",
              "rightValue": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
              "operator": {
                "type": "string",
                "operation": "regex"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "2",
      "name": "Validate Email Format",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_GOOGLE_SHEET_OR_AIRTABLE_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Inbound Leads",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Timestamp": "={{ $now.toISO() }}",
            "Name": "={{ $json.body.name || 'Unknown' }}",
            "Email": "={{ $json.body.email }}",
            "Phone": "={{ $json.body.phone || 'N/A' }}",
            "Service Requested": "={{ $json.body.service || 'General Inquiry' }}",
            "Status": "Contacted"
          }
        },
        "options": {}
      },
      "id": "3",
      "name": "Log to Leads Sheet / CRM",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [700, 200]
    },
    {
      "parameters": {
        "sendTo": "={{ $json.body.email }}",
        "subject": "Thanks for contacting us, {{ $json.body.name || 'there' }} — we received your inquiry",
        "message": "Hi {{ $json.body.name || 'there' }},\n\nThank you for reaching out! We received your message regarding {{ $json.body.service || 'your project' }}.\n\nOur team is reviewing the details right now. We typically get back to you within 30 minutes during standard business hours.\n\nIf your request is urgent, feel free to call our direct line.\n\nBest regards,\nCustomer Support Team",
        "options": {}
      },
      "id": "4",
      "name": "Send Instant Email to Lead",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [940, 200]
    },
    {
      "parameters": {
        "chatId": "YOUR_TELEGRAM_CHAT_OR_SLACK_CHANNEL",
        "text": "=🚨 *NEW INBOUND LEAD*\n\n*Name:* {{ $('Webhook: Inbound Form Lead').item.json.body.name || 'Not provided' }}\n*Email:* {{ $('Webhook: Inbound Form Lead').item.json.body.email }}\n*Phone:* {{ $('Webhook: Inbound Form Lead').item.json.body.phone || 'None' }}\n*Service:* {{ $('Webhook: Inbound Form Lead').item.json.body.service || 'General' }}\n\nAuto-reply has been dispatched. Logged to CRM at {{ $now.format('HH:mm') }}.",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "id": "5",
      "name": "Notify Business Owner (Telegram/Slack)",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [1180, 200]
    },
    {
      "parameters": {
        "chatId": "YOUR_TELEGRAM_ALERT_CHAT_ID",
        "text": "=⚠️ *LEAD CAPTURE FAILED: Invalid Email*\n\nA form submission was received with an unparseable email address: `{{ $json.body.email || 'EMPTY' }}`.\nName: {{ $json.body.name || 'None' }}\nPhone: {{ $json.body.phone || 'None' }}\n\nPlease check form submission logs manually.",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "id": "6",
      "name": "Alert Owner: Invalid Input",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [700, 420]
    }
  ],
  "connections": {
    "Webhook: Inbound Form Lead": {
      "main": [
        [
          {
            "node": "Validate Email Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Email Format": {
      "main": [
        [
          {
            "node": "Log to Leads Sheet / CRM",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Alert Owner: Invalid Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Leads Sheet / CRM": {
      "main": [
        [
          {
            "node": "Send Instant Email to Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Instant Email to Lead": {
      "main": [
        [
          {
            "node": "Notify Business Owner (Telegram/Slack)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
