Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ New public and assistant bookings recheck selected external calendars before com

Google Meet and Teams event types can opt into `allow_phone_call`. Their booking page and widget then accept an optional `phone` value. A valid number selects a telephone appointment; leaving it empty preserves video. The booking stores its own location type so management pages, calendar retries, and paid confirmation do not generate a video link for a telephone appointment. Event duplication preserves the setting.

The `phone_outbound` location type ("we'll call you") is the outbound counterpart: the host calls the attendee. The event type carries no number (`validateLocation` requires none); the booking page and widget show a required `phone` field instead, and `CreateBooking` refuses a missing or invalid number with HTTP 400 rather than falling back to another meeting type. A valid number is stored exactly like the `allow_phone_call` path (`bookings.location_type = "phone"`, `location_value = "tel:<number>"`), so calendar events, emails, webhooks and the manage page treat it as an ordinary telephone appointment. The manage page needs no field of its own: a reschedule keeps the booking's stored number. The shared booking core (`createBookingForSlug`) refuses these event types, because the assistant and MCP cannot collect the number, and the booking page and widget hide the assistant for them.

`internal/booking/service.go` (transactions) + `internal/handler/booking_handler.go`
(HTTP + async side effects).

Expand Down
5 changes: 4 additions & 1 deletion frontend/src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,7 @@
"googleMeet": "Google Meet",
"livekit": "Calnode Video (LiveKit)",
"phone": "Phone call",
"phoneOutbound": "We call the attendee",
"link": "Video link",
"inPerson": "In person"
},
Expand All @@ -1651,6 +1652,7 @@
"meetLink": "Meet link",
"teamsLink": "Teams link",
"phone": "Phone number",
"attendeePhone": "Attendee's phone number",
"address": "Address",
"details": "Details",
"videoRoom": "Video room"
Expand Down Expand Up @@ -1682,7 +1684,8 @@
"notConfigured": "Zoom isn't set up for this workspace (an admin can add it in Settings → Zoom),",
"pasteFallback": "or paste a Zoom link below to use for every booking."
},
"livekit": "A secure video room is created automatically for each booking — no link needed. Guests join in the browser. (Set up the server in Settings → Video.)"
"livekit": "A secure video room is created automatically for each booking — no link needed. Guests join in the browser. (Set up the server in Settings → Video.)",
"phoneOutbound": "The booking form asks the attendee for their phone number (required). You call them at the booked time; the number is the booking's location, so it's in the calendar event and emails as a tap-to-call link."
}
},
"invite": {
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/lib/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,7 @@
"googleMeet": "Google Meet",
"livekit": "Calnode Video (LiveKit)",
"phone": "Appel téléphonique",
"phoneOutbound": "Nous appelons le participant",
"link": "Lien vidéo",
"inPerson": "En personne"
},
Expand All @@ -1651,6 +1652,7 @@
"meetLink": "Lien Meet",
"teamsLink": "Lien Teams",
"phone": "Numéro de téléphone",
"attendeePhone": "Numéro de téléphone du participant",
"address": "Adresse",
"details": "Détails",
"videoRoom": "Salle vidéo"
Expand Down Expand Up @@ -1682,7 +1684,8 @@
"notConfigured": "Zoom n'est pas configuré pour cet espace de travail (un administrateur peut l'ajouter dans Paramètres → Zoom),",
"pasteFallback": "ou collez un lien Zoom ci-dessous à utiliser pour chaque réservation."
},
"livekit": "Une salle vidéo sécurisée est créée automatiquement pour chaque réservation — aucun lien n'est nécessaire. Les invités rejoignent dans le navigateur. (Configurez le serveur dans Paramètres → Vidéo.)"
"livekit": "Une salle vidéo sécurisée est créée automatiquement pour chaque réservation — aucun lien n'est nécessaire. Les invités rejoignent dans le navigateur. (Configurez le serveur dans Paramètres → Vidéo.)",
"phoneOutbound": "Le formulaire de réservation demande au participant son numéro de téléphone (obligatoire). Vous l'appelez à l'heure réservée ; le numéro est le lieu de la réservation et figure dans l'événement d'agenda et les e-mails sous forme de lien cliquable."
}
},
"invite": {
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/routes/event-types/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
{ value: 'google_meet', label: $t('eventTypeEditor.location.types.googleMeet') },
{ value: 'livekit', label: $t('eventTypeEditor.location.types.livekit') },
{ value: 'phone', label: $t('eventTypeEditor.location.types.phone') },
{ value: 'phone_outbound', label: $t('eventTypeEditor.location.types.phoneOutbound') },
{ value: 'link', label: $t('eventTypeEditor.location.types.link') },
{ value: 'in_person', label: $t('eventTypeEditor.location.types.inPerson') },
]);
Expand Down Expand Up @@ -399,7 +400,8 @@
invite_delivery: form.invite_delivery,
allow_phone_call: allowPhoneCall,
location_type: form.location_type,
location_value: form.location_value.trim() || null,
// "We'll call you" has no host-side value: the attendee gives their number at booking.
location_value: form.location_type === 'phone_outbound' ? null : form.location_value.trim() || null,
buffer_before_minutes: Number(form.buffer_before_minutes),
buffer_after_minutes: Number(form.buffer_after_minutes),
min_notice_minutes: Number(form.min_notice_minutes),
Expand Down Expand Up @@ -763,6 +765,11 @@
</p>
{/if}
<Input id="et-loc-val" bind:value={form.location_value} placeholder={zoomAutoGen ? $t('eventTypeEditor.location.placeholder.optionalFallback') : $t('eventTypeEditor.location.placeholder.pasteZoom')} />
{:else if form.location_type === 'phone_outbound'}
<Label>{$t('eventTypeEditor.location.labels.attendeePhone')}</Label>
<p class="rounded-md border border-green-600/20 bg-green-50 px-3 py-2 text-sm text-green-700">
{$t('eventTypeEditor.location.hint.phoneOutbound')}
</p>
{:else if form.location_type === 'livekit'}
<Label>{$t('eventTypeEditor.location.labels.videoRoom')}</Label>
<p class="rounded-md border border-green-600/20 bg-green-50 px-3 py-2 text-sm text-green-700">
Expand Down
91 changes: 91 additions & 0 deletions internal/db/migrations/00073_phone_outbound_location.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
-- +goose NO TRANSACTION
-- 'phone_outbound' location type: the host calls the attendee. The booking form asks
-- the attendee for a required phone number, and the booking is stored exactly like the
-- allow_phone_call path (bookings.location_type = 'phone', location_value = 'tel:<number>'),
-- so tap-to-call, the calendar event location and the emails work unchanged. Only the
-- event type carries the new value; bookings.location_type has no CHECK.
--
-- Widening the location_type CHECK is the 00042 table rebuild: NO TRANSACTION +
-- foreign_keys=OFF, because a DROP TABLE with foreign keys enabled would cascade-delete
-- the child rows (bookings, hosts, questions, reminders, availability rules), and PRAGMA
-- foreign_keys is a no-op inside a transaction. Columns are named explicitly, in the
-- table's current order (the ones added by ALTER after 00042 sit at the end).

