Skip to content

feat: add cancelledBy and rescheduledBy parameters to workflow links #22438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 28, 2025

Conversation

joeauyeung
Copy link
Contributor

@joeauyeung joeauyeung commented Jul 11, 2025

Adds the cancelledBy and rescheduledBy params to the cancel and reschedule links that are in workflow messages.


Summary by cubic

Added cancelledBy and rescheduledBy parameters to workflow cancel and reschedule links, using the assignee's email for user and team workflows.

  • New Features
    • Updated email and SMS reminder links to include the assignee's email in cancel and reschedule actions.
    • Added logic to select the correct email for user or team workflows, defaulting to team owner for teams.

- Extended workflow reminder selection to include user and team data
- Added getWorkflowAssigneeEmail helper function to resolve assignee email
- Updated email and SMS workflow templates to include assignee in cancel/reschedule links
- For user workflows, uses user email; for team workflows, uses team owner email
- Maintains backward compatibility when assignee data is unavailable

Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
Copy link

vercel bot commented Jul 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Jul 28, 2025 4:26pm
cal-eu ⬜️ Ignored (Inspect) Visit Preview Jul 28, 2025 4:26pm

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'.
  • 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

@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Jul 11, 2025
Copy link

delve-auditor bot commented Jul 11, 2025

No security or compliance issues detected. Reviewed everything up to 5dbca7e.

Security Overview
  • 🔎 Scanned files: 5 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

…parameters

- Updated getWorkflowRecipientEmail to determine recipient based on workflow action type
- EMAIL_ADDRESS uses sendTo email, EMAIL_HOST uses organizer, EMAIL_ATTENDEE uses attendee
- SMS_ATTENDEE/WHATSAPP_ATTENDEE use attendee email for cancelledBy/rescheduledBy params
- Maintains backward compatibility when recipient data unavailable

Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
…meters

- Updated emailReminderManager to include recipient email in cancel/reschedule links
- Added getEmailWorkflowRecipientEmail function for proper recipient determination
- Removed changes from deprecated scheduleEmailReminders.ts
- SMS_ATTENDEE correctly uses attendee email like EMAIL_ATTENDEE

Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
@vercel vercel bot temporarily deployed to Preview – api July 14, 2025 20:17 Inactive
Copy link
Contributor

coderabbitai bot commented Jul 14, 2025

Walkthrough

The changes introduce a new helper function, getWorkflowRecipientEmail, to centralize the logic for determining the recipient email based on workflow action types and available email addresses. This function is now used in various modules responsible for scheduling and composing email and SMS reminders. The recipient email, as determined by this helper, is appended as a URL-encoded query parameter (cancelledBy or rescheduledBy) to the cancel and reschedule links included in both email and SMS reminders. The type definition for PartialWorkflowStep was reformatted for clarity, and no changes were made to exported entity signatures except for the addition of the new helper function.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/features/ee/workflows/api/scheduleEmailReminders.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-playwright".

