{
  "name": "AI Receptionist — HVAC Contractor Demo",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "ai-receptionist",
        "responseMode": "responseDefined",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [100, 400],
      "webhookId": "ai-receptionist-hvac"
    },
    {
      "parameters": {
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are the AI receptionist for **Precision Air HVAC** — a family-owned heating and cooling company serving homeowners in the greater Phoenix metro area since 2004.\n\nPERSONA & VOICE:\n- Warm, professional, Arizona-local friendly\n- Never use technical jargon unless the customer brings it up\n- Always confirm spelling of names\n- Write times in plain English: \"3 PM\" not \"15:00\"\n\nSERVICE TYPES:\n- AC Repair — $89 diagnostic + parts\n- AC Installation — Starting $4,500\n- Furnace Repair — $89 diagnostic + parts  \n- Furnace Installation — Starting $5,200\n- Maintenance Plans — $149/year (two annual tune-ups)\n- Emergency Service — $149/hr, 24/7\n\nAVAILABILITY:\n- Mon–Fri: 7 AM – 7 PM\n- Sat: 8 AM – 4 PM\n- Sun: Emergency calls only\n- Same-day service available for calls before 2 PM\n\nLEAD QUALIFICATION CHECKLIST (gather all three):\n1. First name + last name spelled out\n2. Service type (repair / installation / maintenance)\n3. Zip code (must be in service area: 85001–85399)\n\nAfter collecting all three, confirm appointment slot and say:\n\"I'm wrapping up your appointment right now — you'll get a confirmation text at the number you provided. Anything else I can help with?\"\n\nIf zip code is outside service area, say:\n\"We don't currently service that zip code, but I'd be happy to give you our main line in case that changes — would you like that number?\"\n\nCOLLECT FOR CRM:\n- Full name\n- Phone number (ask for the best number to reach them)\n- Service needed\n- Zip code\n- Urgency level (urgent = leaking, no heat/cool, or emergency; routine = scheduled)\n- Best callback time\n\nAfter the call ends, output a JSON summary in this exact format:\n{\"firstName\":\"...\",\"lastName\":\"...\",\"phone\":\"...\",\"service\":\"...\",\"zipCode\":\"...\",\"urgency\":\"urgent|routine\",\"bestTime\":\"...\"}"
            },
            {
              "role": "user",
              "content": "={{ $json.body.message }}"
            }
          ]
        },
        "options": {
          "temperature": 0.7
        }
      },
      "id": "ai-agent",
      "name": "AI Agent (Receptionist)",
      "type": "@n8n/n8n-nodes-langchain.openAiAssistant",
      "typeVersion": 1.3,
      "position": [350, 400]
    },
    {
      "parameters": {
        "url": "https://api.openai.com/v1/chat/completions",
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "sendQuery": true,
        "queryParameters": {
          "values": [
            {
              "name": "model",
              "value": "gpt-4o"
            },
            {
              "name": "messages",
              "value": "=[{\"role\":\"system\",\"content\":\"Extract lead qualification data from the following message. Return JSON only: {\"firstName\":\"\",\"lastName\":\"\",\"phone\":\"\",\"service\":\"\",\"zipCode\":\"\",\"urgency\":\"\",\"bestTime\":\"\"}. Mark zip codes outside 85001-85399 as out-of-area.\"},{\"role\":\"user\",\"content\":\"={{ $json.aiResponse }}\"}]"
            }
          ]
        },
        "options": {}
      },
      "id": "extract-lead-data",
      "name": "Extract Lead Data (OpenAI)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3.2,
      "position": [600, 400]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "lead-score",
              "leftValue": "={{ $json.zipCode ? ($json.zipCode >= 85001 && $json.zipCode <= 85399 ? 'in-area' : 'out-of-area') : 'unknown' }}",
              "rightValue": "in-area",
              "operator": {
                "type": "equals",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "lead-qualification",
      "name": "Lead Qualification",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [850, 400]
    },
    {
      "parameters": {
        "operation": "append",
        "sheetId": "",
        "range": "A1:G1",
        "options": {
          "valueInputMode": "USER_ENTERED"
        },
        "values": {
          "values": {
            "row": [
              "={{ $json.firstName }} {{ $json.lastName }}",
              "={{ $json.phone }}",
              "={{ $json.service }}",
              "={{ $json.zipCode }}",
              "={{ $json.urgency }}",
              "={{ $json.bestTime }}",
              "={{ $now }}"
            ]
          }
        }
      },
      "id": "add-to-google-sheets",
      "name": "Add Lead to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 3.4,
      "position": [1100, 300],
      "webhookId": "ai-receptionist-hvac",
      "continueOnFail": true
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.SLACK_WEBHOOK_URL }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "🚨 *Lead Outside Service Area*\n\nName: {{ $json.firstName }} {{ $json.lastName }}\nZip: {{ $json.zipCode }}\nService: {{ $json.service }}\n\n*Receptionist offered main line number.*"
            }
          ]
        },
        "options": {}
      },
      "id": "notify-out-of-area",
      "name": "Notify: Out of Area",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3.2,
      "position": [1100, 500]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"status\": \"ok\", \"message\": $json.aiResponse } }}"
      },
      "id": "webhook-response",
      "name": "Return AI Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [1350, 400]
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "AI Agent (Receptionist)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent (Receptionist)": {
      "main": [
        [
          {
            "node": "Extract Lead Data (OpenAI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Lead Data (OpenAI)": {
      "main": [
        [
          {
            "node": "Lead Qualification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lead Qualification": {
      "main": [
        [
          {
            "node": "Add Lead to Google Sheets",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify: Out of Area",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Lead to Google Sheets": {
      "main": [
        [
          {
            "node": "Return AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify: Out of Area": {
      "main": [
        [
          {
            "node": "Return AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": ["ai-receptionist", "hvac", "lead-gen", "openai", "google-sheets"]
}