-- +goose Up
PRAGMA foreign_keys=OFF;

CREATE TABLE event_types_new (
id TEXT PRIMARY KEY,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
team_id TEXT REFERENCES teams(id) ON DELETE SET NULL,
slug TEXT NOT NULL UNIQUE,
name TEXT NOT NULL,
description TEXT,
duration_minutes INTEGER NOT NULL,
slot_interval_minutes INTEGER NOT NULL DEFAULT 30,
location_type TEXT NOT NULL DEFAULT 'link'
CHECK (location_type IN ('zoom','google_meet','teams','custom_video','phone','in_person','link','livekit','phone_outbound')),
location_value TEXT,
routing_mode TEXT NOT NULL DEFAULT 'fixed'
CHECK (routing_mode IN ('fixed', 'round_robin', 'collective', 'priority')),
buffer_before_minutes INTEGER NOT NULL DEFAULT 0,
buffer_after_minutes INTEGER NOT NULL DEFAULT 0,
min_notice_minutes INTEGER NOT NULL DEFAULT 0,
max_future_days INTEGER NOT NULL DEFAULT 60,
seat_limit INTEGER NOT NULL DEFAULT 1,
is_active INTEGER NOT NULL DEFAULT 1,
is_public INTEGER NOT NULL DEFAULT 1,
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
msg_confirmation TEXT,
msg_cancellation TEXT,
msg_reschedule TEXT,
msg_reminder TEXT,
max_active_bookings INTEGER NOT NULL DEFAULT 1,
rr_strategy TEXT NOT NULL DEFAULT 'even'
CHECK (rr_strategy IN ('even', 'soonest', 'priority')),
subj_confirmation TEXT,
subj_cancellation TEXT,
subj_reschedule TEXT,
subj_reminder TEXT,
price_cents INTEGER NOT NULL DEFAULT 0,
currency TEXT NOT NULL DEFAULT 'usd',
archived_at TEXT,
msg_greeting TEXT,
show_taken_slots INTEGER NOT NULL DEFAULT 0,
allow_phone_call INTEGER NOT NULL DEFAULT 0,
display_order INTEGER NOT NULL DEFAULT 0,
invite_delivery TEXT NOT NULL DEFAULT 'calendar'
CHECK (invite_delivery IN ('calendar', 'calnode', 'none'))
);

