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)- Build a confirmation flex message showing the service, staff member, location, date and time.
- Resolve the
channel_access_tokenfromline_oaand push the message to the user. - Update the booking row and merge the
appt_*values intoline_user.custom_attribute.
- Cancellation (
cancel) — send a plain text cancellation notice and update the booking status.
Booking reminder cron (every minute)
- Query bookings that satisfy all of the following:
- status is
confirmedand the reminder has not been sent yet; - the associated journey defines a
reminder_hours_beforegreater 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.
- status is
- Publish the payload onto the
booking_notificationqueue so the consumer does the actual send. - Mark the reminder as sent to prevent duplicates.
No-show cron (every minute)
- Query bookings still marked
confirmedwhose end time plus a grace period has passed. The grace period comes from the journey'sno_show_grace_minutes, defaulting to 30 minutes. - Flip the status to no-show and publish a follow-up event so workflows can react to it.
Key Files & Functions
| File | Responsibility |
|---|---|
internal/appointment/booking_notification.go | BookingNotificationService.SendConfirmation, BookingNotificationService.HandleCancel, buildConfirmationFlex, and the BookingNotificationPayload structure carrying the full booking detail |
internal/appointment/consumer.go | Consumer.HandleBookingNotification — dispatches between confirmation and cancellation |
internal/cronscheduler/booking_reminder.go | BookingReminderService.Run, scheduled */1 * * * * |
internal/cronscheduler/booking_noshow.go | BookingNoShowService.Run, scheduled */1 * * * * |
cmd/worker/main.go | runCronScheduler — 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
appointmentschema —booking,journey(reminder_hours_before,no_show_grace_minutes),service,staff,location. - Tables in the public schema —
line_oa(access token) andline_user(theappt_*custom attributes). - LINE API —
POST /v2/bot/message/pushfor the confirmation flex, the cancellation text and the reminder message. - Works together with Booking Event Triggers, which lets booking activity drive workflows.