{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "2e1e6b9f-af3a-4da5-a434-7079570cfbfc",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2784,
        -1104
      ],
      "parameters": {
        "color": 3,
        "width": 496,
        "height": 448,
        "content": "## Appointment Booked \u2192 Confirmation + Reminders + No-Show Re-booking\n\n**How it works:**\n1. Receives new appointment from booking system (Calendly, Acuity, Jane App, etc.)\n2. Normalizes patient data + appointment type, date/time, provider\n3. Creates/updates patient contact in Aloware\n4. Sends instant confirmation SMS with date, time, and location\n5. Enrolls in Aloware Reminder Sequence (48h, 24h, 2h before)\n6. Waits until 1 hour after appointment time\n7. Checks for no-show tag \u2192 enrolls in re-booking sequence if needed\n\n**Setup:**\n- Set n8n Variables: `ALOWARE_API_TOKEN`, `ALOWARE_LINE_PHONE`, `ALOWARE_REMINDER_SEQUENCE_ID`, `ALOWARE_NOSHOW_SEQUENCE_ID`, `PRACTICE_NAME`, `PRACTICE_ADDRESS`\n- Configure booking system webhook to POST to this URL"
      },
      "typeVersion": 1
    },
    {
      "id": "63c30f32-6a6b-49f5-be8d-73673e91e386",
      "name": "Book & Confirm",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3392,
        -1056
      ],
      "parameters": {
        "color": 2,
        "width": 912,
        "height": 276,
        "content": "### \u2705 Receive Booking & Send Confirmation"
      },
      "typeVersion": 1
    },
    {
      "id": "03196b2f-0a4e-4556-9798-de3c206c0c3b",
      "name": "Reminder Sequence",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4352,
        -1056
      ],
      "parameters": {
        "color": 4,
        "width": 264,
        "height": 276,
        "content": "### \ud83d\udd14 Enroll in Reminders"
      },
      "typeVersion": 1
    },
    {
      "id": "102bc282-b24b-469c-a82c-325c24cd8c6f",
      "name": "No-Show Detection",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4656,
        -1104
      ],
      "parameters": {
        "color": 5,
        "width": 1220,
        "height": 384,
        "content": "### \u23f0 Post-Appointment No-Show Check"
      },
      "typeVersion": 1
    },
    {
      "id": "ff404a94-2ecb-4e1f-94b2-756129cbd6d2",
      "name": "Reminder Tip",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4272,
        -1216
      ],
      "parameters": {
        "width": 400,
        "height": 80,
        "content": "Configure Aloware Reminder Sequence: 48h SMS, 24h SMS + call, 2h final SMS. Reply CANCEL \u2192 disenroll."
      },
      "typeVersion": 1
    },
    {
      "id": "afd412a6-0679-4f34-9a03-20fa1fbee929",
      "name": "Booking System: Appointment Created",
      "type": "n8n-nodes-base.webhook",
      "position": [
        3472,
        -976
      ],
      "parameters": {
        "path": "appointment-booked",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "0aa42b86-5845-4821-93c4-8f788e5d4073",
      "name": "Normalize Appointment Data",
      "type": "n8n-nodes-base.set",
      "position": [
        3696,
        -976
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a001",
              "name": "patientPhone",
              "type": "string",
              "value": "={{ $json.body?.invitee?.phone_number || $json.phone || $json.patient?.phone || $json.contact?.phone || $json.phone_number || '' }}"
            },
            {
              "id": "a002",
              "name": "patientFirstName",
              "type": "string",
              "value": "={{ $json.body?.invitee?.first_name || $json.first_name || $json.patient?.first_name || $json.name?.split(' ')[0] || 'there' }}"
            },
            {
              "id": "a003",
              "name": "patientLastName",
              "type": "string",
              "value": "={{ $json.body?.invitee?.last_name || $json.last_name || $json.patient?.last_name || '' }}"
            },
            {
              "id": "a004",
              "name": "patientEmail",
              "type": "string",
              "value": "={{ $json.body?.invitee?.email || $json.email || $json.patient?.email || '' }}"
            },
            {
              "id": "a005",
              "name": "appointmentType",
              "type": "string",
              "value": "={{ $json.body?.event_type?.name || $json.appointment_type || $json.service || $json.event_name || 'your appointment' }}"
            },
            {
              "id": "a006",
              "name": "appointmentDatetime",
              "type": "string",
              "value": "={{ $json.body?.scheduled_event?.start_time || $json.appointment_time || $json.start_time || $json.datetime || '' }}"
            },
            {
              "id": "a007",
              "name": "appointmentDateFormatted",
              "type": "string",
              "value": "={{ $json.body?.scheduled_event?.start_time ? DateTime.fromISO($json.body.scheduled_event.start_time).toFormat('EEEE, MMMM d') : 'soon' }}"
            },
            {
              "id": "a008",
              "name": "appointmentTimeFormatted",
              "type": "string",
              "value": "={{ $json.body?.scheduled_event?.start_time ? DateTime.fromISO($json.body.scheduled_event.start_time).toFormat('h:mm a') : '' }}"
            },
            {
              "id": "a009",
              "name": "appointmentId",
              "type": "string",
              "value": "={{ $json.body?.scheduled_event?.uri || $json.appointment_id || $json.id || '' }}"
            },
            {
              "id": "a010",
              "name": "providerName",
              "type": "string",
              "value": "={{ $json.body?.event_type?.profile?.name || $json.provider || $json.staff_name || $vars.PRACTICE_NAME }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9ef238fe-b864-47ae-8a60-e00bdd5cff1f",
      "name": "Aloware: Create or Update Patient Contact",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3920,
        -976
      ],
      "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.patientPhone }}"
            },
            {
              "name": "first_name",
              "value": "={{ $json.patientFirstName }}"
            },
            {
              "name": "last_name",
              "value": "={{ $json.patientLastName }}"
            },
            {
              "name": "email",
              "value": "={{ $json.patientEmail }}"
            },
            {
              "name": "lead_source",
              "value": "Appointment Booking"
            },
            {
              "name": "csf1",
              "value": "={{ 'Appt Type: ' + $json.appointmentType }}"
            },
            {
              "name": "csf2",
              "value": "={{ 'Next Appt: ' + $json.appointmentDateFormatted + ' at ' + $json.appointmentTimeFormatted }}"
            },
            {
              "name": "notes",
              "value": "={{ 'Appointment booked: ' + $json.appointmentType + ' on ' + $json.appointmentDateFormatted + ' at ' + $json.appointmentTimeFormatted }}"
            },
            {
              "name": "force_update",
              "value": "=true"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "155dda42-b3b1-4b21-9d6e-28798a41bcef",
      "name": "Aloware: Send Booking Confirmation SMS",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4144,
        -976
      ],
      "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 Appointment Data').item.json.patientPhone }}"
            },
            {
              "name": "message",
              "value": "=Hi {{ $('Normalize Appointment Data').item.json.patientFirstName }}! \u2705 Your {{ $('Normalize Appointment Data').item.json.appointmentType }} is confirmed for {{ $('Normalize Appointment Data').item.json.appointmentDateFormatted }} at {{ $('Normalize Appointment Data').item.json.appointmentTimeFormatted }}. Location: {{ $vars.PRACTICE_ADDRESS }}. Reply CANCEL to cancel or RESCHEDULE to reschedule. See you soon! \u2014 {{ $vars.PRACTICE_NAME }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "12a2bdde-5fa3-4036-81be-0f8311736f9c",
      "name": "Aloware: Enroll in Reminder Sequence",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4432,
        -976
      ],
      "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_REMINDER_SEQUENCE_ID }}"
            },
            {
              "name": "phone_number",
              "value": "={{ $('Normalize Appointment Data').item.json.patientPhone }}"
            },
            {
              "name": "source",
              "value": "n8n-appointment-booked"
            },
            {
              "name": "force_enroll",
              "value": "=true"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a8d2225f-d1b4-4ead-aba9-05a55a241d2e",
      "name": "Wait Until After Appointment",
      "type": "n8n-nodes-base.wait",
      "position": [
        4800,
        -976
      ],
      "parameters": {
        "resume": "specificTime",
        "dateTime": "={{ DateTime.fromISO($('Normalize Appointment Data').item.json.appointmentDatetime).plus({hours: 1}).toISO() }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "97e38141-6de2-4230-9b1f-8c9633ce8de7",
      "name": "Aloware: Check If Appointment Completed",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5040,
        -976
      ],
      "parameters": {
        "url": "=https://app.aloware.com/api/v1/webhook/contact/phone-number?api_token={{ $vars.ALOWARE_API_TOKEN }}&phone_number={{ $('Normalize Appointment Data').item.json.patientPhone }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "5250f894-35f2-4270-9da1-daed71de4147",
      "name": "Was It a No-Show?",
      "type": "n8n-nodes-base.if",
      "position": [
        5264,
        -976
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cond_001",
              "operator": {
                "type": "array",
                "operation": "contains"
              },
              "leftValue": "={{ $json.data?.tags || [] }}",
              "rightValue": "no-show"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "120a3835-ac8d-4e9b-b7e0-5e8d344652ed",
      "name": "Aloware: Enroll in No-Show Re-booking Sequence",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5568,
        -1072
      ],
      "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_NOSHOW_SEQUENCE_ID }}"
            },
            {
              "name": "phone_number",
              "value": "={{ $('Normalize Appointment Data').item.json.patientPhone }}"
            },
            {
              "name": "source",
              "value": "n8n-no-show"
            },
            {
              "name": "force_enroll",
              "value": "=true"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "15c3b894-f9a8-4bd7-b5fc-44f2dc389ca7",
      "name": "Appointment Completed \u2014 No Action",
      "type": "n8n-nodes-base.noOp",
      "position": [
        5568,
        -880
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "connections": {
    "Was It a No-Show?": {
      "main": [
        [
          {
            "node": "Aloware: Enroll in No-Show Re-booking Sequence",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Appointment Completed \u2014 No Action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Appointment Data": {
      "main": [
        [
          {
            "node": "Aloware: Create or Update Patient Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Until After Appointment": {
      "main": [
        [
          {
            "node": "Aloware: Check If Appointment Completed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Booking System: Appointment Created": {
      "main": [
        [
          {
            "node": "Normalize Appointment Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aloware: Enroll in Reminder Sequence": {
      "main": [
        [
          {
            "node": "Wait Until After Appointment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aloware: Send Booking Confirmation SMS": {
      "main": [
        [
          {
            "node": "Aloware: Enroll in Reminder Sequence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aloware: Check If Appointment Completed": {
      "main": [
        [
          {
            "node": "Was It a No-Show?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aloware: Create or Update Patient Contact": {
      "main": [
        [
          {
            "node": "Aloware: Send Booking Confirmation SMS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}