INSERT INTO event_types_new (
id, user_id, team_id, slug, name, description, duration_minutes, slot_interval_minutes,
location_type, location_value, routing_mode, buffer_before_minutes, buffer_after_minutes,
min_notice_minutes, max_future_days, seat_limit, is_active, is_public, created_at,
msg_confirmation, msg_cancellation, msg_reschedule, msg_reminder, max_active_bookings,
rr_strategy, subj_confirmation, subj_cancellation, subj_reschedule, subj_reminder,
price_cents, currency, archived_at, msg_greeting, show_taken_slots, allow_phone_call,
display_order, invite_delivery)
SELECT
id, user_id, team_id, slug, name, description, duration_minutes, slot_interval_minutes,
location_type, location_value, routing_mode, buffer_before_minutes, buffer_after_minutes,
min_notice_minutes, max_future_days, seat_limit, is_active, is_public, created_at,
msg_confirmation, msg_cancellation, msg_reschedule, msg_reminder, max_active_bookings,
rr_strategy, subj_confirmation, subj_cancellation, subj_reschedule, subj_reminder,
price_cents, currency, archived_at, msg_greeting, show_taken_slots, allow_phone_call,
display_order, invite_delivery
FROM event_types;

DROP TABLE event_types;
ALTER TABLE event_types_new RENAME TO event_types;

PRAGMA foreign_keys=ON;

-- +goose Down
-- The widened CHECK stays (as in 00042 and 00071). An older binary does not know
-- 'phone_outbound', so those event types become 'phone' with no host number and are
-- deactivated: still a phone call, never silently a video meeting, and not bookable
-- until the operator enters a number (validateLocation requires one for 'phone').
-- Existing bookings are unaffected: they were stored as 'phone' + 'tel:<number>'.
UPDATE event_types SET location_type = 'phone', location_value = NULL, is_active = 0
WHERE location_type = 'phone_outbound';
15 changes: 12 additions & 3 deletions internal/handler/book.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ type bookQuestion struct {
}

