Booking Links + Calendar Functions Reference

Complete scheduling reference with instructions, highlighted calendar rules, clickable code cards, full-copy support, and Google Calendar workflow notes.

Open Scheduling Links
Booking Link Rule of Thumb

SchedulingLink decides what can be booked. Booking records what was booked. Google Calendar confirms whether the time is truly available.

  • Always check availability before showing a slot and again before creating a booking.
  • Always store external_event_id on Booking so reschedule/cancel updates the same calendar event.
  • Public pages should use getSchedulingLinkPublic, not direct entity reads.
Calendar Connector Pattern

Calendar-backed functions use the app-user Google Workspace Calendar connector when the user has connected their account.

const { accessToken } = await base44.asServiceRole.connectors.getCurrentAppUserConnection('69ddc2f7db4598a87eb698bd');

await fetch('https://www.googleapis.com/calendar/v3/calendars/primary/events', {
  headers: { Authorization: `Bearer ${accessToken}` }
});
System Architecture & Data Flows

Booking Links are the scheduling layer for public guests, internal CRM scheduling, agent/referral partner portals, and Cielo appointment workflows. SchedulingLink controls the public/internal rules, Booking stores the appointment lifecycle, and Google Calendar functions keep the real external calendar in sync.

SchedulingLink

Controls slug, duration, timezone, calendar, business hours, buffers, meeting location, branding, questions, and default-link flags.

Booking

Stores each appointment, guest/contact data, manage token, Google event ID, meeting URL, status, and related loan/opportunity context.

Google Workspace Calendar Connector

Per-user Google Calendar connector used by availability and calendar sync functions. Current connector id: 69ddc2f7db4598a87eb698bd.

Confirmation + Reminder Layer

triggerAppointmentConfirmation, resendBookingConfirmation, and cieloAppointmentReminder send confirmations and reminder actions from Booking data.

=== PUBLIC BOOKING LINK FLOW ===
1. Visitor opens the public booking route.
2. getSchedulingLinkPublic loads the public SchedulingLink by slug.
3. getAvailability calculates slots from SchedulingLink rules + Google Calendar conflicts.
4. Visitor selects a slot and submits guest details.
5. createBooking creates Booking, creates Google Calendar event, stores external_event_id, meeting_url, and manage_token.
6. Confirmation/reminder functions send follow-up messaging.
7. cancelBooking and rescheduleBooking use Booking.external_event_id to update the same calendar event.

=== INTERNAL + AGENT BOOKING FLOW ===
1. Internal user, CRM, loan, opportunity, or portal starts scheduling.
2. getInternalAvailableSlots checks internal rules and real calendar conflicts.
3. createUnifiedBooking creates the Booking with source, loan_id, opportunity_id, and guest context.
4. syncAgentBookingToCalendar handles agent-originated calendar sync when needed.
5. Booking remains the source of truth for reminders, confirmations, and manage links.

=== GOOGLE CALENDAR FLOW ===
1. User connects Google Workspace Calendar.
2. googleCalendarListCalendars lists available calendars for setup.
3. SchedulingLink.calendar_id stores the selected calendar.
4. Availability reads busy events before showing slots.
5. Booking creation/update/cancel writes back to Google Calendar.
Core Data Records
SchedulingLink

Rules and public/internal link settings.

Booking

Appointment lifecycle, guest data, calendar event ID, manage token, and meeting URL.

EmailCalendarConnection

Legacy email/calendar connection metadata used by older flows.

SubAccount

Agent/referral/borrower portal identity used in portal scheduling.

Loan / Opportunity

Optional business context attached to internal bookings.

Public Booking Link Flow

5
getSchedulingLinkPublic

Loads the safe public booking-link configuration by slug before the visitor sees times.

Click to view code + instructions →

utility

Modes:

Public
Slug lookup
Branding
Questions

Features:

Active/visible link checkHost display infoBranding and layoutCustom questions
getAvailability

Calculates public available slots from SchedulingLink rules and real Google Calendar conflicts.

Click to view code + instructions →

utility

Modes:

Availability
Timezone-aware
Calendar conflicts

Features:

Business hoursBuffersMinimum noticeMax days aheadGoogle busy events
createBooking

Creates the Booking record, writes the Google Calendar event, generates meeting/manage details, and sends confirmation.

Click to view code + instructions →

