{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "b32784c4-0205-4a4f-b4b6-4a3eda4e7c44",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7072,
        -1744
      ],
      "parameters": {
        "color": 3,
        "width": 476,
        "height": 480,
        "content": "## Law Firm Inquiry \u2192 SMS + AI Intake + Practice Area Routing\n\n**How it works:**\n1. Receives client inquiry from website form or legal intake system\n2. Normalizes data: phone, name, practice area, case description\n3. Creates contact in Aloware with practice area + case details\n4. Sends immediate intake acknowledgment SMS\n5. Routes by practice area:\n   - High-intent (PI, Family, Criminal, Immigration) \u2192 immediate AI intake call\n   - Standard (Estate, Business, Real Estate) \u2192 consultation scheduling sequence\n\n**Setup:**\n- Set n8n Variables: `ALOWARE_API_TOKEN`, `ALOWARE_LINE_PHONE`, `ALOWARE_INTAKE_SEQUENCE_ID`, `ALOWARE_CONSULT_SEQUENCE_ID`, `FIRM_NAME`\n- Connect intake form to POST to this webhook URL\n- Create 2 Aloware Sequences (AI Intake + Consultation Scheduling)"
      },
      "typeVersion": 1
    },
    {
      "id": "b1db82f4-cd4d-4af7-9460-7423c73504b2",
      "name": "Receive & Create Contact",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7744,
        -1632
      ],
      "parameters": {
        "color": 6,
        "width": 928,
        "height": 260,
        "content": "### \ud83d\udce5 Receive Inquiry & Create Contact"
      },
      "typeVersion": 1
    },
    {
      "id": "8f0e0098-a9c8-4d47-8591-8c0e0eebe104",
      "name": "Practice Area Routing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        8752,
        -1728
      ],
      "parameters": {
        "color": 4,
        "width": 500,
        "height": 460,
        "content": "### \u2696\ufe0f Route by Practice Area"
      },
      "typeVersion": 1
    },
    {
      "id": "433e1ff3-fb00-4cfe-8b4f-285c6f1912ee",
      "name": "Practice Area Tip",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        8752,
        -1824
      ],
      "parameters": {
        "width": 420,
        "height": 60,
        "content": "High-intent: Personal Injury, Family, Criminal, Immigration. Edit IF node to match your firm's areas."
      },
      "typeVersion": 1
    },
    {
      "id": "4171993d-705f-49c9-bd4a-70d4101b1ed4",
      "name": "Law Firm: New Client Inquiry",
      "type": "n8n-nodes-base.webhook",
      "position": [
        7840,
        -1552
      ],
      "parameters": {
        "path": "law-firm-inquiry",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "514d7abc-13e4-4f40-bf98-fa1e7db44996",
      "name": "Normalize Inquiry Data",
      "type": "n8n-nodes-base.set",
      "position": [
        8064,
        -1552
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a001",
              "name": "clientPhone",
              "type": "string",
              "value": "={{ $json.body?.phone || $json.phone || $json.contact?.phone || '' }}"
            },
            {
              "id": "a002",
              "name": "clientFirstName",
              "type": "string",
              "value": "={{ $json.body?.first_name || $json.first_name || $json.name?.split(' ')[0] || 'there' }}"
            },
            {
              "id": "a003",
              "name": "clientLastName",
              "type": "string",
              "value": "={{ $json.body?.last_name || $json.last_name || $json.name?.split(' ').slice(1).join(' ') || '' }}"
            },
            {
              "id": "a004",
              "name": "clientEmail",
              "type": "string",
              "value": "={{ $json.body?.email || $json.email || '' }}"
            },
            {
              "id": "a005",
              "name": "practiceArea",
              "type": "string",
              "value": "={{ $json.body?.practice_area || $json.practice_area || $json.case_type || $json.service || 'General' }}"
            },
            {
              "id": "a006",
              "name": "caseDescription",
              "type": "string",
              "value": "={{ $json.body?.message || $json.message || $json.case_description || '' }}"
            },
            {
              "id": "a007",
              "name": "preferredContact",
              "type": "string",
              "value": "={{ $json.body?.preferred_contact || $json.preferred_contact || 'anytime' }}"
            },
            {
              "id": "a008",
              "name": "leadSource",
              "type": "string",
              "value": "={{ $json.body?.source || $json.source || $json.utm_source || 'Website' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c679fa02-2b58-4796-a23c-6b0acaea7489",
      "name": "Aloware: Create Client Contact",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        8288,
        -1552
      ],
      "parameters": {
        "url": "https://app.aloware.com/api/v1/webhook/forms",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "api_token",
              "value": "={{ $vars.ALOWARE_API_TOKEN }}"
            },
            {
              "name": "phone_number",
              "value": "={{ $json.clientPhone }}"
            },
            {
              "name": "first_name",
              "value": "={{ $json.clientFirstName }}"
            },
            {
              "name": "last_name",
              "value": "={{ $json.clientLastName }}"
            },
            {
              "name": "email",
              "value": "={{ $json.clientEmail }}"
            },
            {
              "name": "lead_source",
              "value": "={{ $json.leadSource }}"
            },
            {
              "name": "csf1",
              "value": "={{ 'Practice Area: ' + $json.practiceArea }}"
            },
            {
              "name": "csf2",
              "value": "={{ 'Preferred Contact: ' + $json.preferredContact }}"
            },
            {
              "name": "notes",
              "value": "={{ $json.caseDescription ? 'Case: ' + $json.caseDescription : $json.practiceArea + ' inquiry from ' + $json.leadSource }}"
            },
            {
              "name": "force_update",
              "value": "=true"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "22730dd1-bd16-4bf7-8a8d-6305016d9f21",
      "name": "Aloware: Send Intake SMS",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        8496,
        -1552
      ],
      "parameters": {
        "url": "https://app.aloware.com/api/v1/webhook/sms-gateway/send",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "api_token",
              "value": "={{ $vars.ALOWARE_API_TOKEN }}"
            },
            {
              "name": "from",
              "value": "={{ $vars.ALOWARE_LINE_PHONE }}"
            },
            {
              "name": "to",
              "value": "={{ $('Normalize Inquiry Data').item.json.clientPhone }}"
            },
            {
              "name": "message",
              "value": "=Hi {{ $('Normalize Inquiry Data').item.json.clientFirstName }}, thank you for contacting {{ $vars.FIRM_NAME }}. We've received your {{ $('Normalize Inquiry Data').item.json.practiceArea }} inquiry and a member of our team will be reaching out soon. If this is urgent, you can call us directly at {{ $vars.ALOWARE_LINE_PHONE }}."
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a747bdcf-45ec-4461-927e-b60f907561df",
      "name": "Is High-Intent Practice Area?",
      "type": "n8n-nodes-base.if",
      "position": [
        8832,
        -1552
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "cond_001",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $('Normalize Inquiry Data').item.json.practiceArea.toLowerCase() }}",
              "rightValue": "personal injury"
            },
            {
              "id": "cond_002",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $('Normalize Inquiry Data').item.json.practiceArea.toLowerCase() }}",
              "rightValue": "family"
            },
            {
              "id": "cond_003",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $('Normalize Inquiry Data').item.json.practiceArea.toLowerCase() }}",
              "rightValue": "criminal"
            },
            {
              "id": "cond_004",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $('Normalize Inquiry Data').item.json.practiceArea.toLowerCase() }}",
              "rightValue": "immigration"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "aa2f9567-7002-4877-9c93-818deec0f2a8",
      "name": "Aloware: Enroll in AI Intake Sequence",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        9056,
        -1680
      ],
      "parameters": {
        "url": "https://app.aloware.com/api/v1/webhook/sequence-enroll",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "api_token",
              "value": "={{ $vars.ALOWARE_API_TOKEN }}"
            },
            {
              "name": "sequence_id",
              "value": "={{ $vars.ALOWARE_INTAKE_SEQUENCE_ID }}"
            },
            {
              "name": "phone_number",
              "value": "={{ $('Normalize Inquiry Data').item.json.clientPhone }}"
            },
            {
              "name": "source",
              "value": "n8n-law-high-intent"
            },
            {
              "name": "force_enroll",
              "value": "=true"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1af39276-257e-49d1-b80a-7d0c280d6a9a",
      "name": "Aloware: Enroll in Consultation Scheduling Sequence",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        9056,
        -1440
      ],
      "parameters": {
        "url": "https://app.aloware.com/api/v1/webhook/sequence-enroll",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "api_token",
              "value": "={{ $vars.ALOWARE_API_TOKEN }}"
            },
            {
              "name": "sequence_id",
              "value": "={{ $vars.ALOWARE_CONSULT_SEQUENCE_ID }}"
            },
            {
              "name": "phone_number",
              "value": "={{ $('Normalize Inquiry Data').item.json.clientPhone }}"
            },
            {
              "name": "source",
              "value": "n8n-law-consultation"
            },
            {
              "name": "force_enroll",
              "value": "=false"
            }
          ]
        }
      },
      "typeVersion": 4.2
    }
  ],
  "connections": {
    "Normalize Inquiry Data": {
      "main": [
        [
          {
            "node": "Aloware: Create Client Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aloware: Send Intake SMS": {
      "main": [
        [
          {
            "node": "Is High-Intent Practice Area?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Law Firm: New Client Inquiry": {
      "main": [
        [
          {
            "node": "Normalize Inquiry Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is High-Intent Practice Area?": {
      "main": [
        [
          {
            "node": "Aloware: Enroll in AI Intake Sequence",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Aloware: Enroll in Consultation Scheduling Sequence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aloware: Create Client Contact": {
      "main": [
        [
          {
            "node": "Aloware: Send Intake SMS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}