Skip to main content

Appointment Notifications

Overview

The appointment module lets customers book slots and appointments through LINE. The worker's job is to send notifications at the moments that matter: booking confirmation, cancellation, a reminder ahead of the appointment, and marking a customer as a no-show.

Everything runs on the cron-scheduler profile: one consumer for the booking_notification queue plus two cron scanners that fire every minute.

Business Flow

The booking_notification consumer

The consumer dispatches on the payload's type field.

  • Confirmation (confirm, or no type at all)
    1. Build a confirmation flex message showing the service, staff member, location, date and time.
    2. Resolve the channel_access_token from line_oa and push the message to the user.
    3. Update the booking row and merge the appt_* values into line_user.custom_attribute.
  • Cancellation (cancel) — send a plain text cancellation notice and update the booking status.

Booking reminder cron (every minute)

  1. Query bookings that satisfy all of the following:
    • status is confirmed and the reminder has not been sent yet;
    • the associated journey defines a reminder_hours_before greater than zero;
    • the reminder is now due — the appointment time minus the configured lead time has passed;
    • joined against journey, service, staff and location so the message can show real names.
  2. Publish the payload onto the booking_notification queue so the consumer does the actual send.
  3. Mark the reminder as sent to prevent duplicates.

No-show cron (every minute)

  1. Query bookings still marked confirmed whose end time plus a grace period has passed. The grace period comes from the journey's no_show_grace_minutes, defaulting to 30 minutes.
  2. Flip the status to no-show and publish a follow-up event so workflows can react to it.

Key Files & Functions

FileResponsibility
internal/appointment/booking_notification.goBookingNotificationService.SendConfirmation, BookingNotificationService.HandleCancel, buildConfirmationFlex, and the BookingNotificationPayload structure carrying the full booking detail
internal/appointment/consumer.goConsumer.HandleBookingNotification — dispatches between confirmation and cancellation
internal/cronscheduler/booking_reminder.goBookingReminderService.Run, scheduled */1 * * * *
internal/cronscheduler/booking_noshow.goBookingNoShowService.Run, scheduled */1 * * * *
cmd/worker/main.gorunCronScheduler — where the services and cron jobs are assembled

Queue: booking_notification, both consumed and published on the cron-scheduler profile.

Connections to Other Services

  • Receives jobs from client-api-go (users booking or cancelling through LIFF), cms-api-go (admins managing the schedule), and the worker's own cron scanners.
  • Tables in the appointment schemabooking, journey (reminder_hours_before, no_show_grace_minutes), service, staff, location.
  • Tables in the public schemaline_oa (access token) and line_user (the appt_* custom attributes).
  • LINE APIPOST /v2/bot/message/push for the confirmation flex, the cancellation text and the reminder message.
  • Works together with Booking Event Triggers, which lets booking activity drive workflows.