Skip to content

The open alternative to Salesforce, designed for AI.

Let application workflows send email and create calendar events (#28920)

Félix Malfaited6875731b2e
diff --git a/packages/twenty-docs/developers/extend/apps/logic/workflows.mdx b/packages/twenty-docs/developers/extend/apps/logic/workflows.mdx
index bb3f94674a9..3ec376b74fb 100644
--- a/packages/twenty-docs/developers/extend/apps/logic/workflows.mdx
+++ b/packages/twenty-docs/developers/extend/apps/logic/workflows.mdx
@@ -96,12 +96,14 @@ A webhook workflow listens on `https://<your-twenty-domain>/webhooks/workflows/<
## Steps
-Application workflows support these step types: `LOGIC_FUNCTION`, `AI_AGENT`, `HTTP_REQUEST`, `CLASSIFY`, `CREATE_RECORD`, `UPDATE_RECORD`, `UPSERT_RECORD`, `DELETE_RECORD`, `FIND_RECORDS`, `PICK_RECORD`, `FILTER`, `IF_ELSE`, `ITERATOR`, `FORM`, `DELAY`, `WAIT_FOR_EVENT` and `EMPTY`.
+Application workflows support these step types: `LOGIC_FUNCTION`, `AI_AGENT`, `HTTP_REQUEST`, `CLASSIFY`, `CREATE_RECORD`, `UPDATE_RECORD`, `UPSERT_RECORD`, `DELETE_RECORD`, `FIND_RECORDS`, `PICK_RECORD`, `FILTER`, `IF_ELSE`, `ITERATOR`, `FORM`, `DELAY`, `WAIT_FOR_EVENT`, `SEND_EMAIL`, `DRAFT_EMAIL`, `CREATE_CALENDAR_EVENT` and `EMPTY`.
Their inputs match the steps of the [workflow builder](/user-guide/workflows/capabilities/workflow-actions), with universal identifiers in place of names:
- Record steps take `objectUniversalIdentifier` instead of an object name.
- Filters and sorts point at fields with `fieldMetadataUniversalIdentifier`.
-- To run your own code, use a `LOGIC_FUNCTION` step. The builder's Code step is not available, and neither are the email and calendar steps.
+- To run your own code, use a `LOGIC_FUNCTION` step. The builder's Code step is not available.
+- Email and calendar steps run only if your app's role has the matching permission flag: `SystemPermissionFlag.SEND_EMAIL_TOOL` for `SEND_EMAIL` and `DRAFT_EMAIL`, `SystemPermissionFlag.CREATE_CALENDAR_EVENT_TOOL` for `CREATE_CALENDAR_EVENT`. The workspace grants it by installing the app, and the step can then use any connected account in the workspace, like a workflow built in the app.
+- Connected account ids are local to each workspace, so don't hardcode one. Pass the account as a variable. Email steps also take a workspace member id, such as `{{trigger.properties.after.assigneeId}}`, which resolves to that member's first account able to send.
## After install
diff --git a/packages/twenty-sdk/src/sdk/define/workflows/__tests__/define-workflow.spec.ts b/packages/twenty-sdk/src/sdk/define/workflows/__tests__/define-workflow.spec.ts
index 56d8f296303..bc87f456cbb 100644
--- a/packages/twenty-sdk/src/sdk/define/workflows/__tests__/define-workflow.spec.ts
+++ b/packages/twenty-sdk/src/sdk/define/workflows/__tests__/define-workflow.spec.ts
@@ -50,7 +50,7 @@ describe('defineWorkflow', () => {
problem: 'a step type applications cannot use',
definition: withStep({ type: 'CODE' }),
error:
- 'version.steps.0.type: Unsupported step type. Application workflows support: LOGIC_FUNCTION, HTTP_REQUEST, CLASSIFY, ITERATOR, DELAY, WAIT_FOR_EVENT, EMPTY, CREATE_RECORD, UPDATE_RECORD, UPSERT_RECORD, DELETE_RECORD, FIND_RECORDS, PICK_RECORD, FILTER, IF_ELSE, FORM, AI_AGENT',
+ 'version.steps.0.type: Unsupported step type. Application workflows support: LOGIC_FUNCTION, HTTP_REQUEST, CLASSIFY, ITERATOR, DELAY, WAIT_FOR_EVENT, EMPTY, CREATE_RECORD, UPDATE_RECORD, UPSERT_RECORD, DELETE_RECORD, FIND_RECORDS, PICK_RECORD, FILTER, IF_ELSE, FORM, SEND_EMAIL, DRAFT_EMAIL, CREATE_CALENDAR_EVENT, AI_AGENT',
},
{
problem: 'an unknown trigger type',
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-workflow-step-manifest-to-action-or-throw.util.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-workflow-step-manifest-to-action-or-throw.util.spec.ts
index 319d19bf814..f264a6a408a 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-workflow-step-manifest-to-action-or-throw.util.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-workflow-step-manifest-to-action-or-throw.util.spec.ts
@@ -47,6 +47,10 @@ const record = {
objectUniversalIdentifier: REFERENCE_ID,
objectRecord: { name: 'Company' },
};
+const email = {
+ connectedAccountId: '{{trigger.accountId}}',
+ recipients: { to: '[email protected]' },
+};
const filters = { stepFilterGroups: [], stepFilters: [] };
const inputs = {
LOGIC_FUNCTION: { value: 'Hello' },
@@ -88,6 +92,17 @@ const inputs = {
fieldUniversalIdentifier: FIELD_ID,
},
},
+ SEND_EMAIL: email,
+ DRAFT_EMAIL: email,
+ CREATE_CALENDAR_EVENT: {
+ connectedAccountId: '{{trigger.accountId}}',
+ title: 'Meeting',
+ startsAt: '2026-10-01T10:00:00Z',
+ endsAt: '2026-10-01T11:00:00Z',
+ isFullDay: false,
+ sendInvitations: false,
+ addConferencing: false,
+ },
FORM: [
{
id: FIELD_ID,
@@ -183,9 +198,6 @@ describe('application workflow actions', () => {
Object.values(WorkflowActionType).filter(
(type) =>
type !== WorkflowActionType.CODE &&
- type !== WorkflowActionType.SEND_EMAIL &&
- type !== WorkflowActionType.DRAFT_EMAIL &&
- type !== WorkflowActionType.CREATE_CALENDAR_EVENT &&
type !== WorkflowActionType.SEND_CHAT_MESSAGE,
),
)('converts %s to its runtime action', (type) => {
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/constants/application-workflow-step-permission-flags.constant.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/constants/application-workflow-step-permission-flags.constant.ts
new file mode 100644
index 00000000000..3aa1e8f3f2e
--- /dev/null
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/constants/application-workflow-step-permission-flags.constant.ts
@@ -0,0 +1,12 @@
+import { PermissionFlagType } from 'twenty-shared/constants';
+import { WorkflowActionType } from 'twenty-shared/workflow';
+
+// Steps acting through a connected account need the matching tool permission on the app role
+export const APPLICATION_WORKFLOW_STEP_PERMISSION_FLAGS: Partial<
+ Record<WorkflowActionType, PermissionFlagType>
+> = {
+ [WorkflowActionType.SEND_EMAIL]: PermissionFlagType.SEND_EMAIL_TOOL,
+ [WorkflowActionType.DRAFT_EMAIL]: PermissionFlagType.SEND_EMAIL_TOOL,
+ [WorkflowActionType.CREATE_CALENDAR_EVENT]:
+ PermissionFlagType.CREATE_CALENDAR_EVENT_TOOL,
+};
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/services/application-workflow-step-permission.service.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/services/application-workflow-step-permission.service.ts
new file mode 100644
index 00000000000..4125cc9780c
--- /dev/null
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/services/application-workflow-step-permission.service.ts
@@ -0,0 +1,51 @@
+import { Injectable } from '@nestjs/common';
+
+import { isDefined } from 'twenty-shared/utils';
+import { type WorkflowActionType } from 'twenty-shared/workflow';
+
+import { PermissionsService } from 'src/engine/metadata-modules/permissions/permissions.service';
+import { APPLICATION_WORKFLOW_STEP_PERMISSION_FLAGS } from 'src/modules/workflow/workflow-executor/constants/application-workflow-step-permission-flags.constant';
+import {
+ WorkflowStepExecutorException,
+ WorkflowStepExecutorExceptionCode,
+} from 'src/modules/workflow/workflow-executor/exceptions/workflow-step-executor.exception';
+
+@Injectable()
+export class ApplicationWorkflowStepPermissionService {
+ constructor(private readonly permissionsService: PermissionsService) {}
+
+ // Runs without an application keep the reach of whoever built the workflow
+ async assertRunApplicationMayUseStepOrThrow({
+ workspaceId,
+ runApplicationId,
+ stepType,
+ }: {
+ workspaceId: string;
+ runApplicationId?: string;
+ stepType: WorkflowActionType;
+ }): Promise<void> {
+ const permissionFlag = APPLICATION_WORKFLOW_STEP_PERMISSION_FLAGS[stepType];
+
+ if (!isDefined(runApplicationId) || !isDefined(permissionFlag)) {
+ return;
+ }
+
+ const applicationHasPermissionFlag =
+ await this.permissionsService.userHasWorkspaceSettingPermission({
+ userWorkspaceId: undefined,
+ workspaceId,
+ setting: permissionFlag,
+ applicationId: runApplicationId,
+ agentId: undefined,
+ });
+
+ if (applicationHasPermissionFlag) {
+ return;
+ }
+
+ throw new WorkflowStepExecutorException(
+ `This application needs the ${permissionFlag} permission to run ${stepType} steps`,
+ WorkflowStepExecutorExceptionCode.FORBIDDEN,
+ );
+ }
+}
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/assert-step-type-available-to-application-run.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/assert-step-type-available-to-application-run.util.spec.ts
deleted file mode 100644
index 87ffbef9a78..00000000000
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/assert-step-type-available-to-application-run.util.spec.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import { WorkflowActionType } from 'twenty-shared/workflow';
-
-import { assertStepTypeAvailableToApplicationRun } from 'src/modules/workflow/workflow-executor/utils/assert-step-type-available-to-application-run.util';
-
-describe('assertStepTypeAvailableToApplicationRun', () => {
- it.each([
- WorkflowActionType.SEND_EMAIL,
- WorkflowActionType.DRAFT_EMAIL,
- WorkflowActionType.CREATE_CALENDAR_EVENT,
- ])('refuses %s steps in a run started by an application', (stepType) => {
- expect(() =>
- assertStepTypeAvailableToApplicationRun({
- stepType,
- runApplicationId: 'installed-app-id',
- }),
- ).toThrow(`Applications cannot use ${stepType} steps`);
- });
-
- it('lets a run started by an application use other steps', () => {
- expect(() =>
- assertStepTypeAvailableToApplicationRun({
- stepType: WorkflowActionType.CREATE_RECORD,
- runApplicationId: 'installed-app-id',
- }),
- ).not.toThrow();
- });
-
- it('lets a run without an application send emails', () => {
- expect(() =>
- assertStepTypeAvailableToApplicationRun({
- stepType: WorkflowActionType.SEND_EMAIL,
- runApplicationId: undefined,
- }),
- ).not.toThrow();
- });
-});
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/assert-step-type-available-to-application-run.util.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/assert-step-type-available-to-application-run.util.ts
deleted file mode 100644
index 9813588c8a4..00000000000
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/assert-step-type-available-to-application-run.util.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { APPLICATION_WORKFLOW_UNAVAILABLE_STEP_TYPES } from 'twenty-shared/application';
-import { isDefined } from 'twenty-shared/utils';
-import { type WorkflowActionType } from 'twenty-shared/workflow';
-
-import {
- WorkflowStepExecutorException,
- WorkflowStepExecutorExceptionCode,
-} from 'src/modules/workflow/workflow-executor/exceptions/workflow-step-executor.exception';
-
-export const assertStepTypeAvailableToApplicationRun = ({
- stepType,
- runApplicationId,
-}: {
- stepType: WorkflowActionType;
- runApplicationId?: string;
-}): void => {
- if (
- !isDefined(runApplicationId) ||
- !APPLICATION_WORKFLOW_UNAVAILABLE_STEP_TYPES.includes(stepType)
- ) {
- return;
- }
-
- throw new WorkflowStepExecutorException(
- `Applications cannot use ${stepType} steps`,
- WorkflowStepExecutorExceptionCode.FORBIDDEN,
- );
-};
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-executor.module.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-executor.module.ts
index 2642e9aca91..9900bd74db0 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-executor.module.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-executor.module.ts
@@ -5,6 +5,8 @@ import { BillingModule } from 'src/engine/core-modules/billing/billing.module';
import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-flag.module';
import { MetricsModule } from 'src/engine/core-modules/metrics/metrics.module';
import { UsageLimitModule } from 'src/engine/core-modules/usage-limit/usage-limit.module';
+import { ApplicationWorkflowStepPermissionService } from 'src/modules/workflow/workflow-executor/services/application-workflow-step-permission.service';
+import { PermissionsModule } from 'src/engine/metadata-modules/permissions/permissions.module';
import { WorkflowActionFactory } from 'src/modules/workflow/workflow-executor/factories/workflow-action.factory';
import { AiAgentActionModule } from 'src/modules/workflow/workflow-executor/workflow-actions/ai-agent/ai-agent-action.module';
import { ClassifyActionModule } from 'src/modules/workflow/workflow-executor/workflow-actions/classify/classify-action.module';
@@ -51,8 +53,13 @@ import { WorkflowStepWaitModule } from 'src/modules/workflow/workflow-wait/workf
MetricsModule,
UsageLimitModule,
WorkflowStepWaitModule,
+ PermissionsModule,
+ ],
+ providers: [
+ WorkflowExecutorWorkspaceService,
+ WorkflowActionFactory,
+ ApplicationWorkflowStepPermissionService,
],
- providers: [WorkflowExecutorWorkspaceService, WorkflowActionFactory],
exports: [WorkflowExecutorWorkspaceService, WorkflowActionFactory],
})
export class WorkflowExecutorModule {}
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts
index e03436894dc..f8b64b26fac 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts
@@ -36,7 +36,6 @@ import {
type WorkflowBranchExecutorInput,
type WorkflowExecutorInput,
} from 'src/modules/workflow/workflow-executor/types/workflow-executor-input.type';
-import { assertStepTypeAvailableToApplicationRun } from 'src/modules/workflow/workflow-executor/utils/assert-step-type-available-to-application-run.util';
import { getStepRetryDelayMs } from 'src/modules/workflow/workflow-executor/utils/get-step-retry-delay-ms.util';
import { isUserFacingWorkflowExecutorError } from 'src/modules/workflow/workflow-executor/utils/is-user-facing-workflow-executor-error.util';
import { stepHasRetryAttemptsLeft } from 'src/modules/workflow/workflow-executor/utils/step-has-retry-attempts-left.util';
@@ -52,6 +51,7 @@ import { isWorkflowIteratorAction } from 'src/modules/workflow/workflow-executor
import { findEnclosingIteratorWithContinueOnFailure } from 'src/modules/workflow/workflow-executor/workflow-actions/iterator/utils/find-enclosing-iterator-with-continue-on-failure.util';
import { getNextStepIdsForIterator } from 'src/modules/workflow/workflow-executor/workflow-actions/iterator/utils/get-next-step-ids-for-iterator.util';
import { WorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';
+import { ApplicationWorkflowStepPermissionService } from 'src/modules/workflow/workflow-executor/services/application-workflow-step-permission.service';
import { RUN_WORKFLOW_JOB_NAME } from 'src/modules/workflow/workflow-runner/constants/run-workflow-job-name';
import { type RunWorkflowJobData } from 'src/modules/workflow/workflow-runner/types/run-workflow-job-data.type';
import { buildRunWorkflowJobOptions } from 'src/modules/workflow/workflow-runner/utils/build-run-workflow-job-options.util';
@@ -79,6 +79,7 @@ export class WorkflowExecutorWorkspaceService {
private readonly workflowStepWaitWorkspaceService: WorkflowStepWaitWorkspaceService,
@InjectMessageQueue(MessageQueue.workflowQueue)
private readonly messageQueueService: MessageQueueService,
+ private readonly applicationWorkflowStepPermissionService: ApplicationWorkflowStepPermissionService,
) {}
async executeFromSteps({
@@ -601,10 +602,13 @@ export class WorkflowExecutorWorkspaceService {
try {
await this.assertActionTypeEnabled({ type: step.type, workspaceId });
- assertStepTypeAvailableToApplicationRun({
- stepType: step.type,
- runApplicationId,
- });
+ await this.applicationWorkflowStepPermissionService.assertRunApplicationMayUseStepOrThrow(
+ {
+ workspaceId,
+ runApplicationId,
+ stepType: step.type,
+ },
+ );
const nodeRunRefusal = await this.getNodeRunRefusal({
workspaceId,
diff --git a/packages/twenty-server/test/integration/graphql/suites/workflow/application-workflow-execution-permissions.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/workflow/application-workflow-execution-permissions.integration-spec.ts
index 262bb9e91d0..6506cf42017 100644
--- a/packages/twenty-server/test/integration/graphql/suites/workflow/application-workflow-execution-permissions.integration-spec.ts
+++ b/packages/twenty-server/test/integration/graphql/suites/workflow/application-workflow-execution-permissions.integration-spec.ts
@@ -150,18 +150,33 @@ const FORM_WORKFLOW = buildTestWorkflow([
} as WorkflowStepManifestWithoutEdges,
]);
+const DRAFT_EMAIL_WORKFLOW = buildTestWorkflow([
+ {
+ name: 'Draft an email',
+ type: 'DRAFT_EMAIL',
+ input: {
+ connectedAccountId: randomUUID(),
+ recipients: { to: '[email protected]', cc: '', bcc: '' },
+ subject: `${RUN_PREFIX} draft`,
+ },
+ } as WorkflowStepManifestWithoutEdges,
+]);
+
const TEST_WORKFLOWS = [
CREATE_COMPANY_WORKFLOW,
CREATE_OPPORTUNITY_WORKFLOW,
LOGIC_FUNCTION_WORKFLOW,
DELAYED_CREATE_COMPANY_WORKFLOW,
FORM_WORKFLOW,
+ DRAFT_EMAIL_WORKFLOW,
];
const buildManifest = ({
canManageCompanies,
+ canSendEmail = false,
}: {
canManageCompanies: boolean;
+ canSendEmail?: boolean;
}): Manifest =>
buildBaseManifest({
appId: APP_ID,
@@ -188,7 +203,10 @@ const buildManifest = ({
},
]
: [],
- permissionFlagUniversalIdentifiers: [SystemPermissionFlag.WORKFLOWS],
+ permissionFlagUniversalIdentifiers: [
+ SystemPermissionFlag.WORKFLOWS,
+ ...(canSendEmail ? [SystemPermissionFlag.SEND_EMAIL_TOOL] : []),
+ ],
},
],
logicFunctions: [
@@ -647,6 +665,46 @@ describe('application workflow execution permissions', () => {
).not.toHaveProperty('opportunity');
}, 120000);
+ it('refuses an email step when the application role lacks the send email permission', async () => {
+ const workflowRun = await waitForRunToEnd(
+ await runWorkflow(DRAFT_EMAIL_WORKFLOW),
+ );
+ const [draftStep] = DRAFT_EMAIL_WORKFLOW.steps;
+ const draftStepInfo =
+ workflowRun.state.stepInfos[draftStep.universalIdentifier];
+
+ expect(workflowRun.status).toBe('FAILED');
+ expect(draftStepInfo.status).toBe('FAILED');
+ expect(draftStepInfo.error).toContain(
+ 'This application needs the SEND_EMAIL_TOOL permission to run DRAFT_EMAIL steps',
+ );
+ }, 120000);
+
+ it('lets an email step through the permission check once the application role has it', async () => {
+ const grant = await syncApplication({
+ manifest: buildManifest({ canManageCompanies: true, canSendEmail: true }),
+ });
+
+ expect(grant.errors).toBeUndefined();
+
+ const workflowRun = await waitForRunToEnd(
+ await runWorkflow(DRAFT_EMAIL_WORKFLOW),
+ );
+ const [draftStep] = DRAFT_EMAIL_WORKFLOW.steps;
+ const draftStepInfo =
+ workflowRun.state.stepInfos[draftStep.universalIdentifier];
+
+ // The step still fails on the made-up connected account, after the permission check
+ expect(draftStepInfo.status).toBe('FAILED');
+ expect(draftStepInfo.error).not.toContain('SEND_EMAIL_TOOL');
+
+ const revocation = await syncApplication({
+ manifest: buildManifest({ canManageCompanies: true }),
+ });
+
+ expect(revocation.errors).toBeUndefined();
+ }, 150000);
+
it('checks the current application permissions again when a delayed run resumes', async () => {
const workflowRunId = await runWorkflow(DELAYED_CREATE_COMPANY_WORKFLOW);
const [delayStep, createStep] = DELAYED_CREATE_COMPANY_WORKFLOW.steps;
diff --git a/packages/twenty-shared/src/application/__tests__/workflowManifestType.spec.ts b/packages/twenty-shared/src/application/__tests__/workflowManifestType.spec.ts
index effc21a6d49..e0f714d084e 100644
--- a/packages/twenty-shared/src/application/__tests__/workflowManifestType.spec.ts
+++ b/packages/twenty-shared/src/application/__tests__/workflowManifestType.spec.ts
@@ -1,6 +1,5 @@
/** @jest-environment node */
-import { APPLICATION_WORKFLOW_UNAVAILABLE_STEP_TYPES } from '@/application/constants/ApplicationWorkflowUnavailableStepTypes';
import { isDefined } from '@/utils/validation/isDefined';
import {
@@ -124,24 +123,51 @@ describe('workflow manifest iterator cycles', () => {
});
describe('workflow manifest step types', () => {
- it.each(APPLICATION_WORKFLOW_UNAVAILABLE_STEP_TYPES)(
- 'rejects %s steps',
- (type) => {
- const invalid = structuredClone(workflow);
- Object.assign(getStep(invalid, 2), { type });
- const result = workflowManifestSchema.safeParse(invalid);
- expect(result.success).toBe(false);
- expect(result.error?.issues[0]?.path).toEqual([
- 'version',
- 'steps',
- 2,
- 'type',
- ]);
- expect(result.error?.issues[0]?.message).toContain(
- 'Unsupported step type',
- );
+ const ASSIGNEE = '{{trigger.properties.after.assigneeId}}';
+
+ it.each([
+ {
+ type: 'SEND_EMAIL',
+ input: {
+ connectedAccountId: ASSIGNEE,
+ recipients: { to: '{{trigger.properties.after.email}}' },
+ subject: 'Hello',
+ },
+ },
+ {
+ type: 'DRAFT_EMAIL',
+ input: {
+ connectedAccountId: ASSIGNEE,
+ recipients: { to: '[email protected]' },
+ },
},
- );
+ {
+ type: 'CREATE_CALENDAR_EVENT',
+ input: {
+ connectedAccountId: '{{trigger.properties.after.connectedAccountId}}',
+ title: 'Kick-off',
+ startsAt: '2026-11-02T09:00:00.000Z',
+ endsAt: '2026-11-02T09:30:00.000Z',
+ isFullDay: false,
+ sendInvitations: true,
+ addConferencing: false,
+ },
+ },
+ ])('accepts $type steps', ({ type, input }) => {
+ const definition = structuredClone(workflow);
+ Object.assign(getStep(definition, 2), { type, input });
+
+ expect(workflowManifestSchema.safeParse(definition).success).toBe(true);
+ });
+
+ it('rejects a step type applications cannot use', () => {
+ const invalid = structuredClone(workflow);
+ Object.assign(getStep(invalid, 2), { type: 'CODE' });
+ const result = workflowManifestSchema.safeParse(invalid);
+
+ expect(result.success).toBe(false);
+ expect(result.error?.issues[0]?.message).toContain('Unsupported step type');
+ });
});
describe('workflow manifest manual trigger', () => {
diff --git a/packages/twenty-shared/src/application/constants/ApplicationWorkflowUnavailableStepTypes.ts b/packages/twenty-shared/src/application/constants/ApplicationWorkflowUnavailableStepTypes.ts
deleted file mode 100644
index 1d54a362f7e..00000000000
--- a/packages/twenty-shared/src/application/constants/ApplicationWorkflowUnavailableStepTypes.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { WorkflowActionType } from '@/workflow/types/WorkflowActionType';
-
-export const APPLICATION_WORKFLOW_UNAVAILABLE_STEP_TYPES: readonly WorkflowActionType[] =
- [
- WorkflowActionType.SEND_EMAIL,
- WorkflowActionType.DRAFT_EMAIL,
- WorkflowActionType.CREATE_CALENDAR_EVENT,
- ];
diff --git a/packages/twenty-shared/src/application/index.ts b/packages/twenty-shared/src/application/index.ts
index bd8f7cbeafc..b24ca384ff1 100644
--- a/packages/twenty-shared/src/application/index.ts
+++ b/packages/twenty-shared/src/application/index.ts
@@ -84,7 +84,6 @@ export { AGENT_TRIGGER_EVENT_NAME_PATTERN } from './constants/AgentTriggerEventN
export { AGENT_TRIGGER_LIMITS } from './constants/AgentTriggerLimits';
export { AGENT_TRIGGER_TYPES } from './constants/AgentTriggerTypes';
export { APPLICATION_FILE_UPLOAD_BATCH_SIZE } from './constants/ApplicationFileUploadBatchSize';
-export { APPLICATION_WORKFLOW_UNAVAILABLE_STEP_TYPES } from './constants/ApplicationWorkflowUnavailableStepTypes';
export { ASSETS_DIR } from './constants/AssetDirectory';
export { CONNECTION_PROVIDER_SCOPES } from './constants/ConnectionProviderScopes';
export { DEFAULT_CONNECTION_PROVIDER_SCOPE } from './constants/DefaultConnectionProviderScope';
diff --git a/packages/twenty-shared/src/application/workflowStepManifestType.ts b/packages/twenty-shared/src/application/workflowStepManifestType.ts
index d664a8d6c5e..49b4938ab04 100644
--- a/packages/twenty-shared/src/application/workflowStepManifestType.ts
+++ b/packages/twenty-shared/src/application/workflowStepManifestType.ts
@@ -19,6 +19,8 @@ import { workflowFindRecordsActionSettingsSchema } from '@/workflow/schemas/find
import { workflowFormActionSettingsSchema } from '@/workflow/schemas/form-action-settings-schema';
import { workflowFilterActionSettingsSchema } from '@/workflow/schemas/filter-action-settings-schema';
import { workflowIfElseActionSettingsSchema } from '@/workflow/schemas/if-else-action-settings-schema';
+import { workflowSendEmailActionSettingsSchema } from '@/workflow/schemas/send-email-action-settings-schema';
+import { workflowCreateCalendarEventActionSettingsSchema } from '@/workflow/schemas/create-calendar-event-action-settings-schema';
import { recordFilterGroupSchema } from '@/workflow/schemas/record-filter-group-schema';
import { recordFilterSchema } from '@/workflow/schemas/record-filter-schema';
import { stepFilterSchema } from '@/workflow/schemas/step-filter-schema';
@@ -191,6 +193,12 @@ const workflowStepManifestOptions = [
}),
),
),
+ stepSchema('SEND_EMAIL', workflowSendEmailActionSettingsSchema.shape.input),
+ stepSchema('DRAFT_EMAIL', workflowSendEmailActionSettingsSchema.shape.input),
+ stepSchema(
+ 'CREATE_CALENDAR_EVENT',
+ workflowCreateCalendarEventActionSettingsSchema.shape.input,
+ ),
stepSchema(
'AI_AGENT',
z.strictObject({