type bookPageData struct {
PhoneChoice bool
PhoneChoice bool
// PhoneRequired is the "we'll call you" location: the same phone field, but required,
// because the attendee's number is the only way the host can reach them.
PhoneRequired bool
AccentColor string
AccentForeground string
Slug string
Expand Down Expand Up @@ -311,6 +314,8 @@ func locationLabel(locType, locValue string, loc *i18n.Locale) string {
return loc.T("location_video_meeting")
case "phone":
return loc.T("location_phone")
case phoneOutboundLocation:
return loc.T("location_phone_outbound")
case "in_person":
if locValue != "" {
return locValue
Expand Down Expand Up @@ -420,6 +425,7 @@ func (h *Handler) PublicEventType(w http.ResponseWriter, r *http.Request) {
"duration_label": durationLabel(durMins, loc),
"location_type": locType,
"allow_phone_call": allowPhoneCall && onlineMeetingLocation(locType),
"phone_required": locType == phoneOutboundLocation,
"booking_accent": accentColor,
"booking_accent_foreground": accentForeground(accentColor),
"location_label": locationLabel(locType, locValue, loc),
Expand All @@ -430,7 +436,9 @@ func (h *Handler) PublicEventType(w http.ResponseWriter, r *http.Request) {
// would leave it rebuilding a plural-aware label the server already has (#20).
"min_notice_minutes": minNotice,
"min_notice_label": noticeLabel(minNotice, loc),
"assistant_enabled": h.getLLM() != nil,
// The assistant cannot collect the attendee's number, so it is off for "we'll call
// you" event types rather than offered and then refused at the last step.
"assistant_enabled": h.getLLM() != nil && locType != phoneOutboundLocation,
"assistant_greeting": assistantGreeting(msgGreeting, loc),
"price_cents": priceCents,
"currency": currency,
Expand Down Expand Up @@ -537,6 +545,7 @@ func (h *Handler) BookPage(w http.ResponseWriter, r *http.Request) {

data := bookPageData{
PhoneChoice: allowPhoneCall && onlineMeetingLocation(locType),
PhoneRequired: locType == phoneOutboundLocation,
AccentColor: accentColor,
AccentForeground: accentForeground(accentColor),
Slug: slug,
Expand All @@ -561,7 +570,7 @@ func (h *Handler) BookPage(w http.ResponseWriter, r *http.Request) {
MaxFutureDays: maxDays,
Questions: questions,
BookingLogicJS: template.JS(bookingLogicJS), // #nosec G203 -- our own bundled JS source constant, not user input
AssistantEnabled: h.getLLM() != nil,
AssistantEnabled: h.getLLM() != nil && locType != phoneOutboundLocation,
AssistantDisclosure: loc.T("assistant_disclosure"),
AssistantGreeting: assistantGreeting(msgGreeting, loc),
CSSVersion: bookingCSSVersion,
Expand Down
1 change: 1 addition & 0 deletions internal/handler/book_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func TestBookPage_locationLabels(t *testing.T) {
{"google_meet", "https://meet.google.com/abc-defg-hij", "Google Meet"},
{"teams", "https://teams.microsoft.com/l/meetup-join/x", "Microsoft Teams"},
{"phone", "+1 555 123 4567", "Phone Call"},
{"phone_outbound", "", "Phone Call (we"}, // the attendee gives the number at booking
{"in_person", "123 Main St", "123 Main St"},
{"in_person", "", "In Person"}, // in-person value stays optional
{"custom_video", "https://example.com/room", "Video Call"},
Expand Down
33 changes: 32 additions & 1 deletion internal/handler/booking_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ func onlineMeetingLocation(locType string) bool {
return locType == "google_meet" || locType == "teams"
}

// phoneOutboundLocation is the event-type location where the host calls the attendee.
// It exists only on the event type: every booking on it requires the attendee's number
// and is stored as location_type "phone" with "tel:<number>", the same shape as the
// allow_phone_call path, so everything downstream of the booking treats it as a phone call.
const phoneOutboundLocation = "phone_outbound"

// providerMintsPlatform reports whether a connected calendar provider can natively
// auto-generate the meeting link for the given online location type: Google Meet
// only from a Google calendar, Microsoft Teams only from a Microsoft calendar. When
Expand Down Expand Up @@ -223,6 +229,9 @@ func (h *Handler) validateLocation(ctx context.Context, ownerID, locType string,
return fmt.Errorf("enter a valid phone number")
}
return nil
case phoneOutboundLocation:
// The attendee supplies the number at booking time; the event type needs none.
return nil
default: // in_person and anything else: no value requirement
return nil
}
Expand Down Expand Up @@ -481,6 +490,11 @@ var errNoHostAvailable = errors.New("no active host can take this booking")
// only be booked through the Stripe Checkout flow on the booking page (agents can't pay).
var errPaymentRequired = errors.New("this event requires payment; please book on the booking page")

// errPhoneRequired is returned by the shared booking core for "we'll call you" event types:
// the assistant and MCP have no way to collect the attendee's number, and booking without
// one would leave the host with nobody to call.
var errPhoneRequired = errors.New("this event requires the attendee's phone number; please book on the booking page")

// bookableEventType is the event_types fields the booking-creation and slot-computation
// paths need. loadBookableEventType is their one shared query — createBookingForSlug,
// CreateBooking, and computeSlots each used to hand-write their own column subset, which
Expand Down Expand Up @@ -568,6 +582,9 @@ func (h *Handler) createBookingForSlug(ctx context.Context, slug string, startAt
if et.PriceCents > 0 {
return nil, errPaymentRequired
}
if et.LocationType == phoneOutboundLocation {
return nil, errPhoneRequired
}
// The attendee's own locale (set by the assistant from the page's resolved language;
// empty for MCP callers, which i18n.Get turns into nil → English).
answers, err := h.validateAnswersCore(ctx, et.ID, rawAnswers, i18n.Get(organizer.Locale))
Expand Down Expand Up @@ -899,7 +916,21 @@ func (h *Handler) CreateBooking(w http.ResponseWriter, r *http.Request) {
// Resolve candidate hosts by routing mode: rotation hosts for round-robin,
// required hosts otherwise. Archived hosts are excluded by resolveEventTypeHosts.
req.Phone = strings.TrimSpace(req.Phone)
if req.Phone != "" {
switch {
case et.LocationType == phoneOutboundLocation:
// The host calls the attendee, so the number is required. A missing or invalid one
// is refused, never downgraded to another meeting type.
if req.Phone == "" {
h.writeError(w, http.StatusBadRequest, loc.T("err_phone_required"))
return
}
if len(req.Phone) > 40 || !validPhone(req.Phone) {
h.writeError(w, http.StatusBadRequest, "invalid telephone number")
return
}
et.LocationType = "phone"
locValue = "tel:" + req.Phone
case req.Phone != "":
if !et.AllowPhoneCall || !onlineMeetingLocation(et.LocationType) || len(req.Phone) > 40 || !validPhone(req.Phone) {
h.writeError(w, http.StatusBadRequest, "invalid telephone number")
return
Expand Down
Loading
Loading