chore: migrate booking requested webhook trigger#27546
Merged
alishaz-polymath merged 38 commits intomainfrom Feb 19, 2026
Merged
chore: migrate booking requested webhook trigger#27546alishaz-polymath merged 38 commits intomainfrom
alishaz-polymath merged 38 commits intomainfrom
Conversation
Contributor
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
- Export IWebhookProducerService and getWebhookProducer from platform-libraries - Add WEBHOOK_PRODUCER token and useFactory provider in RegularBookingModule - Inject webhookProducer in RegularBookingService and pass to base class This follows the composition root pattern where only the NestJS module knows about getWebhookProducer(), and all consumers depend only on the IWebhookProducerService interface via constructor injection. Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
- Remove failing BOOKING_REQUESTED tests from fresh-booking.test.ts (4 tests) - Remove failing BOOKING_REQUESTED tests from reschedule.test.ts (2 tests) - Remove failing BOOKING_REQUESTED test from collective-scheduling.test.ts (1 test) - Replace WebhookTaskConsumer.test.ts with placeholder (constructor changed) - Create new webhook architecture test suite: - producer/WebhookTaskerProducerService.test.ts (14 tests) - consumer/WebhookTaskConsumer.test.ts (8 tests) - consumer/triggers/booking-requested.test.ts (8 tests) The new test suite is organized by trigger type for extensibility as more triggers are migrated to the producer/consumer pattern. Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
…cture) Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
Contributor
E2E results are ready! |
Contributor
Devin AI is addressing Cubic AI's review feedbackA Devin session has been created to address the issues identified by Cubic AI. |
This comment was marked as outdated.
This comment was marked as outdated.
6 tasks
Contributor
Devin AI is addressing Cubic AI's review feedbackA Devin session has been created to address the issues identified by Cubic AI. |
…bhook Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
This comment was marked as outdated.
This comment was marked as outdated.
joeauyeung
approved these changes
Feb 19, 2026
Contributor
joeauyeung
left a comment
There was a problem hiding this comment.
New implementation LGTM. Also tested this out and it's working as expected with the task running on Trigger and the webhook being sent.
volnei
approved these changes
Feb 19, 2026
Contributor
volnei
left a comment
There was a problem hiding this comment.
Nice architectural change! Loved it! I left a nit but could be done in follow up.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Migrates BOOKING_REQUESTED webhook delivery from the legacy inline path (
getWebhooks → sendPayload) to the producer–consumer pipeline (Trigger.dev or sync), so it uses the same flow as other booking triggers (e.g. BOOKING_CREATED, BOOKING_RESCHEDULED).Core Changes
handleBookingRequested.ts: Replaced inlinegetWebhooks→sendPayloadwithgetWebhookProducer().queueBookingRequestedWebhook(...). Missingevt.uidis handled withif/else+ innertry/catchso workflow scheduling is never skipped. AddedoAuthClientIdparameter for platform webhook subscriber filtering.RegularBookingService: When a booking requires confirmation (!isConfirmedByDefault), the BOOKING_REQUESTED webhook is queued viadeps.webhookProducer.queueBookingRequestedWebhook(...). Queued after booking update so the consumer fetches complete booking data (location, metadata, references).handlePaymentSuccess.ts: Now passesoAuthClientIdthrough tohandleBookingRequestedso platform webhooks fire for paid events requiring confirmation.webhookProduceris wired intoRegularBookingService.module.tsviawebhookProducerModuleLoader.WEBHOOK_PRODUCERinjection token inregular-booking.tokens.tsanduseFactory: () => getWebhookProducer()inRegularBookingModuleto bridge Cal.com DI into NestJS.RegularBookingService(API v2) now receives and forwards the producer via@Inject(WEBHOOK_PRODUCER).BookingWebhookDataFetcher: Upgraded from scaffold to full implementation — fetches booking viaBookingRepository.getBookingForCalEventBuilderFromUid(), buildsCalendarEventviaCalendarEventBuilder.fromBooking(), and returns complete data for webhook payload building. Now accepts platform metadata fields (platformClientId,platformRescheduleUrl, etc.).bookingWebhookTaskPayloadSchemawithplatformClientId,platformRescheduleUrl,platformCancelUrl,platformBookingUrl.IWebhookProducerService,getWebhookProducer,Tasker, andgetTaskerare now exported from@calcom/platform-libraries.small-1xmachine,concurrencyLimit: 25, retry with 30s–600s exponential backoff and OOM fallback tomedium-1x.webhook.e2e.ts): Added null guard forbody.payload.metadatato prevent crash when metadata is absent.BOOKING_REQUESTED Routes (2 entry points, both migrated)
RegularBookingService.ts— fires whenbooking.status === PENDING && !isDryRundeps.webhookProducer.queueBookingRequestedWebhook()via DIhandlePaymentSuccess.ts→handleBookingRequested.ts— fires when!isConfirmed && requiresConfirmationgetWebhookProducer().queueBookingRequestedWebhook()via container getterTest Changes
Removed legacy tests that asserted inline webhook delivery (
sendPayload/expectBookingRequestedWebhookToHaveBeenFired):fresh-booking.test.ts,reschedule.test.ts,collective-scheduling.test.tsAdded new test suites (49 total tests):
packages/features/webhooks/lib/__tests__/producer/WebhookTaskerProducerService.test.tspackages/features/webhooks/lib/__tests__/consumer/WebhookTaskConsumer.test.tspackages/features/webhooks/lib/__tests__/consumer/triggers/booking-requested.test.tspackages/features/bookings/lib/handleNewBooking/test/webhook-producer-booking-requested.test.tsIntegration test scenarios (8 total in
webhook-producer-booking-requested.test.ts):queueBookingRequestedWebhookcalledPayload content verification tests (11 new tests in
booking-requested.test.ts):Reusable test infrastructure:
packages/testing/src/lib/webhookProducer.ts—MockWebhookProducertype,createMockWebhookProducer(),expectWebhookProducerCalled(),expectWebhookProducerNotCalled(),resetMockWebhookProducer()for extendable use as more triggers migrate.Updates Since Last Revision
Code review findings (migration quality score: 8.5/10):
handleBookingRequestedusesgetWebhookProducer()container getter instead of DI injection (acceptable for standalone function; would need refactoring to class/service for proper DI)buildDTOswitch only handlesBOOKING_REQUESTED(expected for incremental migration; other triggers will be added as they migrate)Backward compatibility verified:
Webhook payload shape matches legacy format (v2021-10-20)
assignmentReasonuses legacy array format from bookingResponse labels normalized (
name→your_name,email→email_address)Default values preserved (price: 0, currency: "usd", length: null)
Fixes #XXXX
Fixes CAL-XXXX
Visual Demo (For contributors especially)
Video Demo (if applicable):
Loom
handleWebhookTrigger; no task appears in Trigger.dev.webhook.deliverrun appears in the Trigger.dev dashboard.Image Demo (if applicable):
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
ENABLE_ASYNC_TASKER=true,TRIGGER_SECRET_KEY,TRIGGER_API_URLset; worker running.webhook.delivertask run appears in the dashboard.TZ=UTC yarn test packages/features/webhooks/lib/__tests__ TZ=UTC yarn vitest run packages/features/bookings/lib/handleNewBooking/test/webhook-producer-booking-requested.test.tsHuman Review Checklist
handleBookingRequested.tsif/else + inner try/catch ensures workflows always run (lines 75-94)handleBookingRequested.tsusesgetWebhookProducer()directly, which may not be intercepted by the DI-injected mock inRegularBookingServiceassignmentReason,responsesnormalization, default values)booking-requested.test.tsadequately cover the payload shapes that were verified by the deleted testsChecklist