Skip to main content

Booking & Meeting Functions

These edge functions handle the meeting lifecycle: confirmation emails, reminders, cancellation, and no-show detection.

send-booking-notification

Sends confirmation emails when a meeting is booked. Uses the Resend API for email delivery. Supports dual-mode (client and internal booking).

Input

interface BookingNotificationRequest {
// One of these must be provided:
meetingId?: string; // For client meetings
salesMeetingId?: string; // For internal sales meetings
}

Flow

Email Content

The confirmation email includes:

  • Meeting title
  • Date and time (in the owner's timezone)
  • Duration
  • Meeting link (Google Meet / Teams)
  • Booker's name and contact info
  • Calendar link (.ics attachment or "Add to Calendar" link)

Owner Email Resolution

For internal meetings, the owner email is fetched via the Supabase Admin API:

const { data: { user } } = await supabaseAdmin.auth.admin.getUserById(meeting.user_id);
const ownerEmail = user.email;

Side Effects

  • Sends 2 emails (to booker + to meeting owner) via Resend API
  • Updates confirmation_sent_at on the meeting record
  • Requires RESEND_API_KEY secret

send-meeting-reminder

Sends reminder emails at 24 hours and 1 hour before a meeting. Designed to be called by a scheduled job (cron) or manually triggered.

Input

interface ReminderRequest {
type: '24h' | '1h'; // Which reminder to send
}

Logic

Reminder Windows

  • 24h reminder: Meetings scheduled between 23-25 hours from now
  • 1h reminder: Meetings scheduled between 50-70 minutes from now

Side Effects

  • Sends reminder emails to booker
  • Updates reminder_24h_sent_at or reminder_1h_sent_at to prevent duplicate sends
  • Skips meetings that are cancelled or already have the reminder flag set

cancel-meeting

Handles meeting cancellation. Cancels the calendar event and sends a cancellation email.

Input

interface CancelRequest {
meetingId?: string; // Client meeting
salesMeetingId?: string; // Internal sales meeting
reason?: string; // Cancellation reason
}

Flow

Side Effects

  • Deletes the calendar event from Google/Outlook
  • Sets meeting status to 'cancelled'
  • Sends cancellation notification to the booker
  • Does NOT delete the meeting record (preserves history)

check-no-shows

Detects meetings that were scheduled in the past but never marked as completed. Updates their status to no_show.

Input

No input required. Designed to be called on a schedule.

Logic

-- Conceptual query (actual implementation in TypeScript)
UPDATE meetings
SET status = 'no_show'
WHERE status = 'scheduled'
AND scheduled_for < now() - interval '30 minutes'
AND status != 'completed'
AND status != 'cancelled';

Side Effects

  • Updates status to 'no_show' for past-due meetings
  • Runs against both meetings and sales_meetings tables
  • Should be scheduled to run periodically (e.g., every hour)
Scheduling Check-No-Shows

This function is not automatically scheduled. You can set up a cron job via the Supabase dashboard (Database > Extensions > pg_cron) or call it from an external scheduler.