Skip to content

The open alternative to Salesforce, designed for AI.

Stop the workflow step schemas from filling in email and calendar defaults (#29360)

Félix Malfait66eb254fe698
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-workflow-to-workflow-manifest.util.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-workflow-to-workflow-manifest.util.spec.ts
index c65a14c349c..66d94d2d4f5 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-workflow-to-workflow-manifest.util.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-workflow-to-workflow-manifest.util.spec.ts
@@ -477,6 +477,45 @@ describe('fromFlatWorkflowToWorkflowManifest', () => {
);
});
+ it.each([
+ {
+ type: 'DRAFT_EMAIL' as const,
+ input: {
+ connectedAccountId: '{{trigger.properties.after.assigneeId}}',
+ recipients: { to: '[email protected]' },
+ },
+ },
+ {
+ type: 'CREATE_CALENDAR_EVENT' as const,
+ input: {
+ connectedAccountId: '{{trigger.properties.after.assigneeId}}',
+ title: 'Kick-off',
+ startsAt: '2026-11-02T09:00:00.000Z',
+ endsAt: '2026-11-02T09:30:00.000Z',
+ isFullDay: false,
+ sendInvitations: true,
+ addConferencing: false,
+ },
+ },
+ ])(
+ 'stores a $type step with only the values it declares',
+ ({ type, input }) => {
+ const manifest = buildWorkflow({
+ steps: [
+ buildStep({
+ type,
+ overrides: { input } as Partial<WorkflowStepManifest>,
+ }),
+ ],
+ });
+
+ expect(
+ syncWorkflow(manifest).flatWorkflowVersion.steps?.[0]?.settings.input,
+ ).toEqual(input);
+ expectRoundTrip(manifest);
+ },
+ );
+
it('omits values the sync derives', () => {
const result = exportWorkflow(
syncWorkflow(
@@ -1036,6 +1075,30 @@ describe('fromFlatWorkflowToWorkflowManifest on versions built in the workflow b
expect(step.outputSchema).toEqual({});
});
+ it('exports an email step written without files', () => {
+ const input = {
+ connectedAccountId: '{{trigger.properties.after.accountId}}',
+ recipients: { to: '[email protected]', cc: '', bcc: '' },
+ subject: 'Hello',
+ };
+ const [step] = exportBuilderVersion({
+ triggers: [recordCreatedTrigger()],
+ steps: [
+ createRecordStep({
+ name: 'Draft Email',
+ type: 'DRAFT_EMAIL',
+ settings: {
+ outputSchema: {},
+ errorHandlingOptions: BUILDER_ERROR_HANDLING_OPTIONS,
+ input,
+ },
+ }),
+ ],
+ }).steps;
+
+ expect(step).toMatchObject({ type: 'DRAFT_EMAIL', input });
+ });
+
it('exports a chat message step that waits for an approval', () => {
const input = {
text: '{{trigger.properties.after.summary}}',
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/is-same-workflow-version-definition.util.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/is-same-workflow-version-definition.util.ts
index 5640fe5a476..9958a3c4dd1 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/is-same-workflow-version-definition.util.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/is-same-workflow-version-definition.util.ts
@@ -3,7 +3,6 @@ import { isDefined } from 'twenty-shared/utils';
import {
type StoredWorkflowNode,
- type StoredWorkflowNodeSettings,
type StoredWorkflowVersionDefinition,
} from 'src/engine/core-modules/application/application-manifest/types/stored-workflow-version-definition.type';
import { normalizeStoredWorkflowErrorHandlingOptions } from 'src/engine/core-modules/application/application-manifest/utils/normalize-stored-workflow-error-handling-options.util';
@@ -12,10 +11,8 @@ import { normalizeStoredWorkflowErrorHandlingOptions } from 'src/engine/core-mod
const normalizeSettings = ({
type,
settings: { objectType, errorHandlingOptions, ...rest },
-}: {
- type: string;
- settings: StoredWorkflowNodeSettings;
-}) => ({
+}: Pick<StoredWorkflowNode, 'type'> &
+ Required<Pick<StoredWorkflowNode, 'settings'>>) => ({
...rest,
...(type === 'MANUAL' ? {} : { objectType }),
...(isDefined(errorHandlingOptions)
diff --git a/packages/twenty-shared/src/workflow/schemas/create-calendar-event-action-settings-schema.ts b/packages/twenty-shared/src/workflow/schemas/create-calendar-event-action-settings-schema.ts
index fdf59a077b8..a77fb55a494 100644
--- a/packages/twenty-shared/src/workflow/schemas/create-calendar-event-action-settings-schema.ts
+++ b/packages/twenty-shared/src/workflow/schemas/create-calendar-event-action-settings-schema.ts
@@ -12,7 +12,7 @@ export const workflowCreateCalendarEventActionSettingsSchema =
endsAt: z.string(),
isFullDay: z.boolean(),
timeZone: z.string().optional(),
- attendees: z.string().optional().default(''),
+ attendees: z.string().optional(),
sendInvitations: z.boolean(),
addConferencing: z.boolean(),
}),
diff --git a/packages/twenty-shared/src/workflow/schemas/send-email-action-settings-schema.ts b/packages/twenty-shared/src/workflow/schemas/send-email-action-settings-schema.ts
index 4ec5f01abea..5db075c970d 100644
--- a/packages/twenty-shared/src/workflow/schemas/send-email-action-settings-schema.ts
+++ b/packages/twenty-shared/src/workflow/schemas/send-email-action-settings-schema.ts
@@ -3,17 +3,14 @@ import { baseWorkflowActionSettingsSchema } from './base-workflow-action-setting
import { workflowFileSchema } from './workflow-file-action-schema';
import { workflowVariableReferenceSchema } from './workflow-variable-reference-schema';
-export const workflowEmailFilesSchema = z
- .array(
- z.union([
- workflowFileSchema,
- workflowVariableReferenceSchema.describe(
- 'A workflow variable reference resolving to files',
- ),
- ]),
- )
- .optional()
- .default([]);
+export const workflowEmailFilesSchema = z.array(
+ z.union([
+ workflowFileSchema,
+ workflowVariableReferenceSchema.describe(
+ 'A workflow variable reference resolving to files',
+ ),
+ ]),
+);
export type WorkflowEmailFiles = z.infer<typeof workflowEmailFilesSchema>;
@@ -23,9 +20,9 @@ export const workflowSendEmailActionSettingsSchema =
connectedAccountId: z.string(),
fromHandle: z.string().trim().optional(),
recipients: z.object({
- to: z.string().optional().default(''),
- cc: z.string().optional().default(''),
- bcc: z.string().optional().default(''),
+ to: z.string().optional(),
+ cc: z.string().optional(),
+ bcc: z.string().optional(),
}),
subject: z.string().optional(),
body: z
@@ -34,7 +31,7 @@ export const workflowSendEmailActionSettingsSchema =
.describe(
'The email body as a serialized email document: JSON.stringify of {"type":"doc","attrs":{"schemaVersion":1},"content":[...]} with paragraph, heading, bulletList, orderedList, image, button, divider and html blocks. Use {{stepId.field}} for variables. To send a complete HTML email verbatim, including HTML produced by an earlier step such as {{stepId.html}}, make the body a single htmlDocument block ({"type":"htmlDocument","attrs":{"html":"..."}}): it is sent without the email layout and its variables are inserted as raw HTML, while an html block is embedded in the layout with escaped variables. HTML or plain text strings are rejected.',
),
- files: workflowEmailFilesSchema,
+ files: workflowEmailFilesSchema.optional(),
inReplyTo: z.string().trim().optional(),
}),
});