{
  "name": "Instant web-form reply (Law Firms)",
  "nodes": [
    {
      "id": "6c310b63-3980-5254-9498-012d910d75e7",
      "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": "ee19c953-456f-588d-88ed-c9c7e92a14e1"
    },
    {
      "id": "1976a4fe-4afd-5f91-a645-fa55e4f0a459",
      "name": "Config (edit me)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ab09dc1a-ed3c-50bb-aea7-86216dfd3f17",
              "name": "business_name",
              "value": "YOUR BUSINESS NAME",
              "type": "string"
            },
            {
              "id": "1e7b3dcc-f643-5a3a-8d41-bd1f5301572d",
              "name": "booking_link",
              "value": "https://YOUR-BOOKING-LINK",
              "type": "string"
            },
            {
              "id": "cf2cbcee-8e36-56e1-b899-7bc9d0fbb87d",
              "name": "hours",
              "value": "Mon-Fri 8am-6pm",
              "type": "string"
            },
            {
              "id": "ee7f2466-a652-55e1-b9d8-97954efe8b60",
              "name": "owner_email",
              "value": "you@example.com",
              "type": "string"
            },
            {
              "id": "88a11386-5d65-5574-b7fa-97c209986604",
              "name": "owner_cell",
              "value": "+15555550100",
              "type": "string"
            },
            {
              "id": "68cbb137-e78f-5ec9-a1a8-d94f03ef525d",
              "name": "twilio_number",
              "value": "+15555550199",
              "type": "string"
            },
            {
              "id": "eeeafdd5-f1a0-5545-aaec-610842961603",
              "name": "lead_name",
              "value": "={{ $json.body.name || $json.body.first_name || 'there' }}",
              "type": "string"
            },
            {
              "id": "1d19ecf5-407e-5082-a538-5186fd6b7458",
              "name": "lead_phone",
              "value": "={{ $json.body.phone || '' }}",
              "type": "string"
            },
            {
              "id": "35ccf708-0317-54fc-b04d-2d5ecfda6b55",
              "name": "lead_email",
              "value": "={{ $json.body.email || '' }}",
              "type": "string"
            },
            {
              "id": "ec544335-713d-5103-90cf-a278ded32fde",
              "name": "lead_message",
              "value": "={{ $json.body.message || $json.body.details || '' }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "1e90775c-f9e3-5747-8df1-e75ef72c7888",
      "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": "165690ec-b071-59ec-9a35-767d9b1717ea",
      "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 friendly intake coordinator at a small law firm. Write one short, warm SMS reply (under 300 characters) to a person asking about legal help. Thank them, confirm an attorney or intake team member will call them back during office hours, and offer the consultation booking link. Never give legal advice, never predict an outcome, never say the firm will take the case, and never quote fees. Ask them not to send case details or documents by text. If they say someone is in custody, a court date is today or tomorrow, or they are in danger, tell them to call the office directly and, if they are in danger, to call 911. Sign off with the firm 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": "33eb7255-1c30-5d26-b3cd-bb8975a8177f",
      "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": "ceec291a-58ea-59da-ad44-ff7fffcd5a0a",
              "leftValue": "={{ $('Config (edit me)').item.json.lead_phone }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "bd1f9ff8-d42b-500f-bce2-9100ebe90928",
      "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": "f145a77c-697e-56ae-a438-86460da4d182",
      "name": "Has an email?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        880,
        60
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "a4ccd60b-7929-54bb-9009-aa1ec4c04292",
              "leftValue": "={{ $('Config (edit me)').item.json.lead_email }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "df924302-0137-51e9-852a-7354f61bf8ec",
      "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": "130a1315-1437-53b7-9713-de70fdf3a5ab",
      "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": "baec129e-61f1-5078-97e6-fee70cff2ab1",
      "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": []
}