
I built an automated Hotel Room Access pin generation workflow
Workflow Code:
https://gist.github.com/iamvaar-dev/6544545160d058f716b121e7e38e52bc
Pre-requesties:
- Apaleo Client id and secret.
- Apaleo basic authentication key which we recieve just after creation of the dev app.
- seam.co Api key as we need it to generate smart lock pin.
- Twillio API
Workflow 1: Smart Lock PIN Generation & Notifications
This is the primary workflow that runs whenever a room is assigned to a guest.
- When Reservation Unit Assigned (Apaleo Trigger)
- What it does: This is the starting point. It listens for a specific webhook event from Apaleo (
reservation/unit-assigned). As soon as a staff member assigns a physical room to a booking, this node triggers the automation.
- What it does: This is the starting point. It listens for a specific webhook event from Apaleo (
- Fetch Reservation Details (Apaleo Node)
- What it does: It takes the ID from the trigger node and makes a request (
BookingReservationsByIdGet) to Apaleo to grab the full details of the reservation, specifically the arrival and departure times needed for the smart lock.
- What it does: It takes the ID from the trigger node and makes a request (
- Map Room ID to Lock ID (Code Node)
- What it does: This runs custom JavaScript to match the Apaleo room string (e.g., "BER-VWD 1.001") against a hardcoded database of your physical locks. It finds the corresponding Seam
locker_idand prepares a clean JSON payload containing the device ID, reservation ID, and the exact start/end times for the lock access.
- What it does: This runs custom JavaScript to match the Apaleo room string (e.g., "BER-VWD 1.001") against a hardcoded database of your physical locks. It finds the corresponding Seam
- Post Access Code to Seam (HTTP Request Node)
- What it does: It sends a POST request to Seam's API (
/access_codes/create) using the data prepared in the previous step. Seam generates a unique PIN that will automatically activate at check-in time and expire at check-out time.
- What it does: It sends a POST request to Seam's API (
- Append PIN to Reservation Note (Apaleo Node)
- What it does: Uses a PATCH request to update the Apaleo reservation. It takes the newly generated PIN from Seam and saves it directly into the reservation's comments/notes so hotel staff have a record of it.
- Fetch Customer Contact Data (HTTP Request Node)
- What it does: Makes another call to Apaleo's API using a Bearer token to pull expanded customer details, specifically the
primaryGuestandbookerprofiles. This is required to get the guest's email address and phone number.
- What it does: Makes another call to Apaleo's API using a Bearer token to pull expanded customer details, specifically the
- Send Email via Gmail (Gmail Node) & Send PIN via Twilio (Twilio Node)
- What they do: The workflow splits into two parallel actions here.
- The Gmail node takes the customer's email and sends a beautifully formatted, custom HTML email containing their secure PIN and instructions.
- The Twilio node simultaneously takes the customer's phone number and sends a concise SMS text message with the PIN for easy access on the go.
- What they do: The workflow splits into two parallel actions here.
Workflow 2: Automated API Token Rotation
Because the Apaleo Bearer token (used in the "Fetch Customer Contact Data" node) likely expires every 60 minutes, this background workflow runs independently to refresh it.
- Every 58 Minutes Trigger (Schedule Trigger Node)
- What it does: Acts as a cron job, firing off this secondary sequence exactly every 58 minutes.
- Fetch Access Token (HTTP Request Node)
- What it does: Sends a POST request to Apaleo's identity server (
identity.apaleo.com/connect/token) using a static Basic Auth key to request a brand new, short-lived access token.
- What it does: Sends a POST request to Apaleo's identity server (
- Patch API Credential (HTTP Request Node)
- What it does: This is a clever use of the n8n API itself. It takes the fresh token fetched in the previous step and makes a PATCH request to your n8n instance. It dynamically overwrites the existing "Apaleo Bearer Auth" credential saved in n8n. This ensures that Workflow 1 always has a valid token when it needs to fetch customer data.