Skip to content

Conversation

@sean-brydon
Copy link
Member

@sean-brydon sean-brydon commented Jan 26, 2026

What does this PR do?

Implements rescheduling workflows as a background job using the existing email/SMS tasker pattern as inspiration. This moves workflow scheduling for reschedule events to trigger.dev for async execution, reducing latency in the booking response.

The implementation follows the same 3-layer architecture used by BookingEmailAndSmsTasker:

  • WorkflowTasker - Main orchestrator that dispatches to async or sync tasker
  • WorkflowTriggerDevTasker - Async implementation via trigger.dev
  • WorkflowSyncTasker - Sync fallback implementation
  • WorkflowTaskService - Contains the actual business logic (calls scheduleWorkflowReminders)

Key changes:

  • Added workflow-tasker feature flag to AppFlags
  • Created DI modules and tokens for workflow tasker components
  • Added getBookingForWorkflowTasker repository method to fetch booking data with required relations
  • Integrated WorkflowTasker into RegularBookingService for reschedule events
  • Created trigger.dev task workflow.schedule.reschedule
  • Added comprehensive unit tests (27 tests across 4 test files)

The feature is gated behind the workflow-tasker feature flag and only triggers for organizations that have the flag enabled.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - no docs changes needed.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Enable the workflow-tasker feature flag for a test organization
  2. Create a booking with a workflow that triggers on RESCHEDULE_EVENT
  3. Reschedule the booking
  4. Verify the workflow is scheduled via trigger.dev (check trigger.dev dashboard)
  5. Verify the workflow executes correctly (email/SMS sent)

Environment variables needed:

  • TRIGGER_API_KEY and TRIGGER_API_URL for trigger.dev integration
  • Feature flag workflow-tasker must be enabled for the org

Checklist for Human Review

  • Verify ExtendedCalendarEvent construction in WorkflowTaskService matches what scheduleWorkflowReminders expects
  • Check if task registration in packages/features/tasker/tasks/index.ts is needed for trigger.dev
  • Review workflow filtering logic - currently includes RESCHEDULE_EVENT, BEFORE_EVENT, and AFTER_EVENT triggers
  • Review indentation changes in RegularBookingService.ts, BookingRepository.ts, and config.ts - some appear to be formatting-only changes that may need cleanup

Link to Devin run: https://app.devin.ai/sessions/43d17dbab131473883f6421be9ebc5fd
Requested by: @sean-brydon

This PR implements rescheduling workflows as a background job using the
existing email/SMS tasker pattern as inspiration. The implementation
follows the same 3-layer architecture:

- WorkflowTasker: Main orchestrator that dispatches to async or sync tasker
- WorkflowTriggerDevTasker: Async implementation via trigger.dev
- WorkflowSyncTasker: Sync fallback implementation
- WorkflowTaskService: Contains the actual business logic

Key changes:
- Added workflow-tasker feature flag to AppFlags
- Created WorkflowTasker DI modules and tokens
- Added getBookingForWorkflowTasker repository method
- Integrated WorkflowTasker into RegularBookingService for reschedule events
- Created trigger.dev task for scheduling reschedule workflows

Co-Authored-By: sean@cal.com <Sean@brydon.io>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Added comprehensive unit tests for:
- WorkflowTaskService: Tests for scheduling reschedule workflows, error handling, workflow filtering
- WorkflowTasker: Tests for dispatch behavior and error handling
- WorkflowSyncTasker: Tests for sync execution and runId generation
- WorkflowTriggerDevTasker: Tests for trigger.dev integration

All 27 tests pass with good coverage of the new workflow tasker functionality.

Co-Authored-By: sean@cal.com <Sean@brydon.io>
Co-Authored-By: sean@cal.com <Sean@brydon.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants