{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "ba21ac43-22fb-4163-a023-2b67643f1c90",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4576,
        -2624
      ],
      "parameters": {
        "color": 3,
        "width": 524,
        "height": 400,
        "content": "## Guesty Booking \u2192 Guest SMS Lifecycle\n\n**How it works:**\n1. Receives new reservation from Guesty webhook\n2. Normalizes guest data + check-in/out dates, listing, confirmation code\n3. Creates guest contact in Aloware with reservation details\n4. Sends instant booking confirmation SMS\n5. Enrolls in Check-in Reminder Sequence (3-day, 1-day, day-of)\n6. Waits until 18 hours after checkout\n7. Enrolls in Post-Stay Review Request Sequence\n\n**Setup:**\n- Set n8n Variables: `ALOWARE_API_TOKEN`, `ALOWARE_LINE_PHONE`, `ALOWARE_CHECKIN_SEQUENCE_ID`, `ALOWARE_REVIEW_SEQUENCE_ID`, `PROPERTY_COMPANY_NAME`\n- In Guesty, create webhook for \"New Reservation\" events\n- Create 2 Aloware Sequences (Check-in Reminders + Post-Stay Review)"
      },
      "typeVersion": 1
    },
    {
      "id": "032e0ccc-2219-4d53-a5d7-4443c23fea6e",
      "name": "Book & Confirm",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5232,
        -2496
      ],
      "parameters": {
        "color": 4,
        "width": 912,
        "height": 260,
        "content": "### \u2705 Receive Booking & Confirm"
      },
      "typeVersion": 1
    },
    {
      "id": "ec1e2184-9155-46c6-8e17-268ef17d6d05",
      "name": "Check-in Reminders",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6160,
        -2496
      ],
      "parameters": {
        "color": 6,
        "width": 280,
        "height": 260,
        "content": "### \ud83d\udd14 Check-in Sequence"
      },
      "typeVersion": 1
    },
    {
      "id": "b5dab817-5073-401f-8289-37991c1e5095",
      "name": "Post-Checkout Review",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6464,
        -2496
      ],
      "parameters": {
        "color": 5,
        "width": 500,
        "height": 260,
        "content": "### \u2b50 Post-Checkout Review Request"
      },
      "typeVersion": 1
    },
    {
      "id": "f9241e28-f3e0-4457-be75-9452bbc7b8c6",
      "name": "Sequence Tip",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6096,
        -2608
      ],
      "parameters": {
        "width": 420,
        "height": 80,
        "content": "Check-in Sequence: 3 days before \u2192 property info, 1 day \u2192 instructions + WiFi, day of \u2192 door code"
      },
      "typeVersion": 1
    },
    {
      "id": "a7d34f82-3d35-4cb8-bb47-16da5e05ceda",
      "name": "Guesty: New Reservation",
      "type": "n8n-nodes-base.webhook",
      "position": [
        5296,
        -2432
      ],
      "parameters": {
        "path": "guesty-new-booking",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "7d800eaf-7401-4ee3-9701-18c61b886525",
      "name": "Normalize Reservation Data",
      "type": "n8n-nodes-base.set",
      "position": [
        5520,
        -2432
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a001",
              "name": "guestPhone",
              "type": "string",
              "value": "={{ $json.body?.guest?.phone || $json.guest?.phone || $json.phone || '' }}"
            },
            {
              "id": "a002",
              "name": "guestFirstName",
              "type": "string",
              "value": "={{ $json.body?.guest?.firstName || $json.guest?.first_name || $json.first_name || $json.name?.split(' ')[0] || 'Guest' }}"
            },
            {
              "id": "a003",
              "name": "guestLastName",
              "type": "string",
              "value": "={{ $json.body?.guest?.lastName || $json.guest?.last_name || $json.last_name || '' }}"
            },
            {
              "id": "a004",
              "name": "guestEmail",
              "type": "string",
              "value": "={{ $json.body?.guest?.email || $json.guest?.email || $json.email || '' }}"
            },
            {
              "id": "a005",
              "name": "checkInDate",
              "type": "string",
              "value": "={{ $json.body?.checkIn || $json.check_in || $json.checkInDateLocalized || '' }}"
            },
            {
              "id": "a006",
              "name": "checkOutDate",
              "type": "string",
              "value": "={{ $json.body?.checkOut || $json.check_out || $json.checkOutDateLocalized || '' }}"
            },
            {
              "id": "a007",
              "name": "listingName",
              "type": "string",
              "value": "={{ $json.body?.listing?.title || $json.listing?.title || $json.listing_name || 'your property' }}"
            },
            {
              "id": "a008",
              "name": "confirmationCode",
              "type": "string",
              "value": "={{ $json.body?.confirmationCode || $json.confirmation_code || $json.reservationId || '' }}"
            },
            {
              "id": "a009",
              "name": "numberOfGuests",
              "type": "string",
              "value": "={{ $json.body?.guestsCount || $json.guests_count || $json.number_of_guests || '' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "94377f03-461f-4377-b299-f61d43ac1369",
      "name": "Aloware: Create Guest Contact",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5744,
        -2432
      ],
      "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.guestPhone }}"
            },
            {
              "name": "first_name",
              "value": "={{ $json.guestFirstName }}"
            },
            {
              "name": "last_name",
              "value": "={{ $json.guestLastName }}"
            },
            {
              "name": "email",
              "value": "={{ $json.guestEmail }}"
            },
            {
              "name": "lead_source",
              "value": "Guesty Booking"
            },
            {
              "name": "csf1",
              "value": "={{ 'Property: ' + $json.listingName }}"
            },
            {
              "name": "csf2",
              "value": "={{ 'Check-in: ' + $json.checkInDate + ' | Check-out: ' + $json.checkOutDate }}"
            },
            {
              "name": "csf3",
              "value": "={{ $json.confirmationCode ? 'Confirmation: ' + $json.confirmationCode : '' }}"
            },
            {
              "name": "notes",
              "value": "={{ 'Guesty reservation for ' + $json.listingName + '. Guests: ' + $json.numberOfGuests }}"
            },
            {
              "name": "force_update",
              "value": "=true"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "290c8d07-89b4-4110-b8d8-926a83f911a3",
      "name": "Aloware: Send Booking Confirmation SMS",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5952,
        -2432
      ],
      "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 Reservation Data').item.json.guestPhone }}"
            },
            {
              "name": "message",
              "value": "=Hi {{ $('Normalize Reservation Data').item.json.guestFirstName }}! \ud83c\udf89 Your reservation at {{ $('Normalize Reservation Data').item.json.listingName }} is confirmed for {{ $('Normalize Reservation Data').item.json.checkInDate }}. Confirmation: {{ $('Normalize Reservation Data').item.json.confirmationCode }}. We'll send check-in details closer to your arrival. Reply here anytime with questions! \u2014 {{ $vars.PROPERTY_COMPANY_NAME }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "58c010c2-8376-46db-97cc-67ada4d2773c",
      "name": "Aloware: Enroll in Check-in Reminder Sequence",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6240,
        -2432
      ],
      "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_CHECKIN_SEQUENCE_ID }}"
            },
            {
              "name": "phone_number",
              "value": "={{ $('Normalize Reservation Data').item.json.guestPhone }}"
            },
            {
              "name": "source",
              "value": "n8n-guesty-booking"
            },
            {
              "name": "force_enroll",
              "value": "=true"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "31bd6eba-2429-465f-bd12-102427d632cc",
      "name": "Wait Until After Checkout",
      "type": "n8n-nodes-base.wait",
      "position": [
        6528,
        -2432
      ],
      "parameters": {
        "resume": "specificTime",
        "dateTime": "={{ DateTime.fromISO($('Normalize Reservation Data').item.json.checkOutDate).plus({hours: 18}).toISO() }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "6047143d-2937-42da-8b9f-f26032c3c007",
      "name": "Aloware: Enroll in Post-Stay Review Sequence",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6752,
        -2432
      ],
      "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_REVIEW_SEQUENCE_ID }}"
            },
            {
              "name": "phone_number",
              "value": "={{ $('Normalize Reservation Data').item.json.guestPhone }}"
            },
            {
              "name": "source",
              "value": "n8n-guesty-post-checkout"
            },
            {
              "name": "force_enroll",
              "value": "=false"
            }
          ]
        }
      },
      "typeVersion": 4.2
    }
  ],
  "connections": {
    "Guesty: New Reservation": {
      "main": [
        [
          {
            "node": "Normalize Reservation Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Until After Checkout": {
      "main": [
        [
          {
            "node": "Aloware: Enroll in Post-Stay Review Sequence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Reservation Data": {
      "main": [
        [
          {
            "node": "Aloware: Create Guest Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aloware: Create Guest Contact": {
      "main": [
        [
          {
            "node": "Aloware: Send Booking Confirmation SMS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aloware: Send Booking Confirmation SMS": {
      "main": [
        [
          {
            "node": "Aloware: Enroll in Check-in Reminder Sequence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aloware: Enroll in Check-in Reminder Sequence": {
      "main": [
        [
          {
            "node": "Wait Until After Checkout",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}