(The package "eslint-plugin-playwright" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-playwright@latest --save-dev

The plugin "eslint-plugin-playwright" was referenced from the config file in ".eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

packages/features/ee/workflows/api/scheduleSMSReminders.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-playwright".

(The package "eslint-plugin-playwright" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-playwright@latest --save-dev

The plugin "eslint-plugin-playwright" was referenced from the config file in ".eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

packages/features/ee/workflows/lib/getWorkflowReminders.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-playwright".

(The package "eslint-plugin-playwright" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-playwright@latest --save-dev

The plugin "eslint-plugin-playwright" was referenced from the config file in ".eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 2 others

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5756438 and 5dbca7e.

📒 Files selected for processing (5)
  • packages/features/ee/workflows/api/scheduleEmailReminders.ts (3 hunks)
  • packages/features/ee/workflows/api/scheduleSMSReminders.ts (2 hunks)
  • packages/features/ee/workflows/lib/getWorkflowReminders.ts (2 hunks)
  • packages/features/ee/workflows/lib/reminders/emailReminderManager.ts (3 hunks)
  • packages/features/ee/workflows/lib/reminders/utils.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: alishaz-polymath
PR: calcom/cal.com#22304
File: packages/prisma/schema.prisma:1068-1071
Timestamp: 2025-07-16T05:10:22.863Z
Learning: In PR #22304 for Cal.com private link expiration features, the `maxUsageCount` field was intentionally set to default to 1 (non-nullable) as a breaking change, making all existing private links single-use after migration. This was a deliberate design decision by alishaz-polymath.
🧬 Code Graph Analysis (4)
packages/features/ee/workflows/api/scheduleSMSReminders.ts (1)
packages/features/ee/workflows/lib/getWorkflowReminders.ts (1)
  • getWorkflowRecipientEmail (224-254)
packages/features/ee/workflows/api/scheduleEmailReminders.ts (1)
packages/features/ee/workflows/lib/getWorkflowReminders.ts (1)
  • getWorkflowRecipientEmail (224-254)
packages/features/ee/workflows/lib/reminders/emailReminderManager.ts (1)
packages/features/ee/workflows/lib/getWorkflowReminders.ts (1)
  • getWorkflowRecipientEmail (224-254)
packages/features/ee/workflows/lib/getWorkflowReminders.ts (1)
packages/features/ee/workflows/lib/types.ts (1)
  • WorkflowStep (19-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
🔇 Additional comments (14)
packages/features/ee/workflows/lib/reminders/utils.ts (3)

7-7: Import addition looks good.

The import of getWorkflowRecipientEmail is correctly added to support the new functionality.


44-47: Recipient email determination is well implemented.

The call to getWorkflowRecipientEmail with the action and attendee email follows the established pattern and centralizes the recipient email logic.


50-55: URL construction with recipient email is properly handled.

The conditional addition of cancelledBy and rescheduledBy query parameters to the URLs is correctly implemented. The recipient email is properly URL-encoded and only added when it exists.

packages/features/ee/workflows/api/scheduleSMSReminders.ts (3)

19-19: Import addition is appropriate.

The import of getWorkflowRecipientEmail is correctly added to support the new recipient email functionality.


110-114: Recipient email determination is well implemented.

The call to getWorkflowRecipientEmail with the workflow step action, attendee email, and organizer email follows the established pattern and provides the necessary context for determining the appropriate recipient.


118-123: URL construction with recipient parameters is correct.

The conditional addition of cancelledBy and rescheduledBy query parameters to the cancel and reschedule URLs is properly implemented. The recipient email is used when available, maintaining consistency with the other workflow files.

packages/features/ee/workflows/api/scheduleEmailReminders.ts (3)

24-24: Import addition is appropriate.

The import of getWorkflowRecipientEmail is correctly added to support the new recipient email functionality.


191-196: Recipient email determination is comprehensive.

The call to getWorkflowRecipientEmail with all relevant parameters (action, attendee email, organizer email, and sendToEmail) provides complete context for determining the appropriate recipient.


210-215: URL construction with proper encoding is excellent.

The conditional addition of cancelledBy and rescheduledBy query parameters to the URLs is correctly implemented with proper encodeURIComponent usage to handle special characters in email addresses.

packages/features/ee/workflows/lib/reminders/emailReminderManager.ts (3)

22-22: Import addition is appropriate.

The import of getWorkflowRecipientEmail is correctly added to support the new recipient email functionality.


143-148: Recipient email determination is well implemented.

The call to getWorkflowRecipientEmail with the action, attendee email, organizer email, and first sendTo email provides comprehensive context for determining the appropriate recipient.


163-169: URL construction with proper encoding is excellent.

The conditional addition of cancelledBy and rescheduledBy query parameters to the URLs is correctly implemented with proper encodeURIComponent usage and follows the established pattern across the codebase.

packages/features/ee/workflows/lib/getWorkflowReminders.ts (2)

6-13: Type reformatting improves readability.

The reformatting of the PartialWorkflowStep type definition enhances code clarity without changing its functionality.


224-254: Helper function is well-designed and comprehensive.

The getWorkflowRecipientEmail function effectively centralizes recipient email determination logic. The switch statement covers all relevant action types and returns the appropriate email address or null as expected. The parameter types are well-defined and the function signature matches the usage patterns across the codebase.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vercel vercel bot temporarily deployed to Preview – api July 16, 2025 18:09 Inactive
@vercel vercel bot temporarily deployed to Preview – cal July 16, 2025 18:09 Inactive
@joeauyeung joeauyeung marked this pull request as ready for review July 17, 2025 14:46
@graphite-app graphite-app bot requested a review from a team July 17, 2025 14:46
@dosubot dosubot bot added workflows area: workflows, automations ✨ feature New feature or request labels Jul 17, 2025
Copy link

graphite-app bot commented Jul 17, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (07/17/25)

1 reviewer was added to this PR based on Keith Williams's automation.

attendeeEmail?: string;
sendToEmail?: string | null;
}): string | null {
// const action = reminder.workflowStep.action;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// const action = reminder.workflowStep.action;

Comment on lines +231 to +233
organizerEmail?: string;
attendeeEmail?: string;
sendToEmail?: string | null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make the all required and explicitly accept null for props that aren't available/applicable in a particular case.

It avoids the situation when we accidentally forget to pass a prop and it was applicable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we could have context aware wrappers that call this method. These wrapper would have fields as required. Client code won't call this method directly, it would call a wrapper of it.

e.g. getWorkflowRecipientEmailForSmsReminder would have attendeeEmail as the only field and it would be required.

Comment on lines +112 to +113
attendeeEmail: reminder.booking.attendees[0].email,
organizerEmail: reminder.booking.user?.email,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is time to have a BookingFactory/BookingService to getAttendeeEmail and getOrganizerEmail.

May be in some follow-up

@hariombalhara
Copy link
Member

hariombalhara commented Jul 23, 2025

Didn't test(don't have enough exprience with workflows) but codewise LGTM mostly !! nothing blocking

Requesting @CarinaWolli for review in terms of the logic to determine receipient is correct or not.

Copy link
Member

@CarinaWolli CarinaWolli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@CarinaWolli CarinaWolli enabled auto-merge (squash) July 23, 2025 11:23
@CarinaWolli CarinaWolli merged commit 6c93647 into main Jul 28, 2025
37 of 38 checks passed
@CarinaWolli CarinaWolli deleted the devin/workflow-assignee-parameters-1752272653 branch July 28, 2025 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ✨ feature New feature or request ready-for-e2e workflows area: workflows, automations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants