{
  "name": "Instant web-form reply (Real estate agents)",
  "nodes": [
    {
      "id": "d4ee355e-1efc-5527-9ee6-dc0eedbfde2a",
      "name": "New lead from your form",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "new-lead",
        "responseMode": "responseNode",
        "options": {}
      },
      "webhookId": "4c0a0972-615e-5f80-af5f-29a783d75f76"
    },
    {
      "id": "22be7a91-fbf4-52db-a676-aca00ad63a3d",
      "name": "Config (edit me)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "60e0fd76-348a-57fe-b268-0687f2effd9e",
              "name": "business_name",
              "value": "YOUR BUSINESS NAME",
              "type": "string"
            },
            {
              "id": "c0f59155-2801-53a9-8f9b-9ccf3c427f37",
              "name": "booking_link",
              "value": "https://YOUR-BOOKING-LINK",
              "type": "string"
            },
            {
              "id": "490f7ba4-da4e-5904-bcc4-7311ffd56aaa",
              "name": "hours",
              "value": "Mon-Fri 8am-6pm",
              "type": "string"
            },
            {
              "id": "2789c164-6ecf-56aa-b9cf-f6345c6b4a53",
              "name": "owner_email",
              "value": "you@example.com",
              "type": "string"
            },
            {
              "id": "bdea14ea-36bc-5f67-befd-88cccb99e9ff",
              "name": "owner_cell",
              "value": "+15555550100",
              "type": "string"
            },
            {
              "id": "31986b06-6979-57a9-92c8-fb10cceb825e",
              "name": "twilio_number",
              "value": "+15555550199",
              "type": "string"
            },
            {
              "id": "af08252c-af7e-5b52-bb26-5c90e84944b7",
              "name": "lead_name",
              "value": "={{ $json.body.name || $json.body.first_name || 'there' }}",
              "type": "string"
            },
            {
              "id": "3b68c7ba-1d35-5f64-8899-d3b1a26a2ce6",
              "name": "lead_phone",
              "value": "={{ $json.body.phone || '' }}",
              "type": "string"
            },
            {
              "id": "7d034c51-192d-531f-949b-662aae5570ff",
              "name": "lead_email",
              "value": "={{ $json.body.email || '' }}",
              "type": "string"
            },
            {
              "id": "83263ad1-9261-5f8a-b661-0b0ba5e42b03",
              "name": "lead_message",
              "value": "={{ $json.body.message || $json.body.details || '' }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "8e371647-cd9c-5960-a801-e1f88e01f634",
      "name": "Tell the form it worked",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        440,
        0
      ],
      "parameters": {
        "respondWith": "text",
        "responseBody": "{\"ok\": true}",
        "options": {
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "application/json"
              }
            ]
          }
        }
      }
    },
    {
      "id": "3cb72c29-2965-5556-9c17-c10a0f207691",
      "name": "AI writes reply",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        660,
        0
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-5-mini",
          "mode": "id"
        },
        "messages": {
          "values": [
            {
              "content": "You are the assistant to a local real estate agent. Write one short, friendly SMS reply (under 300 characters) to a new lead. If they asked about a specific property, acknowledge it and offer to set up a showing. Ask one simple question (timeline, or pre-approved yes/no). Do not give legal, financial or pricing advice, do not make claims about schools, neighborhoods or demographics. Sign with the agent's name.",
              "role": "system"
            },
            {
              "content": "=Business: {{ $('Config (edit me)').item.json.business_name }}\nHours: {{ $('Config (edit me)').item.json.hours }}\nBooking link: {{ $('Config (edit me)').item.json.booking_link }}\nLead name: {{ $('Config (edit me)').item.json.lead_name }}\nWhat they wrote: {{ $('Config (edit me)').item.json.lead_message }}"
            }
          ]
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "REPLACE_OPENAI_CREDENTIAL",
          "name": "OpenAI account (placeholder)"
        }
      }
    },
    {
      "id": "c4ab62da-72a3-559b-966c-07bc30f4bf29",
      "name": "Has a phone number?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        880,
        -140
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "bf3be05b-dc72-5713-a5c8-97a99020f963",
              "leftValue": "={{ $('Config (edit me)').item.json.lead_phone }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "aab8f60e-d654-58b7-8a0f-8b2ffa2d566b",
      "name": "Text the lead",
      "type": "n8n-nodes-base.twilio",
      "typeVersion": 1,
      "position": [
        1100,
        -140
      ],
      "parameters": {
        "from": "={{ $('Config (edit me)').item.json.twilio_number }}",
        "to": "={{ $('Config (edit me)').item.json.lead_phone }}",
        "message": "={{ $('AI writes reply').item.json.message.content }}",
        "options": {}
      },
      "credentials": {
        "twilioApi": {
          "id": "REPLACE_TWILIO_CREDENTIAL",
          "name": "Twilio account (placeholder)"
        }
      }
    },
    {
      "id": "1965ab11-90ab-5261-91a9-0d348223906a",
      "name": "Has an email?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        880,
        60
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "85984039-74b1-52cb-914a-1779cc1dabe3",
              "leftValue": "={{ $('Config (edit me)').item.json.lead_email }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "5cb8ac1e-214c-511f-b5af-9a37007ad4be",
      "name": "Email the lead",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1100,
        60
      ],
      "parameters": {
        "sendTo": "={{ $('Config (edit me)').item.json.lead_email }}",
        "subject": "=Thanks for reaching out to {{ $('Config (edit me)').item.json.business_name }}",
        "emailType": "text",
        "message": "={{ $('AI writes reply').item.json.message.content }}",
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "REPLACE_GMAIL_CREDENTIAL",
          "name": "Gmail account (placeholder)"
        }
      }
    },
    {
      "id": "0de6818c-39f2-5d2d-abbe-09bac1bbbc70",
      "name": "Email the owner",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        880,
        260
      ],
      "parameters": {
        "sendTo": "={{ $('Config (edit me)').item.json.owner_email }}",
        "subject": "=New lead: {{ $('Config (edit me)').item.json.lead_name }}",
        "emailType": "text",
        "message": "=Name: {{ $('Config (edit me)').item.json.lead_name }}\nPhone: {{ $('Config (edit me)').item.json.lead_phone }}\nEmail: {{ $('Config (edit me)').item.json.lead_email }}\nMessage: {{ $('Config (edit me)').item.json.lead_message }}\n\nWe already replied with: {{ $('AI writes reply').item.json.message.content }}",
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "REPLACE_GMAIL_CREDENTIAL",
          "name": "Gmail account (placeholder)"
        }
      }
    },
    {
      "id": "69ac2eed-1576-5519-9182-00d725b20620",
      "name": "Setup steps",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -520,
        -160
      ],
      "parameters": {
        "content": "## Setup (about 1 hour)\n1. Fill in **Config (edit me)**.\n2. Connect your own **Twilio**, **OpenAI** and **Gmail** credentials on the red nodes.\n3. Point your website form to POST to `YOUR_N8N_URL/webhook/new-lead` with fields `name`, `phone`, `email`, `message` (or forward lead emails with a Gmail filter + an Email Trigger node).\n4. Register your Twilio number for A2P 10DLC.\n5. Send yourself a test lead, then activate.",
        "height": 380,
        "width": 460
      }
    }
  ],
  "connections": {
    "New lead from your form": {
      "main": [
        [
          {
            "node": "Config (edit me)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config (edit me)": {
      "main": [
        [
          {
            "node": "Tell the form it worked",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tell the form it worked": {
      "main": [
        [
          {
            "node": "AI writes reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI writes reply": {
      "main": [
        [
          {
            "node": "Has a phone number?",
            "type": "main",
            "index": 0
          },
          {
            "node": "Has an email?",
            "type": "main",
            "index": 0
          },
          {
            "node": "Email the owner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has a phone number?": {
      "main": [
        [
          {
            "node": "Text the lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has an email?": {
      "main": [
        [
          {
            "node": "Email the lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "generatedBy": "Speed-to-Lead Playbooks"
  },
  "tags": []
}