Skip to content

The open alternative to Salesforce, designed for AI.

feat(twenty-slack): interactivity endpoint + native feedback buttons on assistant answers (#24107)

Abdul Rahmane25b02ca971c
diff --git a/packages/twenty-apps/public/slack/README.md b/packages/twenty-apps/public/slack/README.md
index 2a0d0029d3a..559427db6cc 100644
--- a/packages/twenty-apps/public/slack/README.md
+++ b/packages/twenty-apps/public/slack/README.md
@@ -10,7 +10,7 @@
## πŸ€– The assistant
-Mention the bot in a channel or DM it. It replies in the thread with your CRM data, using the recent conversation as context.
+Mention the bot in a channel or DM it. It replies in the thread with your CRM data, using the recent conversation as context. Answers end with native thumbs up / thumbs down feedback buttons β€” except very long answers, which fall back to plain text without them β€” and ratings are stored on the matching Slack Assistant Request record in Twenty.
The bot runs with the **Slack Assistant** role, which by default can read, create, update and soft-delete people, companies, opportunities, notes and tasks. Workspace members stay read-only and hard delete is off. Tighten the role in **Settings β†’ Roles** if you want a narrower bot.
diff --git a/packages/twenty-apps/public/slack/SETUP.md b/packages/twenty-apps/public/slack/SETUP.md
index c57cbd26232..4c52ede3ff0 100644
--- a/packages/twenty-apps/public/slack/SETUP.md
+++ b/packages/twenty-apps/public/slack/SETUP.md
@@ -4,7 +4,7 @@ Two parts: a **Slack app** you create, and the **Twenty side** where you paste i
## 1. Slack app
-1. Create a Slack app at [api.slack.com/apps](https://api.slack.com/apps) β†’ **Create New App β†’ From a manifest**, pasting [`slack-app-manifest.json`](./slack-app-manifest.json) with both `<YOUR_TWENTY_SERVER_URL>` placeholders replaced. The manifest is the source of truth for scopes, event subscriptions and the agent surface β€” the steps below describe what it configures, so an app created from it only needs credentials copied (step 4). Use a dedicated app β€” do not reuse one across Twenty apps.
+1. Create a Slack app at [api.slack.com/apps](https://api.slack.com/apps) β†’ **Create New App β†’ From a manifest**, pasting [`slack-app-manifest.json`](./slack-app-manifest.json) with all `<YOUR_TWENTY_SERVER_URL>` placeholders replaced. The manifest is the source of truth for scopes, event subscriptions and the agent surface β€” the steps below describe what it configures, so an app created from it only needs credentials copied (step 4). Use a dedicated app β€” do not reuse one across Twenty apps.
The manifest enables `agent_view` (Slack's Agent messaging experience): the app is listed as an agent in Slack's UI, shows clickable suggested prompts at the top of its Messages tab, and replies show a native thinking status instead of placeholder messages, in DMs and channel threads alike. On an app configured by hand instead, enable **Agents & AI Apps** in the app settings, which also adds the `assistant:write` scope.
@@ -74,9 +74,17 @@ The assistant reuses the same Slack connection β€” no second bot identity.
Event subscriptions added in app upgrades must be added here by hand on existing installs β€” the Slack app only reads the manifest at creation. Upgrading from any version before 0.4.1 adds `app_uninstalled` and `tokens_revoked`; without them the team claim of a Slack-side removal is never released. No new scopes are involved, so the connection itself needs no re-authorization.
-3. **Reconnect** so the token picks up the assistant scopes.
+3. **Interactivity.** On the Slack app, enable **Interactivity & Shortcuts** and set the Request URL to:
-4. **Role.** The `slack-assistant` agent binds to the app's **Slack Assistant** role automatically on install and upgrade. That role is the ceiling for everything the bot can do.
+ ```text
+ <YOUR_TWENTY_SERVER_URL>/webhooks/server/fd756b00-50a2-4816-a919-a1a959a2ed9a
+ ```
+
+ That ID is the `slack-interactivity-resolver` logic function. It powers the thumbs up / thumbs down feedback buttons under assistant answers; requests are verified with the same `SLACK_WEBHOOK_SECRET`. Apps created from the manifest have this preconfigured; existing apps must enable it by hand or the buttons show a warning when clicked.
+
+4. **Reconnect** so the token picks up the assistant scopes.
+
+5. **Role.** The `slack-assistant` agent binds to the app's **Slack Assistant** role automatically on install and upgrade. That role is the ceiling for everything the bot can do.
Where a Slack account is linked to a workspace member, the bot also runs with that member's own permissions, so it can never do more than the person asking. Accounts with no link act with the Slack Assistant role alone, so keep it scoped to what you're comfortable exposing to anyone who can message the bot.
@@ -85,9 +93,10 @@ The assistant reuses the same Slack connection β€” no second bot identity.
- **Suggested prompts.** With `app_home_opened` subscribed and the Agents feature enabled, opening the bot's Messages tab shows clickable example prompts, refreshed on every open.
- **Direct messages.** Each new message in the bot's Messages tab starts its own conversation thread: the bot shows a "Twenty is thinking…" status while it works, replies in the thread, and titles the thread after the question. Conversation context is scoped to the thread, not the whole DM history.
- **Channel mentions.** The bot shows its thinking status in the mention's thread and posts its answer as a thread reply. The status is only visible with the thread open, so the channel itself stays quiet until the answer arrives.
+- **Answer feedback.** Short answers end with Slack's native thumbs up / thumbs down feedback buttons. A click stores a Positive or Negative rating on the matching Slack Assistant Request record (last click wins). Very long answers fall back to a plain markdown message without buttons.
- **Thread memory.** After a successful reply the bot stays active in that thread, so follow-ups need no mention. Channel threads stay active for 24 hours after the last reply (each reply renews it); DM threads never expire.
- **No silent dead-ends.** A mention or DM with no request text gets a short hint reply. The first follow-up in a thread whose 24-hour window has lapsed gets an ephemeral nudge (only that member sees it) to mention the bot again.
-- **Channel welcome.** With `member_joined_channel` subscribed, the bot posts a short introduction the first time it is added to a channel, with the details (what to ask it, what it reads, and how permissions work per step 4 above) in a thread reply so the channel itself stays quiet. It fires once per channel for 30 days, and only for the bot's own join β€” humans joining afterwards trigger nothing. Skip the subscription if you would rather it arrived silently.
+- **Channel welcome.** With `member_joined_channel` subscribed, the bot posts a short introduction the first time it is added to a channel, with the details (what to ask it, what it reads, and how permissions work per step 5 above) in a thread reply so the channel itself stays quiet. It fires once per channel for 30 days, and only for the bot's own join β€” humans joining afterwards trigger nothing. Skip the subscription if you would rather it arrived silently.
- **One Slack workspace per Twenty workspace.** Connecting Slack claims that Slack team for the connecting Twenty workspace. On the same server, a second Twenty workspace connecting the same Slack team is rejected. Removing the connection releases the claim, so another Twenty workspace can then connect that Slack team. Uninstalling the app releases it too, and so does removing the app on the Slack side (uninstalling it from the Slack workspace or revoking its bot token) β€” with `app_uninstalled` and `tokens_revoked` subscribed, Slack reports the removal and the claim is released. The dead connection still shows under **Connections** until you remove it; reconnecting means removing it and adding a new connection.
## Workflow field names (for step authors)
diff --git a/packages/twenty-apps/public/slack/package.json b/packages/twenty-apps/public/slack/package.json
index 8feb897043a..379c86a33f5 100644
--- a/packages/twenty-apps/public/slack/package.json
+++ b/packages/twenty-apps/public/slack/package.json
@@ -1,6 +1,6 @@
{
"name": "@twentyhq/slack",
- "version": "0.4.1",
+ "version": "0.5.0",
"description": "Slack assistant and workflow steps for Twenty",
"license": "MIT",
"engines": {
diff --git a/packages/twenty-apps/public/slack/slack-app-manifest.json b/packages/twenty-apps/public/slack/slack-app-manifest.json
index a1a3b1c29da..870cb917f68 100644
--- a/packages/twenty-apps/public/slack/slack-app-manifest.json
+++ b/packages/twenty-apps/public/slack/slack-app-manifest.json
@@ -38,6 +38,10 @@
}
},
"settings": {
+ "interactivity": {
+ "is_enabled": true,
+ "request_url": "<YOUR_TWENTY_SERVER_URL>/webhooks/server/fd756b00-50a2-4816-a919-a1a959a2ed9a"
+ },
"event_subscriptions": {
"request_url": "<YOUR_TWENTY_SERVER_URL>/webhooks/server/9ad6fa20-dff5-4d3f-ad5f-084f3c8b0b09",
"bot_events": [
diff --git a/packages/twenty-apps/public/slack/src/constants/universal-identifiers.ts b/packages/twenty-apps/public/slack/src/constants/universal-identifiers.ts
index f08f1bf997a..78fa012f060 100644
--- a/packages/twenty-apps/public/slack/src/constants/universal-identifiers.ts
+++ b/packages/twenty-apps/public/slack/src/constants/universal-identifiers.ts
@@ -37,6 +37,12 @@ export const SLACK_EVENTS_ROUTE_UNIVERSAL_IDENTIFIER =
export const SLACK_EVENTS_ENQUEUE_UNIVERSAL_IDENTIFIER =
'8f2e1d3c-4b5a-4c6d-9e7f-0a1b2c3d4e5f';
+export const SLACK_INTERACTIVITY_ROUTE_UNIVERSAL_IDENTIFIER =
+ 'fd756b00-50a2-4816-a919-a1a959a2ed9a';
+
+export const SLACK_ASSISTANT_FEEDBACK_UNIVERSAL_IDENTIFIER =
+ '60947582-0735-4b6d-8c1f-5e237875a2e4';
+
export const SLACK_CHANNEL_WELCOME_UNIVERSAL_IDENTIFIER =
'c5e8b13a-7f42-4d90-8a6b-1e3c9d052f47';
@@ -94,6 +100,9 @@ export const SLACK_ASSISTANT_REQUEST_STATUS_FIELD_UNIVERSAL_IDENTIFIER =
export const SLACK_ASSISTANT_REQUEST_ERROR_FIELD_UNIVERSAL_IDENTIFIER =
'13fa7926-c37b-464a-a6a7-d30e3a5f33ce';
+export const SLACK_ASSISTANT_REQUEST_FEEDBACK_RATING_FIELD_UNIVERSAL_IDENTIFIER =
+ '9b7d83e1-e526-474b-8d93-dad5c0a4a6aa';
+
export const SLACK_ASSISTANT_REQUEST_SLACK_MESSAGE_INDEX_UNIVERSAL_IDENTIFIER =
'486c87fe-c557-4dd1-a7ec-133e4e0324ae';
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/constants/slack-assistant-feedback-action-id.ts b/packages/twenty-apps/public/slack/src/logic-functions/constants/slack-assistant-feedback-action-id.ts
new file mode 100644
index 00000000000..f9f6de02e96
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/constants/slack-assistant-feedback-action-id.ts
@@ -0,0 +1 @@
+export const SLACK_ASSISTANT_FEEDBACK_ACTION_ID = 'slack-assistant-feedback';
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/constants/slack-assistant-feedback-button-value.ts b/packages/twenty-apps/public/slack/src/logic-functions/constants/slack-assistant-feedback-button-value.ts
new file mode 100644
index 00000000000..2c2d035750d
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/constants/slack-assistant-feedback-button-value.ts
@@ -0,0 +1,4 @@
+export const SLACK_ASSISTANT_FEEDBACK_BUTTON_VALUE = {
+ POSITIVE: 'positive_feedback',
+ NEGATIVE: 'negative_feedback',
+} as const;
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/constants/slack-assistant-feedback-rating.ts b/packages/twenty-apps/public/slack/src/logic-functions/constants/slack-assistant-feedback-rating.ts
new file mode 100644
index 00000000000..2433cb88257
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/constants/slack-assistant-feedback-rating.ts
@@ -0,0 +1,4 @@
+export const SLACK_ASSISTANT_FEEDBACK_RATING = {
+ POSITIVE: 'POSITIVE',
+ NEGATIVE: 'NEGATIVE',
+} as const;
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/data/update-slack-assistant-request-feedback.ts b/packages/twenty-apps/public/slack/src/logic-functions/data/update-slack-assistant-request-feedback.ts
new file mode 100644
index 00000000000..ee65a63b667
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/data/update-slack-assistant-request-feedback.ts
@@ -0,0 +1,24 @@
+import { type CoreApiClient } from 'twenty-client-sdk/core';
+
+import { type SlackAssistantFeedbackRating } from 'src/logic-functions/types/slack-assistant-feedback-rating.type';
+
+export const updateSlackAssistantRequestFeedback = async (
+ client: CoreApiClient,
+ {
+ id,
+ feedbackRating,
+ }: {
+ id: string;
+ feedbackRating: SlackAssistantFeedbackRating;
+ },
+): Promise<void> => {
+ await client.mutation({
+ updateSlackAssistantRequest: {
+ __args: {
+ id,
+ data: { feedbackRating },
+ },
+ id: true,
+ },
+ });
+};
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/handlers/__tests__/slack-assistant-feedback-handler.test.ts b/packages/twenty-apps/public/slack/src/logic-functions/handlers/__tests__/slack-assistant-feedback-handler.test.ts
new file mode 100644
index 00000000000..5af95aaf009
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/handlers/__tests__/slack-assistant-feedback-handler.test.ts
@@ -0,0 +1,108 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { slackAssistantFeedbackHandler } from 'src/logic-functions/handlers/slack-assistant-feedback-handler';
+
+const { updateSlackAssistantRequestFeedbackMock } = vi.hoisted(() => ({
+ updateSlackAssistantRequestFeedbackMock: vi.fn(),
+}));
+
+vi.mock(
+ 'src/logic-functions/data/update-slack-assistant-request-feedback',
+ () => ({
+ updateSlackAssistantRequestFeedback: updateSlackAssistantRequestFeedbackMock,
+ }),
+);
+
+vi.mock('twenty-client-sdk/core', () => ({
+ CoreApiClient: vi.fn(),
+}));
+
+const REQUEST_ID = '3f77d0b1-30a1-4c3d-9d02-2f2a9f6f9d10';
+
+const buildPayload = ({
+ actionId = 'slack-assistant-feedback',
+ blockId = REQUEST_ID,
+ value = 'positive_feedback',
+}: {
+ actionId?: string;
+ blockId?: string;
+ value?: string;
+} = {}) => ({
+ type: 'block_actions',
+ team: { id: 'T0123456789' },
+ user: { id: 'U0123456789' },
+ actions: [
+ {
+ type: 'feedback_buttons',
+ action_id: actionId,
+ block_id: blockId,
+ value,
+ },
+ ],
+});
+
+describe('slackAssistantFeedbackHandler', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it('should store a positive rating on the request record', async () => {
+ const result = await slackAssistantFeedbackHandler(buildPayload());
+
+ expect(updateSlackAssistantRequestFeedbackMock).toHaveBeenCalledTimes(1);
+ expect(updateSlackAssistantRequestFeedbackMock).toHaveBeenCalledWith(
+ expect.anything(),
+ { id: REQUEST_ID, feedbackRating: 'POSITIVE' },
+ );
+ expect(result).toEqual({ done: true });
+ });
+
+ it('should store a negative rating on the request record', async () => {
+ const result = await slackAssistantFeedbackHandler(
+ buildPayload({ value: 'negative_feedback' }),
+ );
+
+ expect(updateSlackAssistantRequestFeedbackMock).toHaveBeenCalledTimes(1);
+ expect(updateSlackAssistantRequestFeedbackMock).toHaveBeenCalledWith(
+ expect.anything(),
+ { id: REQUEST_ID, feedbackRating: 'NEGATIVE' },
+ );
+ expect(result).toEqual({ done: true });
+ });
+
+ it('should skip payloads without the assistant feedback action', async () => {
+ const result = await slackAssistantFeedbackHandler(
+ buildPayload({ actionId: 'another-action' }),
+ );
+
+ expect(updateSlackAssistantRequestFeedbackMock).not.toHaveBeenCalled();
+ expect(result).toEqual({
+ skipped: true,
+ reason: 'No assistant feedback action in payload',
+ });
+ });
+
+ it('should skip feedback actions without a request id', async () => {
+ const result = await slackAssistantFeedbackHandler(
+ buildPayload({ blockId: '' }),
+ );
+
+ expect(updateSlackAssistantRequestFeedbackMock).not.toHaveBeenCalled();
+ expect(result).toEqual({
+ skipped: true,
+ reason: 'Feedback action has no request id',
+ });
+ });
+
+ it('should skip feedback actions with an unknown button value', async () => {
+ const result = await slackAssistantFeedbackHandler(
+ buildPayload({ value: 'something-else' }),
+ );
+
+ expect(updateSlackAssistantRequestFeedbackMock).not.toHaveBeenCalled();
+ expect(result).toEqual({
+ skipped: true,
+ reason: 'Unknown feedback button value: something-else',
+ });
+ });
+});
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/handlers/slack-assistant-feedback-handler.ts b/packages/twenty-apps/public/slack/src/logic-functions/handlers/slack-assistant-feedback-handler.ts
new file mode 100644
index 00000000000..645eec03023
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/handlers/slack-assistant-feedback-handler.ts
@@ -0,0 +1,46 @@
+import { isNonEmptyString } from '@sniptt/guards';
+import { CoreApiClient } from 'twenty-client-sdk/core';
+import { isDefined } from 'twenty-sdk/utils';
+
+import { SLACK_ASSISTANT_FEEDBACK_ACTION_ID } from 'src/logic-functions/constants/slack-assistant-feedback-action-id';
+import { updateSlackAssistantRequestFeedback } from 'src/logic-functions/data/update-slack-assistant-request-feedback';
+import { type SlackAssistantFeedbackResult } from 'src/logic-functions/types/slack-assistant-feedback-result.type';
+import { type SlackInteractivityPayload } from 'src/logic-functions/types/slack-interactivity-payload.type';
+import { parseSlackAssistantFeedbackRating } from 'src/logic-functions/utils/parse-slack-assistant-feedback-rating';
+
+export const slackAssistantFeedbackHandler = async (
+ payload: SlackInteractivityPayload,
+): Promise<SlackAssistantFeedbackResult> => {
+ const feedbackAction = payload.actions?.find(
+ (action) => action.action_id === SLACK_ASSISTANT_FEEDBACK_ACTION_ID,
+ );
+
+ if (!isDefined(feedbackAction)) {
+ return { skipped: true, reason: 'No assistant feedback action in payload' };
+ }
+
+ // The answer blocks carry the request record id as the block_id.
+ const requestId = feedbackAction.block_id;
+
+ if (!isNonEmptyString(requestId)) {
+ return { skipped: true, reason: 'Feedback action has no request id' };
+ }
+
+ const feedbackRating = parseSlackAssistantFeedbackRating(
+ feedbackAction.value,
+ );
+
+ if (!isDefined(feedbackRating)) {
+ return {
+ skipped: true,
+ reason: `Unknown feedback button value: ${feedbackAction.value}`,
+ };
+ }
+
+ await updateSlackAssistantRequestFeedback(new CoreApiClient(), {
+ id: requestId,
+ feedbackRating,
+ });
+
+ return { done: true };
+};
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/handlers/slack-interactivity-resolver-handler.ts b/packages/twenty-apps/public/slack/src/logic-functions/handlers/slack-interactivity-resolver-handler.ts
new file mode 100644
index 00000000000..755cc4ef029
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/handlers/slack-interactivity-resolver-handler.ts
@@ -0,0 +1,43 @@
+import { type RoutePayload } from 'twenty-sdk/define';
+import { Response } from 'twenty-sdk/logic-function';
+
+import { SLACK_ASSISTANT_FEEDBACK_UNIVERSAL_IDENTIFIER } from 'src/constants/universal-identifiers';
+import { SLACK_ASSISTANT_FEEDBACK_ACTION_ID } from 'src/logic-functions/constants/slack-assistant-feedback-action-id';
+import { type SlackInteractivityPayload } from 'src/logic-functions/types/slack-interactivity-payload.type';
+import { type SlackInteractivityRequestBody } from 'src/logic-functions/types/slack-interactivity-request-body.type';
+import { parseSlackInteractivityPayloadOrThrow } from 'src/logic-functions/utils/parse-slack-interactivity-payload-or-throw';
+import { resolveTargetWorkspaceId } from 'src/logic-functions/utils/resolve-target-workspace-id';
+import { verifySlackWebhookRequestOrThrow } from 'src/logic-functions/utils/verify-slack-webhook-request-or-throw';
+
+type SlackInteractivityResolverResult =
+ | Response
+ | {
+ workspaceId: string;
+ targetLogicFunctionUniversalIdentifier: string;
+ payload: SlackInteractivityPayload;
+ };
+
+export const slackInteractivityResolverHandler = async (
+ routePayload: RoutePayload<SlackInteractivityRequestBody>,
+): Promise<SlackInteractivityResolverResult> => {
+ verifySlackWebhookRequestOrThrow(routePayload);
+
+ const payload = parseSlackInteractivityPayloadOrThrow(routePayload.body);
+
+ const hasAssistantFeedbackAction =
+ payload.type === 'block_actions' &&
+ (payload.actions ?? []).some(
+ (action) => action.action_id === SLACK_ASSISTANT_FEEDBACK_ACTION_ID,
+ );
+
+ if (!hasAssistantFeedbackAction) {
+ return new Response({ ok: true });
+ }
+
+ return {
+ workspaceId: await resolveTargetWorkspaceId(payload.team?.id),
+ targetLogicFunctionUniversalIdentifier:
+ SLACK_ASSISTANT_FEEDBACK_UNIVERSAL_IDENTIFIER,
+ payload,
+ };
+};
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/slack-assistant-feedback.ts b/packages/twenty-apps/public/slack/src/logic-functions/slack-assistant-feedback.ts
new file mode 100644
index 00000000000..b5e2bf91836
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/slack-assistant-feedback.ts
@@ -0,0 +1,13 @@
+import { defineLogicFunction } from 'twenty-sdk/define';
+
+import { SLACK_ASSISTANT_FEEDBACK_UNIVERSAL_IDENTIFIER } from 'src/constants/universal-identifiers';
+import { slackAssistantFeedbackHandler } from 'src/logic-functions/handlers/slack-assistant-feedback-handler';
+
+export default defineLogicFunction({
+ universalIdentifier: SLACK_ASSISTANT_FEEDBACK_UNIVERSAL_IDENTIFIER,
+ name: 'slack-assistant-feedback',
+ description:
+ 'Runs in the resolved workspace: stores the thumbs up / thumbs down rating a user left with the feedback buttons under an assistant answer on the matching Slack Assistant Request record.',
+ timeoutSeconds: 15,
+ handler: slackAssistantFeedbackHandler,
+});
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/slack-assistant-worker.ts b/packages/twenty-apps/public/slack/src/logic-functions/slack-assistant-worker.ts
index 5ad86ed94d7..6102947af0b 100644
--- a/packages/twenty-apps/public/slack/src/logic-functions/slack-assistant-worker.ts
+++ b/packages/twenty-apps/public/slack/src/logic-functions/slack-assistant-worker.ts
@@ -170,6 +170,7 @@ export const slackAssistantWorkerHandler = async (
: buildSlackAssistantAnswerBlocks({
responseText,
durationMilliseconds,
+ requestId: record.id,
}),
});
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/slack-events-resolver.ts b/packages/twenty-apps/public/slack/src/logic-functions/slack-events-resolver.ts
index 8c251309cb9..4b11e883e1d 100644
--- a/packages/twenty-apps/public/slack/src/logic-functions/slack-events-resolver.ts
+++ b/packages/twenty-apps/public/slack/src/logic-functions/slack-events-resolver.ts
@@ -12,9 +12,8 @@ import {
} from 'src/constants/universal-identifiers';
import { type SlackEventsRequestBody } from 'src/logic-functions/types/slack-events-request-body.type';
import { findClaimedWorkspaceId } from 'src/logic-functions/utils/find-claimed-workspace-id';
-import { getSlackWebhookSecret } from 'src/logic-functions/utils/get-slack-webhook-secret';
import { resolveTargetWorkspaceId } from 'src/logic-functions/utils/resolve-target-workspace-id';
-import { verifySlackRequestSignature } from 'src/logic-functions/utils/verify-slack-request-signature';
+import { verifySlackWebhookRequestOrThrow } from 'src/logic-functions/utils/verify-slack-webhook-request-or-throw';
type SlackEventsResolverResult =
| Response
@@ -27,28 +26,7 @@ type SlackEventsResolverResult =
export const slackEventsResolverHandler = async (
routePayload: RoutePayload<SlackEventsRequestBody>,
): Promise<SlackEventsResolverResult> => {
- const secretResult = getSlackWebhookSecret();
-
- if (!secretResult.success) {
- throw new Error(secretResult.error);
- }
-
- if (routePayload.rawBody === undefined) {
- throw new Error(
- 'Raw request body was not forwarded by the server; cannot verify the webhook signature',
- );
- }
-
- if (
- !verifySlackRequestSignature({
- rawBody: routePayload.rawBody,
- signatureHeader: routePayload.headers['x-slack-signature'],
- timestampHeader: routePayload.headers['x-slack-request-timestamp'],
- secret: secretResult.secret,
- })
- ) {
- throw new Error('Invalid Slack signature');
- }
+ verifySlackWebhookRequestOrThrow(routePayload);
const body = routePayload.body;
@@ -90,7 +68,7 @@ export const slackEventsResolverHandler = async (
}
return {
- workspaceId: await resolveTargetWorkspaceId(body),
+ workspaceId: await resolveTargetWorkspaceId(body.team_id),
targetLogicFunctionUniversalIdentifier,
payload: body,
};
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/slack-interactivity-resolver.ts b/packages/twenty-apps/public/slack/src/logic-functions/slack-interactivity-resolver.ts
new file mode 100644
index 00000000000..50a68e34830
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/slack-interactivity-resolver.ts
@@ -0,0 +1,16 @@
+import { defineLogicFunction } from 'twenty-sdk/define';
+
+import { SLACK_INTERACTIVITY_ROUTE_UNIVERSAL_IDENTIFIER } from 'src/constants/universal-identifiers';
+import { slackInteractivityResolverHandler } from 'src/logic-functions/handlers/slack-interactivity-resolver-handler';
+
+export default defineLogicFunction({
+ universalIdentifier: SLACK_INTERACTIVITY_ROUTE_UNIVERSAL_IDENTIFIER,
+ name: 'slack-interactivity-resolver',
+ description:
+ 'Receives Slack interactivity callbacks (block_actions), verifies the request signature in the owner workspace, acknowledges interactions it does not handle, and resolves the target workspace plus the function that stores the assistant answer feedback.',
+ timeoutSeconds: 15,
+ handler: slackInteractivityResolverHandler,
+ serverRouteTriggerSettings: {
+ forwardedRequestHeaders: ['x-slack-signature', 'x-slack-request-timestamp'],
+ },
+});
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/types/slack-assistant-feedback-rating.type.ts b/packages/twenty-apps/public/slack/src/logic-functions/types/slack-assistant-feedback-rating.type.ts
new file mode 100644
index 00000000000..ea2b7df8784
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/types/slack-assistant-feedback-rating.type.ts
@@ -0,0 +1,4 @@
+import { type SLACK_ASSISTANT_FEEDBACK_RATING } from 'src/logic-functions/constants/slack-assistant-feedback-rating';
+
+export type SlackAssistantFeedbackRating =
+ (typeof SLACK_ASSISTANT_FEEDBACK_RATING)[keyof typeof SLACK_ASSISTANT_FEEDBACK_RATING];
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/types/slack-assistant-feedback-result.type.ts b/packages/twenty-apps/public/slack/src/logic-functions/types/slack-assistant-feedback-result.type.ts
new file mode 100644
index 00000000000..f37b736ab60
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/types/slack-assistant-feedback-result.type.ts
@@ -0,0 +1,3 @@
+export type SlackAssistantFeedbackResult =
+ | { skipped: true; reason: string }
+ | { done: true };
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/types/slack-interactivity-payload.type.ts b/packages/twenty-apps/public/slack/src/logic-functions/types/slack-interactivity-payload.type.ts
new file mode 100644
index 00000000000..2abc089ee39
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/types/slack-interactivity-payload.type.ts
@@ -0,0 +1,15 @@
+type SlackInteractionTeam = {
+ id?: string;
+};
+
+type SlackInteractionAction = {
+ action_id?: string;
+ block_id?: string;
+ value?: string;
+};
+
+export type SlackInteractivityPayload = {
+ type?: string;
+ team?: SlackInteractionTeam;
+ actions?: SlackInteractionAction[];
+};
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/types/slack-interactivity-request-body.type.ts b/packages/twenty-apps/public/slack/src/logic-functions/types/slack-interactivity-request-body.type.ts
new file mode 100644
index 00000000000..4013a9c0c7c
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/types/slack-interactivity-request-body.type.ts
@@ -0,0 +1,4 @@
+// Slack posts interactivity callbacks form-encoded, with the JSON interaction payload in a single `payload` field
+export type SlackInteractivityRequestBody = {
+ payload?: string;
+};
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/utils/__tests__/build-slack-assistant-answer-blocks.test.ts b/packages/twenty-apps/public/slack/src/logic-functions/utils/__tests__/build-slack-assistant-answer-blocks.test.ts
index 585a1a1c6f4..d5aee162b1c 100644
--- a/packages/twenty-apps/public/slack/src/logic-functions/utils/__tests__/build-slack-assistant-answer-blocks.test.ts
+++ b/packages/twenty-apps/public/slack/src/logic-functions/utils/__tests__/build-slack-assistant-answer-blocks.test.ts
@@ -2,12 +2,15 @@ import { describe, expect, it } from 'vitest';
import { buildSlackAssistantAnswerBlocks } from 'src/logic-functions/utils/build-slack-assistant-answer-blocks';
+const REQUEST_ID = '3f77d0b1-30a1-4c3d-9d02-2f2a9f6f9d10';
+
describe('buildSlackAssistantAnswerBlocks', () => {
- it('should render the answer as a markdown block followed by a duration footer', () => {
+ it('should render the answer as a markdown block followed by a duration footer and feedback buttons', () => {
expect(
buildSlackAssistantAnswerBlocks({
responseText: 'All done.',
durationMilliseconds: 3000,
+ requestId: REQUEST_ID,
}),
).toEqual([
{ type: 'markdown', text: 'All done.' },
@@ -15,6 +18,28 @@ describe('buildSlackAssistantAnswerBlocks', () => {
type: 'context',
elements: [{ type: 'mrkdwn', text: 'Answered in 3s' }],
},
+ {
+ type: 'context_actions',
+ block_id: REQUEST_ID,
+ elements: [
+ {
+ type: 'feedback_buttons',
+ action_id: 'slack-assistant-feedback',
+ positive_button: {
+ text: { type: 'plain_text', text: 'Good response' },
+ accessibility_label:
+ 'Mark the assistant answer as a good response',
+ value: 'positive_feedback',
+ },
+ negative_button: {
+ text: { type: 'plain_text', text: 'Bad response' },
+ accessibility_label:
+ 'Mark the assistant answer as a bad response',
+ value: 'negative_feedback',
+ },
+ },
+ ],
+ },
]);
});
@@ -25,6 +50,7 @@ describe('buildSlackAssistantAnswerBlocks', () => {
const [markdownBlock] = buildSlackAssistantAnswerBlocks({
responseText,
durationMilliseconds: 1000,
+ requestId: REQUEST_ID,
});
expect(markdownBlock).toEqual({ type: 'markdown', text: responseText });
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/utils/__tests__/parse-slack-interactivity-payload-or-throw.test.ts b/packages/twenty-apps/public/slack/src/logic-functions/utils/__tests__/parse-slack-interactivity-payload-or-throw.test.ts
new file mode 100644
index 00000000000..652d55a25e3
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/utils/__tests__/parse-slack-interactivity-payload-or-throw.test.ts
@@ -0,0 +1,56 @@
+import { describe, expect, it } from 'vitest';
+
+import { parseSlackInteractivityPayloadOrThrow } from 'src/logic-functions/utils/parse-slack-interactivity-payload-or-throw';
+
+describe('parseSlackInteractivityPayloadOrThrow', () => {
+ it('should parse the JSON payload field of the form-encoded body', () => {
+ const payload = {
+ type: 'block_actions',
+ team: { id: 'T0123456789' },
+ actions: [
+ {
+ action_id: 'slack-assistant-feedback',
+ block_id: '3f77d0b1-30a1-4c3d-9d02-2f2a9f6f9d10',
+ value: 'positive_feedback',
+ },
+ ],
+ };
+
+ expect(
+ parseSlackInteractivityPayloadOrThrow({
+ payload: JSON.stringify(payload),
+ }),
+ ).toEqual(payload);
+ });
+
+ it('should throw when the body has no payload field', () => {
+ expect(() => parseSlackInteractivityPayloadOrThrow({})).toThrow(
+ 'Slack interactivity request has no payload field',
+ );
+ expect(() => parseSlackInteractivityPayloadOrThrow(null)).toThrow(
+ 'Slack interactivity request has no payload field',
+ );
+ });
+
+ it('should throw when the payload field is not valid JSON', () => {
+ expect(() =>
+ parseSlackInteractivityPayloadOrThrow({ payload: 'not-json' }),
+ ).toThrow('Slack interactivity payload is not valid JSON');
+ });
+
+ it('should throw when the payload JSON has an unexpected shape', () => {
+ expect(() =>
+ parseSlackInteractivityPayloadOrThrow({ payload: '"a string"' }),
+ ).toThrow('Slack interactivity payload has an unexpected shape');
+ expect(() =>
+ parseSlackInteractivityPayloadOrThrow({
+ payload: JSON.stringify({ type: 'block_actions', actions: 'no' }),
+ }),
+ ).toThrow('Slack interactivity payload has an unexpected shape');
+ expect(() =>
+ parseSlackInteractivityPayloadOrThrow({
+ payload: JSON.stringify({ team: { id: 42 } }),
+ }),
+ ).toThrow('Slack interactivity payload has an unexpected shape');
+ });
+});
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/utils/build-slack-assistant-answer-blocks.ts b/packages/twenty-apps/public/slack/src/logic-functions/utils/build-slack-assistant-answer-blocks.ts
index c197a194567..33dfcfc93c0 100644
--- a/packages/twenty-apps/public/slack/src/logic-functions/utils/build-slack-assistant-answer-blocks.ts
+++ b/packages/twenty-apps/public/slack/src/logic-functions/utils/build-slack-assistant-answer-blocks.ts
@@ -1,13 +1,17 @@
import { type KnownBlock } from '@slack/web-api';
+import { SLACK_ASSISTANT_FEEDBACK_ACTION_ID } from 'src/logic-functions/constants/slack-assistant-feedback-action-id';
+import { SLACK_ASSISTANT_FEEDBACK_BUTTON_VALUE } from 'src/logic-functions/constants/slack-assistant-feedback-button-value';
import { formatSlackAssistantDuration } from 'src/logic-functions/utils/format-slack-assistant-duration';
export const buildSlackAssistantAnswerBlocks = ({
responseText,
durationMilliseconds,
+ requestId,
}: {
responseText: string;
durationMilliseconds: number;
+ requestId: string;
}): KnownBlock[] => [
{ type: 'markdown', text: responseText },
{
@@ -19,4 +23,24 @@ export const buildSlackAssistantAnswerBlocks = ({
},
],
},
+ {
+ type: 'context_actions',
+ block_id: requestId,
+ elements: [
+ {
+ type: 'feedback_buttons',
+ action_id: SLACK_ASSISTANT_FEEDBACK_ACTION_ID,
+ positive_button: {
+ text: { type: 'plain_text', text: 'Good response' },
+ accessibility_label: 'Mark the assistant answer as a good response',
+ value: SLACK_ASSISTANT_FEEDBACK_BUTTON_VALUE.POSITIVE,
+ },
+ negative_button: {
+ text: { type: 'plain_text', text: 'Bad response' },
+ accessibility_label: 'Mark the assistant answer as a bad response',
+ value: SLACK_ASSISTANT_FEEDBACK_BUTTON_VALUE.NEGATIVE,
+ },
+ },
+ ],
+ },
];
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/utils/is-slack-interactivity-payload.ts b/packages/twenty-apps/public/slack/src/logic-functions/utils/is-slack-interactivity-payload.ts
new file mode 100644
index 00000000000..43c2af76261
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/utils/is-slack-interactivity-payload.ts
@@ -0,0 +1,32 @@
+import { isArray, isObject, isString, isUndefined } from '@sniptt/guards';
+
+import { type SlackInteractivityPayload } from 'src/logic-functions/types/slack-interactivity-payload.type';
+
+const isOptionalString = (value: unknown): value is string | undefined =>
+ isUndefined(value) || isString(value);
+
+const isTeam = (value: unknown): boolean =>
+ isUndefined(value) ||
+ (isObject<Record<string, unknown>, unknown>(value) &&
+ isOptionalString(value.id));
+
+const isInteractionAction = (value: unknown): boolean =>
+ isObject<Record<string, unknown>, unknown>(value) &&
+ isOptionalString(value.action_id) &&
+ isOptionalString(value.block_id) &&
+ isOptionalString(value.value);
+
+export const isSlackInteractivityPayload = (
+ value: unknown,
+): value is SlackInteractivityPayload => {
+ if (!isObject<Record<string, unknown>, unknown>(value)) {
+ return false;
+ }
+
+ return (
+ isOptionalString(value.type) &&
+ isTeam(value.team) &&
+ (isUndefined(value.actions) ||
+ (isArray(value.actions) && value.actions.every(isInteractionAction)))
+ );
+};
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/utils/parse-slack-assistant-feedback-rating.ts b/packages/twenty-apps/public/slack/src/logic-functions/utils/parse-slack-assistant-feedback-rating.ts
new file mode 100644
index 00000000000..7c374db2f33
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/utils/parse-slack-assistant-feedback-rating.ts
@@ -0,0 +1,16 @@
+import { SLACK_ASSISTANT_FEEDBACK_BUTTON_VALUE } from 'src/logic-functions/constants/slack-assistant-feedback-button-value';
+import { SLACK_ASSISTANT_FEEDBACK_RATING } from 'src/logic-functions/constants/slack-assistant-feedback-rating';
+import { type SlackAssistantFeedbackRating } from 'src/logic-functions/types/slack-assistant-feedback-rating.type';
+
+export const parseSlackAssistantFeedbackRating = (
+ buttonValue: string | undefined,
+): SlackAssistantFeedbackRating | undefined => {
+ switch (buttonValue) {
+ case SLACK_ASSISTANT_FEEDBACK_BUTTON_VALUE.POSITIVE:
+ return SLACK_ASSISTANT_FEEDBACK_RATING.POSITIVE;
+ case SLACK_ASSISTANT_FEEDBACK_BUTTON_VALUE.NEGATIVE:
+ return SLACK_ASSISTANT_FEEDBACK_RATING.NEGATIVE;
+ default:
+ return undefined;
+ }
+};
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/utils/parse-slack-interactivity-payload-or-throw.ts b/packages/twenty-apps/public/slack/src/logic-functions/utils/parse-slack-interactivity-payload-or-throw.ts
new file mode 100644
index 00000000000..1f0ac48deed
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/utils/parse-slack-interactivity-payload-or-throw.ts
@@ -0,0 +1,27 @@
+import { isNonEmptyString } from '@sniptt/guards';
+
+import { type SlackInteractivityPayload } from 'src/logic-functions/types/slack-interactivity-payload.type';
+import { type SlackInteractivityRequestBody } from 'src/logic-functions/types/slack-interactivity-request-body.type';
+import { isSlackInteractivityPayload } from 'src/logic-functions/utils/is-slack-interactivity-payload';
+
+export const parseSlackInteractivityPayloadOrThrow = (
+ body: SlackInteractivityRequestBody | null | undefined,
+): SlackInteractivityPayload => {
+ if (!isNonEmptyString(body?.payload)) {
+ throw new Error('Slack interactivity request has no payload field');
+ }
+
+ let parsedPayload: unknown;
+
+ try {
+ parsedPayload = JSON.parse(body.payload);
+ } catch {
+ throw new Error('Slack interactivity payload is not valid JSON');
+ }
+
+ if (!isSlackInteractivityPayload(parsedPayload)) {
+ throw new Error('Slack interactivity payload has an unexpected shape');
+ }
+
+ return parsedPayload;
+};
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/utils/resolve-target-workspace-id.ts b/packages/twenty-apps/public/slack/src/logic-functions/utils/resolve-target-workspace-id.ts
index b31cbe110ae..caac1ed1bc8 100644
--- a/packages/twenty-apps/public/slack/src/logic-functions/utils/resolve-target-workspace-id.ts
+++ b/packages/twenty-apps/public/slack/src/logic-functions/utils/resolve-target-workspace-id.ts
@@ -1,17 +1,14 @@
import { isNonEmptyString } from '@sniptt/guards';
import { isDefined } from 'twenty-sdk/utils';
-import { type SlackEventsRequestBody } from 'src/logic-functions/types/slack-events-request-body.type';
import { findClaimedWorkspaceId } from 'src/logic-functions/utils/find-claimed-workspace-id';
export const resolveTargetWorkspaceId = async (
- body: SlackEventsRequestBody,
+ teamId: string | undefined,
): Promise<string> => {
- const teamId = body.team_id;
-
if (!isNonEmptyString(teamId)) {
throw new Error(
- 'Slack event has no team_id; cannot resolve the target workspace',
+ 'Slack request has no team id; cannot resolve the target workspace',
);
}
diff --git a/packages/twenty-apps/public/slack/src/logic-functions/utils/verify-slack-webhook-request-or-throw.ts b/packages/twenty-apps/public/slack/src/logic-functions/utils/verify-slack-webhook-request-or-throw.ts
new file mode 100644
index 00000000000..2a4454acb05
--- /dev/null
+++ b/packages/twenty-apps/public/slack/src/logic-functions/utils/verify-slack-webhook-request-or-throw.ts
@@ -0,0 +1,32 @@
+import { type RoutePayload } from 'twenty-sdk/define';
+import { isDefined } from 'twenty-sdk/utils';
+
+import { getSlackWebhookSecret } from 'src/logic-functions/utils/get-slack-webhook-secret';
+import { verifySlackRequestSignature } from 'src/logic-functions/utils/verify-slack-request-signature';
+
+export const verifySlackWebhookRequestOrThrow = (
+ routePayload: RoutePayload<unknown>,
+): void => {
+ const secretResult = getSlackWebhookSecret();
+
+ if (!secretResult.success) {
+ throw new Error(secretResult.error);
+ }
+
+ if (!isDefined(routePayload.rawBody)) {
+ throw new Error(
+ 'Raw request body was not forwarded by the server; cannot verify the webhook signature',
+ );
+ }
+
+ const hasValidSignature = verifySlackRequestSignature({
+ rawBody: routePayload.rawBody,
+ signatureHeader: routePayload.headers['x-slack-signature'],
+ timestampHeader: routePayload.headers['x-slack-request-timestamp'],
+ secret: secretResult.secret,
+ });
+
+ if (!hasValidSignature) {
+ throw new Error('Invalid Slack signature');
+ }
+};
diff --git a/packages/twenty-apps/public/slack/src/objects/slack-assistant-request.object.ts b/packages/twenty-apps/public/slack/src/objects/slack-assistant-request.object.ts
index 8b5a36560b3..617ff25131b 100644
--- a/packages/twenty-apps/public/slack/src/objects/slack-assistant-request.object.ts
+++ b/packages/twenty-apps/public/slack/src/objects/slack-assistant-request.object.ts
@@ -11,6 +11,7 @@ import {
SLACK_ASSISTANT_REQUEST_CHANNEL_TYPE_FIELD_UNIVERSAL_IDENTIFIER,
SLACK_ASSISTANT_REQUEST_ERROR_FIELD_UNIVERSAL_IDENTIFIER,
SLACK_ASSISTANT_REQUEST_EVENT_ID_FIELD_UNIVERSAL_IDENTIFIER,
+ SLACK_ASSISTANT_REQUEST_FEEDBACK_RATING_FIELD_UNIVERSAL_IDENTIFIER,
SLACK_ASSISTANT_REQUEST_MESSAGE_TS_FIELD_UNIVERSAL_IDENTIFIER,
SLACK_ASSISTANT_REQUEST_NAME_FIELD_UNIVERSAL_IDENTIFIER,
SLACK_ASSISTANT_REQUEST_OBJECT_UNIVERSAL_IDENTIFIER,
@@ -22,6 +23,7 @@ import {
SLACK_ASSISTANT_REQUEST_WORKSPACE_MEMBER_FIELD_UNIVERSAL_IDENTIFIER,
SLACK_ASSISTANT_REQUESTS_ON_WORKSPACE_MEMBER_FIELD_UNIVERSAL_IDENTIFIER,
} from 'src/constants/universal-identifiers';
+import { SLACK_ASSISTANT_FEEDBACK_RATING } from 'src/logic-functions/constants/slack-assistant-feedback-rating';
import { SLACK_ASSISTANT_REQUEST_STATUS } from 'src/logic-functions/constants/slack-assistant-request-status';
export default defineObject({
@@ -184,5 +186,31 @@ export default defineObject({
icon: 'IconAlertTriangle',
name: 'errorMessage',
},
+ {
+ universalIdentifier:
+ SLACK_ASSISTANT_REQUEST_FEEDBACK_RATING_FIELD_UNIVERSAL_IDENTIFIER,
+ type: FieldType.SELECT,
+ label: 'Feedback',
+ description:
+ 'Rating left with the feedback buttons under the assistant answer in Slack',
+ icon: 'IconThumbUp',
+ options: [
+ {
+ id: 'effdd5a6-73f1-48ba-992c-bf0638015301',
+ value: SLACK_ASSISTANT_FEEDBACK_RATING.POSITIVE,
+ label: 'Positive',
+ position: 0,
+ color: 'green',
+ },
+ {
+ id: '0332a188-533d-4709-8f02-340e294e94f6',
+ value: SLACK_ASSISTANT_FEEDBACK_RATING.NEGATIVE,
+ label: 'Negative',
+ position: 1,
+ color: 'red',
+ },
+ ],
+ name: 'feedbackRating',
+ },
],
});
diff --git a/packages/twenty-server/src/engine/core-modules/server-route-trigger/server-route-trigger.service.ts b/packages/twenty-server/src/engine/core-modules/server-route-trigger/server-route-trigger.service.ts
index e56b49f846b..495a36e8dd2 100644
--- a/packages/twenty-server/src/engine/core-modules/server-route-trigger/server-route-trigger.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/server-route-trigger/server-route-trigger.service.ts
@@ -173,7 +173,7 @@ export class ServerRouteTriggerService {
{ retryLimit: QUEUED_TARGET_RETRY_LIMIT },
);
- return { statusCode: 202, headers: {}, body: { queued: true } };
+ return { statusCode: 200, headers: {}, body: { queued: true } };
}
private async findLogicFunctionOrFail({
diff --git a/packages/twenty-server/test/integration/server-route-trigger/suites/server-route-trigger-authorization.integration-spec.ts b/packages/twenty-server/test/integration/server-route-trigger/suites/server-route-trigger-authorization.integration-spec.ts
index c20217982b9..d9c38ba42b8 100644
--- a/packages/twenty-server/test/integration/server-route-trigger/suites/server-route-trigger-authorization.integration-spec.ts
+++ b/packages/twenty-server/test/integration/server-route-trigger/suites/server-route-trigger-authorization.integration-spec.ts
@@ -189,12 +189,12 @@ describe('ServerRouteTrigger authorization (integration)', () => {
});
});
- it('dispatches a server-route-exposed resolver, queues the target, and acks with 202', async () => {
+ it('dispatches a server-route-exposed resolver, queues the target, and acks with 200', async () => {
const response = await request(baseUrl)
.post(`/webhooks/server/${EXPOSED_RESOLVER_UNIVERSAL_IDENTIFIER}`)
.send({ any: 'payload' });
- expect(response.status).toBe(202);
+ expect(response.status).toBe(200);
expect(response.body).toEqual({ queued: true });
}, 60000);