transactional

Modes:

Public submit
Google Calendar write
Confirmation

Features:

Booking createMeet link supportexternal_event_id storagemanage_tokenconfirmation messaging
cancelBooking

Cancels a booking and updates/removes the linked Google Calendar event.

Click to view code + instructions →

lifecycle

Modes:

Guest manage
Calendar delete/update

Features:

manage_token validationBooking status updateCalendar event sync
rescheduleBooking

Moves an existing booking to a new validated slot and updates the same Google Calendar event.

Click to view code + instructions →

lifecycle

Modes:

Guest manage
Availability re-check
Calendar update

Features:

Slot re-validationBooking updateexternal_event_id reuseconfirmation resend

Internal + Agent Scheduling

4
getInternalAvailableSlots

Finds internal slots for a target loan officer while checking real Google Calendar conflicts.

Click to view code + instructions →

utility

Modes:

Internal booking
Agent portal
Connector-backed

Features:

Target LO slotsCalendar busy checksInternal rulesUnrestricted internal mode support
createUnifiedBooking

Central internal booking creator for CRM, loan, opportunity, and portal scheduling flows.

Click to view code + instructions →

transactional

Modes:

Internal submit
CRM
Loan
Opportunity
Agent portal

Features:

loan_idopportunity_idsource trackingcalendar event creationnotifications
syncAgentBookingToCalendar

Syncs agent-originated appointment requests into the connected LO calendar.

Click to view code + instructions →

utility

Modes:

Agent portal
Calendar sync
Connector-backed

Features:

Agent contextLO calendar writeBooking repair/sync
getAgentCalendarEvents

Reads connected calendar events for portal schedule views.

Click to view code + instructions →

utility

Modes:

Calendar read
Portal schedule

Features:

Date window readsCurrent app-user connectionSchedule display

Google Calendar Management

4
googleCalendarListCalendars

Lists calendars available to the connected Google account for scheduling setup.

Click to view code + instructions →

utility

Modes:

Setup
Calendar list

Features:

Calendar dropdownPrimary calendarPermission test
googleCalendarList

Lists calendar events for diagnostics and schedule troubleshooting.

Click to view code + instructions →

utility

Modes:

Read events
Diagnostics

Features:

timeMin/timeMaxcalendar_idevent inspection
googleCalendarUpdate

Updates an existing Google Calendar event during reschedule/update flows.

Click to view code + instructions →

lifecycle

Modes:

Calendar update

Features:

event_id updatedate/time changemetadata preservation
googleCalendarDelete

Deletes/cancels an existing Google Calendar event.

Click to view code + instructions →

lifecycle

Modes:

Calendar delete

Features:

event_id deletecancel lifecycle

Diagnostics + Maintenance

5
testSchedulingLink

Runs a focused health check for one SchedulingLink.

Click to view code + instructions →

diagnostic

Modes:

Debug
Single link

Features:

slug checkvisibility checkcalendar checkavailability check
debugBookingLinks

Inspects missing slugs, inactive links, calendar IDs, and ownership mismatches.

Click to view code + instructions →

diagnostic

Modes:

Admin debug
Inventory

Features:

Link inventoryConfig issuesOwnership checks
backfillBookingLinks

Repairs or creates missing default booking links for users.

Click to view code + instructions →

utility

Modes:

Admin repair
Migration

Features:

Default link creationMissing slug repairUser defaults
triggerAppointmentConfirmation

Sends confirmation/reminder messaging for a Booking.

Click to view code + instructions →

transactional

Modes:

Confirmation
Reminder
Cielo

Features:

Booking lookupGuest messagingManage linkCommunication logging
cieloAppointmentReminder

Finds upcoming bookings and sends Cielo reminder actions.

Click to view code + instructions →

automation

Modes:

Scheduled
Cielo
Reminder

Features:

Upcoming booking scanReminder eligibilityDuplicate prevention

Important Notes

  • Public links only show slots when SchedulingLink is active and visible.
  • Google Calendar conflicts are checked before showing a slot and again before booking.
  • Booking.external_event_id is required for clean cancellation and rescheduling.
  • Agent/default scheduling links should be used first by Cielo when sending scheduling links.
Booking Links — Full Source Bundle

67 files · 18,194 lines · full source inlined at build time. Copy any single file or the entire bundle in one shot.