From 7a4efbb03016fa7701d3fb26daa3763bcf315931 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 16 Feb 2026 14:14:22 -0500 Subject: [PATCH] Slack: capture workflow button interaction metadata --- src/slack/monitor/events/interactions.test.ts | 47 +++++++++++++++++++ src/slack/monitor/events/interactions.ts | 8 ++++ 2 files changed, 55 insertions(+) diff --git a/src/slack/monitor/events/interactions.test.ts b/src/slack/monitor/events/interactions.test.ts index 23fede27927..b21ab2fb95b 100644 --- a/src/slack/monitor/events/interactions.test.ts +++ b/src/slack/monitor/events/interactions.test.ts @@ -596,6 +596,53 @@ describe("registerSlackInteractionEvents", () => { expect(payload.selectedDateTime).toBe(1_771_700_200); }); + it("captures workflow button trigger metadata", async () => { + enqueueSystemEventMock.mockReset(); + const { ctx, getHandler } = createContext(); + registerSlackInteractionEvents({ ctx: ctx as never }); + const handler = getHandler(); + expect(handler).toBeTruthy(); + + const ack = vi.fn().mockResolvedValue(undefined); + await handler!({ + ack, + body: { + user: { id: "U420" }, + team: { id: "T420" }, + channel: { id: "C420" }, + message: { ts: "420.420" }, + }, + action: { + type: "workflow_button", + action_id: "openclaw:workflow", + block_id: "workflow_block", + text: { type: "plain_text", text: "Launch workflow" }, + workflow: { + trigger_url: "https://slack.com/workflows/triggers/T420/12345", + workflow_id: "Wf12345", + }, + }, + }); + + expect(ack).toHaveBeenCalled(); + expect(enqueueSystemEventMock).toHaveBeenCalledTimes(1); + const [eventText] = enqueueSystemEventMock.mock.calls[0] as [string]; + const payload = JSON.parse(eventText.replace("Slack interaction: ", "")) as { + actionType?: string; + workflowTriggerUrl?: string; + workflowId?: string; + teamId?: string; + channelId?: string; + }; + expect(payload).toMatchObject({ + actionType: "workflow_button", + workflowTriggerUrl: "https://slack.com/workflows/triggers/T420/12345", + workflowId: "Wf12345", + teamId: "T420", + channelId: "C420", + }); + }); + it("captures modal submissions and enqueues view submission event", async () => { enqueueSystemEventMock.mockReset(); const { ctx, getViewHandler, resolveSessionKey } = createContext(); diff --git a/src/slack/monitor/events/interactions.ts b/src/slack/monitor/events/interactions.ts index d1c050c1b01..a865f8452f1 100644 --- a/src/slack/monitor/events/interactions.ts +++ b/src/slack/monitor/events/interactions.ts @@ -43,6 +43,8 @@ type InteractionSummary = { teamId?: string; triggerId?: string; responseUrl?: string; + workflowTriggerUrl?: string; + workflowId?: string; channelId?: string; messageTs?: string; threadTs?: string; @@ -165,6 +167,10 @@ function summarizeAction( selected_date_time?: number; value?: string; rich_text_value?: unknown; + workflow?: { + trigger_url?: string; + workflow_id?: string; + }; }; const actionType = typed.type; const selectedUsers = uniqueNonEmptyStrings([ @@ -239,6 +245,8 @@ function summarizeAction( inputUrl, richTextValue, richTextPreview, + workflowTriggerUrl: typed.workflow?.trigger_url, + workflowId: typed.workflow?.workflow_id, }; }