-
Notifications
You must be signed in to change notification settings - Fork 11.7k
feat: form submitted workflow triggers #1 #23704
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
Changes from 190 commits
Commits
Show all changes
239 commits
Select commit
Hold shift + click to select a range
b0d048a
feat: add 5 new workflow triggers for booking events
devin-ai-integration[bot] a327a38
fix: type check, remove as any
Amit91848 a2fef5f
feat: add workflow trigger for BOOKING_REQUESTED in handleNewBooking.ts
devin-ai-integration[bot] 1a86cb0
Merge branch 'devin/1755107037-add-workflow-triggers' of https://git-…
devin-ai-integration[bot] b161f8f
fix: resolve type errors in workflow trigger implementations
devin-ai-integration[bot] 3f4f743
feat: add workflow test configurations for new booking triggers
devin-ai-integration[bot] a4e3015
fix: add missing mockSuccessfulVideoMeetingCreation import to confirm…
devin-ai-integration[bot] dd791ff
add new triggers
94ebb23
Merge branch 'main' into devin/1755107037-add-workflow-triggers
Amit91848 1062d1a
refactor: improve _scheduleWorkflowReminders readability and add miss…
devin-ai-integration[bot] 9025eaa
Merge branch 'devin/1755107037-add-workflow-triggers' of https://git-…
devin-ai-integration[bot] 190eb0b
only show customt emplate for form triggers
3cd2d7e
filter outside scheduleWorkflowReminder
Amit91848 a39ccf4
fix type check
Amit91848 265f852
chore: add more tests
Amit91848 7642992
test: add comprehensive unit tests for handleMarkNoShow with webhook …
devin-ai-integration[bot] 53fe81e
Revert "test: add comprehensive unit tests for handleMarkNoShow with …
Amit91848 32910d8
fix: add new workflow triggers to api/v2
Amit91848 e037154
update swagger docs
Amit91848 2a187ea
fix: e2e
Amit91848 d0e0fee
fix type check
Amit91848 505ff8e
fix tests, add test for before after events
Amit91848 37c78b0
fix unit tests
Amit91848 b945b88
Merge branch 'main' into devin/1755107037-add-workflow-triggers
Amit91848 ac54670
revert confirm.handler.test
Amit91848 32a26e5
Merge branch 'devin/1755107037-add-workflow-triggers' of https://gith…
Amit91848 0f0e2fa
fix: unit tests
Amit91848 75d1235
dummy form variables
edcbca5
add routing forms to active on dropdown
2feb0ea
add migration file
1278b63
Ui fixes for variables dropdown
7825c4a
remove other translation keys
2168142
Merge branch 'fix/add-variables-dropdown' into feat/routing-form-work…
8d58550
review fixes
Amit91848 2ea8c1e
allow routing forms for activeOn
61d231a
use repository function to get routing forms
985b777
remove unnecessary code
c9ae4f5
adjust logic in update handler
6ff24a9
add triggers to api v2
99e2ac7
remvoe unused file
87f8857
Merge branch 'main' of https://github.com/calcom/cal.com into devin/1…
Amit91848 d27e45f
rename to getAcitveOnOptions handler
59a4c9c
remove routingFormOptions handler
fdc18cb
clean up getActiveOnOptions
a9ab403
refactor WorkflowService
Amit91848 4874a6f
remove logs
Amit91848 24dd93f
remove unused
Amit91848 4429ced
Merge branch 'devin/1755107037-add-workflow-triggers' of https://gith…
Amit91848 3b5e530
fix: type check
Amit91848 c13dcbe
fix: missed before after events for recurring
Amit91848 e2768cc
fix: calendarEvent handleMarkNoShow
Amit91848 b957355
fix error message
Amit91848 3672d04
Merge branch 'main' into feat/routing-form-workflow-triggers
57a7d9b
don't query disabled routing forms
72422b0
merge devin/1755107037-add-workflow-triggers
a659afc
create tasker function
a35e1ec
add tasker code
1b9962f
move isFormTrigger function
6be759d
Merge branch 'main' into devin/1755107037-add-workflow-triggers
CarinaWolli 4fdd9b6
Merge branch 'main' into feat/routing-form-workflow-triggers
9c6b365
small adjustments + todo comments
078df04
remove email to host action for form triggers
97c5572
throw trpc error if email to host is added as step
805f8be
Merge branch 'main' of https://github.com/calcom/cal.com into devin/1…
Amit91848 1ab36bd
fix dialog on how to use form responses as variables
ab1a14c
remove add variable dropdown for form triggers
200f3fa
remove form workfows in event workflows tab
239f3db
improvements for workflow logic on form submission
952cf34
review fixes
Amit91848 b57f4a4
base setup for seperate schedule functions (evt and form)
026762f
add missing BOOKING_PAID workflow trigger
Amit91848 737b643
fix pathname
Amit91848 19a9aaf
fix: test for BOOKING_REQUESTED
Amit91848 50a994c
fix activeOn ids
024c888
pass hideBranding and smsReminderNumber
42fe72c
adjustments to reminderScheduler
a702b71
create empty scheduelForForm functions
0dc6b08
pass locale and timezone with form user
672c1d7
pass formData instead of responses
bc4e630
pass timeFormat and locale
d7b0117
reusable function for email sending and reminder creation
e14adee
implement scheduleEmailReminderForForm
4d6356c
remove added editor field from merge conflict
1c03eed
don't support cal.ai action with form triggers
1603f44
throw bad request if form trigger and cal.ai is combined
8362a7f
add tests for scheduleFormWorkflows
c8ccd40
add form submission tests
f82dfd6
remove form response varibe info
3494c61
clean up workflow actions
557f0f4
fixes for getting template options
6b4aaf7
pass triggerType to getAllWorkflows
23751d0
move reusable logic to scheduleSMSReminder
e1a234f
add formdata to param type
a5c3be2
type fixes for text reminder managers
a69f86d
implement scheduleSMSReminderForForm
4e48e9c
fix import
4c65847
fix isAuthorizedToAddActiveOnIds
82e7d41
disble whatsapp action
cfe2068
implement triggerFormSubmittedNoEventWorkflow
6ba946b
code clean up
4c557e7
Merge branch 'devin/1755107037-add-workflow-triggers' into feat/routi…
fe627db
Merge branch 'main' into feat/routing-form-workflow-triggers
af86d6b
fix type errors
2931206
remove async from getSubmitterEmail
7e0e572
fix type errors
1d3f76f
Merge branch 'main' into feat/routing-form-workflow-triggers
0e38ce9
revert cal.ai changes
7451a79
fix type error
9303773
add sublogger
eac7306
Merge branch 'main' into feat/routing-form-workflow-triggers
91253e3
code clean up
43a788c
Merge branch 'main' into feat/routing-form-workflow-triggers
32de973
Merge branch 'main' into feat/routing-form-workflow-triggers
ddd343e
fix type errors
6b8e602
remove label for attendee whatsapp action
d20accd
merge main into feat/routing-form-workflow-triggers
3554cdd
code clean up
07a15f2
fixes saving teams on org workflows
25ff5a7
merge main
6801f3f
fix type error
0a3590a
code improvements for activeOn ids
b294e22
Revert "code improvements for activeOn ids"
520f3bc
improve variable name
2e115ea
fix unit tests
380f9fa
small fixes
d9ed5b3
type fixes
b159476
remove unused translation keys
b5b6878
Merge branch 'main' into feat/routing-form-workflow-triggers
6a90b6a
fix merge conflict issues
01ead92
code clean up
6eac654
remove SMS action support
2cc85dc
remove more SMS code
d551320
add missing imports
eadb532
set custom template for form action
d0ca589
type fixes
594e162
fix tasker endpoint
069ae98
fix duplicate check
fec95f3
merge main
8766ae4
fix workfows.test.ts
78ad4b1
use repository funciton to getHideBranding
46e0c23
code clean up
25e05c0
fix hasDuplicateSubmission
ec9795e
code clean up
c6a7919
select only needed properties
7c77d9a
Merge branch 'main' into feat/routing-form-workflow-triggers
CarinaWolli 7aa47b1
remove repository functions
46da699
Revert "remove repository functions"
fe5db4f
add scheduleWorkflows function
9ab0a5a
Revert "add scheduleWorkflows function"
91e0152
move type to /types
3b1533e
Revert "move type to /types"
f43e786
revert changes causing type errors
af9fab6
remove import
1916768
remove unused import
d437af5
Revert "remove unused import"
763023f
revert changed from attempt to fix type errors
a120784
pass object to gt all workflows
894dbb4
fix isAuthorized check
51db2d0
trigger filtering
cfe376b
remove form submitted no event booked code
c2a3bec
remove form submitted no event from schema
5de5144
remove more code
40774f8
remove test
2823164
fixes
86c04ee
add getSubmitterEmail function
e81ead9
merge main
291bd8b
add missing workflow DTOs
fd7ba2b
small fixes
48b8d38
use activeOnWithChildren
fad1be8
Merge branch 'main' into feat/form-submitted-workflow-triggers
23539a0
fix active on when switching trigger type
6397b7f
git merge main
4145517
remove add variable dropdown
dcb425f
merge main
1177fda
add getAllWorkflowsFromRoutingForm to WorkflowService
dc68390
fix error caused by undefined evt
073ad7b
fix type error
78cc038
fix type error
d42f37b
fix tests
b3cb251
merge main
b891d17
Merge branch 'main' into feat/form-submitted-workflow-triggers
Udit-takkar f7d5e57
code clean up
ac0e4f4
remove console.log
b115131
remove template text form from triggers
eac95df
add routing form repoditory function
acccf59
fix bug with key
0632559
Merge branch 'main' into feat/form-submitted-workflow-triggers
CarinaWolli 99ad38f
Merge branch 'main' into feat/form-submitted-workflow-triggers
hbjORbj c1ecf8a
add missing trigger in update-workflow.input.ts
146cffc
Merge branch 'devin/1755107037-add-workflow-triggers' into feat/routi…
f4da96d
ForEvt and ForForm function for aiPhoneCallManager
6b82d21
chore: add support for form workflows on api v2
ThyMinimalDev c2c4a26
fixup! chore: add support for form workflows on api v2
ThyMinimalDev 49a4587
Merge branch 'main' into feat/form-submitted-workflow-triggers
ThyMinimalDev 6553d27
Merge branch 'main' into feat/form-submitted-workflow-triggers
CarinaWolli 18bf4d8
use only repository functions in update handler
fb9c6e9
move all prisma queries from list.handler
b1a872b
review suggestions
c8c236c
chore: handle workflows api v2
ThyMinimalDev 7733682
chore: handle workflows api v2, split in 2 endpoints
ThyMinimalDev d08297e
fix workflow step creation
f039e5c
remove connect agent and fixes types
97c8785
add type to workflow
4ec6945
chore: use workflow type in apiv2 WorkflowsOutputService
ThyMinimalDev f75d2df
update worklfow type on update
bb281ba
chore: use workflow type in apiv2 WorkflowsOutputService
ThyMinimalDev dfe4a42
Merge branch 'main' into feat/form-submitted-workflow-triggers
ThyMinimalDev 81cb441
fix template body for torm trigger
6109f12
some UI fixes for email subject/body
bf384fa
resetting email body when changing form triggers
9bed8f2
use type field to query workflows
952ad8a
clean up all old active on values
57525b0
Merge branch 'main' into feat/form-submitted-workflow-triggers
c774bb0
remove responseId from all funciton calls
f04f460
remove undefined from updateTemplate
210cd6b
refactor: split routing form and event-type workflows code
ThyMinimalDev 7f24b7b
refactor: split routing form and event-type workflows code
ThyMinimalDev c7b361e
Merge branch 'main' into feat/form-submitted-workflow-triggers
ThyMinimalDev 2033aef
fix template text when adding action
104a1f5
chore: don't rename WorkflowActivationDto to avoid ci blocking
ThyMinimalDev dfa4da6
refine update schedule to use only allowed actions
78b4d46
fix type error
93d401f
don't allow whatsapp action with form trigger
b5d0774
fix type error
2f9f609
Merge branch 'main' into feat/form-submitted-workflow-triggers
ThyMinimalDev 3fa87d0
return early if activeOn array is empty
91f6d1f
fix: from step type in BaseFormWorkflowStepDto
ThyMinimalDev 7da184e
fixup! fix: from step type in BaseFormWorkflowStepDto
ThyMinimalDev b5ce055
move all prisma calls to repository (service/workflows.ts)
70f218a
use FORM_TRIGGER_WORKFLOW_EVENTS for form queries
a8db17d
use userRepository
4610dfd
use FORM_TRIGGER_WORKFLOW_EVENTS in isFormTrigger
755c73c
code clean up
5c058c6
code clean up
cbf9a7a
Merge branch 'main' into feat/form-submitted-workflow-triggers
9077db6
merge main
2e116e1
add back trpc import
4cdd890
fix agent repository functions
7905192
Merge branch 'main' into feat/form-submitted-workflow-triggers
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,13 @@ import { describe, it, vi, expect, beforeEach, afterEach } from "vitest"; | |
|
|
||
| import getWebhooks from "@calcom/features/webhooks/lib/getWebhooks"; | ||
| import { sendGenericWebhookPayload } from "@calcom/features/webhooks/lib/sendPayload"; | ||
| import { WebhookTriggerEvents } from "@calcom/prisma/enums"; | ||
| import { WorkflowService } from "@calcom/lib/server/service/workflows"; | ||
| import { | ||
| WebhookTriggerEvents, | ||
| WorkflowTriggerEvents, | ||
| WorkflowActions, | ||
| WorkflowTemplates, | ||
| } from "@calcom/prisma/enums"; | ||
|
|
||
| import { _onFormSubmission } from "./formSubmissionUtils"; | ||
|
|
||
|
|
@@ -30,6 +36,14 @@ vi.mock("@calcom/features/tasker", () => { | |
| return { default: Promise.resolve(tasker) }; | ||
| }); | ||
|
|
||
| // Mock workflow dependencies | ||
| vi.mock("@calcom/lib/server/service/workflows", () => ({ | ||
| WorkflowService: { | ||
| getAllWorkflowsFromRoutingForm: vi.fn(() => Promise.resolve([])), | ||
| scheduleFormWorkflows: vi.fn(() => Promise.resolve()), | ||
| }, | ||
| })); | ||
|
|
||
| const mockSendEmail = vi.fn(() => Promise.resolve()); | ||
| const mockResponseEmailConstructor = vi.fn(); | ||
| vi.mock("../emails/templates/response-email", () => ({ | ||
|
|
@@ -49,7 +63,7 @@ describe("_onFormSubmission", () => { | |
| { id: "field-1", identifier: "email", label: "Email", type: "email" }, | ||
| { id: "field-2", identifier: "name", label: "Name", type: "text" }, | ||
| ], | ||
| user: { id: 1, email: "[email protected]" }, | ||
| user: { id: 1, email: "[email protected]", timeFormat: 12, locale: "en" }, | ||
| teamId: null, | ||
| settings: { emailOwnerOnSubmission: true }, | ||
| }; | ||
|
|
@@ -83,47 +97,59 @@ describe("_onFormSubmission", () => { | |
| }); | ||
| expect(sendGenericWebhookPayload).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
|
|
||
| it("should schedule FORM_SUBMITTED_NO_EVENT webhooks via tasker", async () => { | ||
| const tasker = await (await import("@calcom/features/tasker")).default; | ||
| const mockWebhook = { id: "wh-no-event-1", secret: "secret" }; | ||
| const chosenAction = { type: "customPageMessage" as const, value: "test" }; | ||
| describe("Workflows", () => { | ||
| it("should call WorkflowService.scheduleFormWorkflows for FORM_SUBMITTED workflows", async () => { | ||
| const mockWorkflows = [ | ||
| { | ||
| id: 1, | ||
| name: "Form Submitted Workflow", | ||
| userId: 1, | ||
| teamId: null, | ||
| trigger: WorkflowTriggerEvents.FORM_SUBMITTED, | ||
| time: null, | ||
| timeUnit: null, | ||
| steps: [ | ||
| { | ||
| id: 1, | ||
| action: WorkflowActions.EMAIL_ATTENDEE, | ||
| sendTo: null, | ||
| reminderBody: "Thank you for your submission!", | ||
| emailSubject: "Form Received", | ||
| template: WorkflowTemplates.CUSTOM, | ||
| verifiedAt: new Date(), | ||
| includeCalendarEvent: false, | ||
| numberVerificationPending: false, | ||
| numberRequired: false, | ||
| }, | ||
| ], | ||
| }, | ||
| ]; | ||
|
|
||
| vi.mocked(getWebhooks).mockImplementation(async (options) => { | ||
| if (options.triggerEvent === WebhookTriggerEvents.FORM_SUBMITTED_NO_EVENT) { | ||
| return [mockWebhook as any]; | ||
| } | ||
| return []; | ||
| }); | ||
| vi.mocked(WorkflowService.getAllWorkflowsFromRoutingForm).mockResolvedValueOnce(mockWorkflows as any); | ||
|
|
||
| await _onFormSubmission(mockForm as any, mockResponse, responseId, chosenAction); | ||
| await _onFormSubmission(mockForm as any, mockResponse, responseId); | ||
|
|
||
| expect(getWebhooks).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| triggerEvent: WebhookTriggerEvents.FORM_SUBMITTED_NO_EVENT, | ||
| }) | ||
| ); | ||
| expect(tasker.create).toHaveBeenCalledWith( | ||
| "triggerFormSubmittedNoEventWebhook", | ||
| { | ||
| responseId, | ||
| form: { | ||
| id: mockForm.id, | ||
| name: mockForm.name, | ||
| teamId: mockForm.teamId, | ||
| expect(WorkflowService.getAllWorkflowsFromRoutingForm).toHaveBeenCalledWith(mockForm); | ||
| expect(WorkflowService.scheduleFormWorkflows).toHaveBeenCalledWith({ | ||
| workflows: mockWorkflows, | ||
| responses: { | ||
| email: { | ||
| value: "[email protected]", | ||
| response: "[email protected]", | ||
| }, | ||
| responses: { | ||
| email: { | ||
| value: "[email protected]", | ||
| response: "[email protected]", | ||
| }, | ||
| name: { value: "Test Name", response: "Test Name" }, | ||
| }, | ||
| redirect: chosenAction, | ||
| webhook: mockWebhook, | ||
| name: { value: "Test Name", response: "Test Name" }, | ||
| }, | ||
| responseId, | ||
| form: { | ||
| ...mockForm, | ||
| fields: mockForm.fields.map((field) => ({ | ||
| type: field.type, | ||
| identifier: field.identifier, | ||
| })), | ||
| }, | ||
| { scheduledAt: expect.any(Date) } | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -133,7 +159,7 @@ describe("_onFormSubmission", () => { | |
| ...mockForm, | ||
| teamId: 1, | ||
| userWithEmails: ["[email protected]", "[email protected]"], | ||
| user: { id: 1, email: "[email protected]" }, | ||
| user: { id: 1, email: "[email protected]", timeFormat: 12, locale: "en" }, | ||
| }; | ||
|
|
||
| await _onFormSubmission(teamForm as any, mockResponse, responseId); | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.