{
  "name": "Lead-Handling Assistant — Complete (Genesis Web Digital)",
  "nodes": [
    {
      "parameters": {
        "content": "## Lead-Handling Assistant — Complete\n\nBuilt over 8 weeks as the \"n8n Build of the Week\" series by Genesis Web Digital.\n\n**What this does, start to finish:**\n1. Receives a contact-form submission via webhook\n2. Filters out junk (empty fields, missing email)\n3. Logs every real lead to Google Sheets\n4. Drafts a personalized reply using AI\n5. Sends the reply with your calendar booking link\n6. Pings you the moment a lead arrives\n7. Waits 3 days → sends an automatic follow-up\n8. Catches any node errors and alerts you\n\n**Things to set up before going live:**\n- Webhook URL → paste into your Tally / website contact form\n- Google Sheet ID → your lead-tracking spreadsheet\n- OpenAI credentials → add your API key in n8n Credentials\n- Gmail credentials → connect your account in n8n Credentials\n- Calendar link → replace `YOUR_CALENDAR_LINK` in the email nodes\n- Owner email → replace `YOUR_EMAIL` in Notify Owner + Alert on Error\n- n8n URL → replace `YOUR_N8N_URL` in Alert on Error",
        "height": 460,
        "width": 520,
        "color": 7
      },
      "id": "a0000000-0000-0000-0000-000000000001",
      "name": "Setup Notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -540,
        60
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "lead-intake",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "a0000000-0000-0000-0000-000000000002",
      "name": "Form Submission",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        300
      ],
      "webhookId": "a0000000-0000-0000-0000-000000000099"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "cond-email",
              "leftValue": "={{ $json.body.email ?? $json.body.formData?.email ?? $json.email ?? '' }}",
              "rightValue": "@",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            },
            {
              "id": "cond-message",
              "leftValue": "={{ $json.body.message ?? $json.body.formData?.message ?? $json.message ?? '' }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a0000000-0000-0000-0000-000000000003",
      "name": "Junk Filter",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_GOOGLE_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "id"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Timestamp": "={{ new Date().toISOString() }}",
            "Name": "={{ $json.body.name ?? $json.body.formData?.name ?? $json.name ?? 'Unknown' }}",
            "Email": "={{ $json.body.email ?? $json.body.formData?.email ?? $json.email ?? '' }}",
            "Phone": "={{ $json.body.phone ?? $json.body.formData?.phone ?? $json.phone ?? '' }}",
            "Message": "={{ $json.body.message ?? $json.body.formData?.message ?? $json.message ?? '' }}",
            "Source": "={{ $json.body.source ?? $json.body.formData?.source ?? 'Contact Form' }}",
            "Status": "New"
          }
        },
        "options": {}
      },
      "id": "a0000000-0000-0000-0000-000000000004",
      "name": "Log Lead to Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        480,
        180
      ]
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "complete",
        "model": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=You are writing a first-touch reply on behalf of Cole Maffeo at Genesis Web Digital, a digital agency based in Rockledge, FL specialising in AI automation and web development for small businesses. Write a warm, direct, personal reply to this lead. Keep it under 90 words. Do not make up specific services, pricing, or timelines that are not in the inquiry. End naturally — the email template will add the calendar link and sign-off.\n\nLead name: {{ $('Log Lead to Sheets').item.json['Name'] }}\nLead message: {{ $('Log Lead to Sheets').item.json['Message'] }}"
            }
          ]
        },
        "options": {}
      },
      "id": "a0000000-0000-0000-0000-000000000005",
      "name": "Draft Reply with AI",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [
        720,
        180
      ]
    },
    {
      "parameters": {
        "sendTo": "={{ $('Log Lead to Sheets').item.json['Email'] }}",
        "subject": "Re: Your inquiry — Genesis Web Digital",
        "emailType": "html",
        "message": "={{ $json.message.content }}<br><br>📅 Book a quick call: <a href=\"YOUR_CALENDAR_LINK\">YOUR_CALENDAR_LINK</a><br><br>—<br>Cole Maffeo<br>Genesis Web Digital",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "a0000000-0000-0000-0000-000000000006",
      "name": "Send Reply + Calendar Link",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [
        960,
        180
      ]
    },
    {
      "parameters": {
        "sendTo": "YOUR_EMAIL",
        "subject": "=🔔 New lead: {{ $('Log Lead to Sheets').item.json['Name'] }}",
        "emailType": "html",
        "message": "=<b>New lead just came in and was replied to automatically.</b><br><br><b>Name:</b> {{ $('Log Lead to Sheets').item.json['Name'] }}<br><b>Email:</b> {{ $('Log Lead to Sheets').item.json['Email'] }}<br><b>Phone:</b> {{ $('Log Lead to Sheets').item.json['Phone'] || '—' }}<br><b>Message:</b><br>{{ $('Log Lead to Sheets').item.json['Message'] }}<br><br>Reply sent. Follow-up fires automatically in 3 days if no response.",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "a0000000-0000-0000-0000-000000000007",
      "name": "Notify Owner",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [
        1200,
        180
      ]
    },
    {
      "parameters": {
        "amount": 3,
        "unit": "days"
      },
      "id": "a0000000-0000-0000-0000-000000000008",
      "name": "Wait 3 Days",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        1440,
        180
      ],
      "webhookId": "a0000000-0000-0000-0000-000000000098"
    },
    {
      "parameters": {
        "sendTo": "={{ $('Log Lead to Sheets').item.json['Email'] }}",
        "subject": "Quick follow-up — Genesis Web Digital",
        "emailType": "html",
        "message": "=Hi {{ $('Log Lead to Sheets').item.json['Name'] }},<br><br>Just circling back on your inquiry from a few days ago. Happy to answer any questions or hop on a quick call — no pressure.<br><br>📅 Book time here: <a href=\"YOUR_CALENDAR_LINK\">YOUR_CALENDAR_LINK</a><br><br>— Cole<br>Genesis Web Digital",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "a0000000-0000-0000-0000-000000000009",
      "name": "Send Follow-up",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [
        1680,
        180
      ]
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "OK",
        "options": {}
      },
      "id": "a0000000-0000-0000-0000-000000000010",
      "name": "Webhook Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        480,
        420
      ]
    },
    {
      "parameters": {},
      "id": "a0000000-0000-0000-0000-000000000011",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        0,
        600
      ]
    },
    {
      "parameters": {
        "sendTo": "YOUR_EMAIL",
        "subject": "⚠️ Lead automation error — action needed",
        "emailType": "html",
        "message": "=<b>The lead-handling workflow hit an error and needs attention.</b><br><br><b>Workflow:</b> {{ $json.workflow.name }}<br><b>Last node:</b> {{ $json.execution.lastNodeExecuted }}<br><b>Error:</b> {{ $json.execution.error.message }}<br><br><a href=\"YOUR_N8N_URL\">Open n8n to investigate →</a>",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "a0000000-0000-0000-0000-000000000012",
      "name": "Alert on Error",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [
        240,
        600
      ]
    }
  ],
  "connections": {
    "Form Submission": {
      "main": [
        [
          {
            "node": "Junk Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Junk Filter": {
      "main": [
        [
          {
            "node": "Log Lead to Sheets",
            "type": "main",
            "index": 0
          },
          {
            "node": "Webhook Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Webhook Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Lead to Sheets": {
      "main": [
        [
          {
            "node": "Draft Reply with AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Draft Reply with AI": {
      "main": [
        [
          {
            "node": "Send Reply + Calendar Link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Reply + Calendar Link": {
      "main": [
        [
          {
            "node": "Notify Owner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Owner": {
      "main": [
        [
          {
            "node": "Wait 3 Days",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 3 Days": {
      "main": [
        [
          {
            "node": "Send Follow-up",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Alert on Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": ""
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 2,
  "versionId": "a0000000-0000-0000-0000-000000000000",
  "meta": {
    "templateCredsSetupCompleted": false,
    "source": "Genesis Web Digital — free n8n template pack. genesisweb.org"
  }
}
