Skip to content

Commit 1318c93

Browse files
fix(slack): finalize agent session streaming
1 parent 254e734 commit 1318c93

26 files changed

Lines changed: 410 additions & 1225 deletions

‎apps/docs/content/docs/integrations/slack.mdx‎

Lines changed: 6 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -909,90 +909,6 @@ Rename the Slack agent session associated with a thread.
909909
| `ok` | boolean | Whether Slack renamed the agent session |
910910
| `title` | string | Updated agent session title |
911911

912-
### Slack Start Stream
913-
914-
Start a streaming Slack message using Markdown or structured chunks.
915-
916-
#### Input
917-
918-
| Parameter | Type | Required | Description |
919-
| --------- | ---- | -------- | ----------- |
920-
| `authMethod` | string | No | Slack authentication method |
921-
| `botToken` | string | No | Custom Slack bot token |
922-
| `channel` | string | Yes | Channel ID where Slack should create the streaming message |
923-
| `markdownText` | string | No | Initial Markdown content, mutually exclusive with chunks |
924-
| `chunks` | json | No | Initial structured Slack streaming chunks, mutually exclusive with Markdown |
925-
| `threadTs` | string | No | Parent thread timestamp when streaming a reply |
926-
| `recipientUserId` | string | No | Recipient user ID, required with Recipient Team ID when channel is not a DM |
927-
| `recipientTeamId` | string | No | Recipient workspace ID, required with Recipient User ID when channel is not a DM |
928-
| `taskDisplayMode` | string | No | Task display mode: timeline or plan |
929-
| `iconEmoji` | string | No | Emoji used to customize the streaming agent identity |
930-
| `iconUrl` | string | No | Image URL used to customize the streaming agent identity |
931-
| `username` | string | No | Display name used to customize the streaming agent identity |
932-
933-
#### Output
934-
935-
| Parameter | Type | Description |
936-
| --------- | ---- | ----------- |
937-
| `ok` | boolean | Whether Slack started the stream |
938-
| `channel` | string | Channel containing the streaming message |
939-
| `ts` | string | Timestamp used to append to or stop the stream |
940-
941-
### Slack Append Stream
942-
943-
Append Markdown or structured chunks to an active Slack stream.
944-
945-
#### Input
946-
947-
| Parameter | Type | Required | Description |
948-
| --------- | ---- | -------- | ----------- |
949-
| `authMethod` | string | No | Slack authentication method |
950-
| `botToken` | string | No | Custom Slack bot token |
951-
| `channel` | string | Yes | Channel containing the streaming message |
952-
| `ts` | string | Yes | Timestamp returned by Start Stream |
953-
| `markdownText` | string | No | Markdown content to append; provide this or chunks, but not both |
954-
| `chunks` | json | No | Structured Slack streaming chunks; provide this or Markdown Text, but not both |
955-
956-
#### Output
957-
958-
| Parameter | Type | Description |
959-
| --------- | ---- | ----------- |
960-
| `ok` | boolean | Whether Slack appended the stream content |
961-
| `channel` | string | Channel containing the streaming message |
962-
| `ts` | string | Streaming message timestamp |
963-
964-
### Slack Stop Stream
965-
966-
Finalize an active Slack stream and return the resulting message.
967-
968-
#### Input
969-
970-
| Parameter | Type | Required | Description |
971-
| --------- | ---- | -------- | ----------- |
972-
| `authMethod` | string | No | Slack authentication method |
973-
| `botToken` | string | No | Custom Slack bot token |
974-
| `channel` | string | Yes | Channel containing the streaming message |
975-
| `ts` | string | Yes | Timestamp returned by Start Stream |
976-
| `markdownText` | string | No | Final Markdown content, mutually exclusive with chunks |
977-
| `chunks` | json | No | Final structured Slack chunks, mutually exclusive with Markdown |
978-
| `blocks` | json | No | Final Block Kit blocks, as an array of up to 50 block objects |
979-
| `metadata` | json | No | Message metadata containing event_type and event_payload |
980-
| `sessionStatus` | string | No | Final agent session state: active, processing, suspended, or closed |
981-
982-
#### Output
983-
984-
| Parameter | Type | Description |
985-
| --------- | ---- | ----------- |
986-
| `ok` | boolean | Whether Slack finalized the stream |
987-
| `channel` | string | Channel containing the finalized message |
988-
| `ts` | string | Finalized streaming message timestamp |
989-
| `message` | object | Final Slack message returned by chat.stopStream |
990-
| ↳ `text` | string | Final message text |
991-
| ↳ `bot_id` | string | Bot ID, or null when Slack omits it |
992-
| ↳ `ts` | string | Message timestamp |
993-
| ↳ `type` | string | Message type |
994-
| ↳ `subtype` | string | Message subtype, or null when the message has no subtype |
995-
996912
### Slack List Channels
997913

998914
List all channels in a Slack workspace. Returns public and private channels the bot has access to.
@@ -2005,16 +1921,16 @@ Trigger from Slack events (mentions, messages, reactions)
20051921
| `eventType` | string | Yes | The single Slack event this trigger fires on. Add another trigger block for another event. |
20061922
| `customBotCredential` | string | Yes | Choose a custom Slack bot you set up once and reuse across triggers. |
20071923
| `manualBotCredential` | string | Yes | Set the custom bot credential ID directly. |
2008-
| `streamResponse` | boolean | No | Stream selected workflow outputs into the Slack conversation that started this run. Custom bots only. |
2009-
| `streamOutputs` | workflow-output-selector | No | Each selected block invocation creates its own Slack response. Agent outputs stream live; other outputs are sent when the block completes. |
2010-
| `streamIncludeThinking` | boolean | No | Show agent thinking as Slack task updates while the response is generated. |
2011-
| `streamTaskTitle` | string | No | The status Slack shows while each selected response is being produced. |
2012-
| `streamIncludeToolCalls` | boolean | No | Show tool execution lifecycle as Slack task updates. |
2013-
| `streamTaskDisplayMode` | string | No | Choose how Slack displays thinking and tool progress. |
20141924
| `source` | string | No | Restrict to direct messages, public channels, or private channels. Leave empty to match any. |
20151925
| `channelFilter` | channel-selector | No | Restrict to specific channels. Leave empty to trigger on any channel the bot has been added to. |
20161926
| `manualChannelFilter` | string | No | Comma-separated channel IDs to restrict to. Set IDs directly here. |
20171927
| `threads` | string | No | Include thread replies, exclude them \(top-level only\), or fire only on thread replies. |
1928+
| `streamResponse` | boolean | No | Create a Slack agent session and stream selected workflow outputs into the conversation that started this run. Custom bots only. |
1929+
| `streamOutputs` | workflow-output-selector | No | Each selected block invocation creates its own Slack response. Agent outputs stream live; other outputs are sent when the block completes. |
1930+
| `streamTaskTitle` | string | No | Optional status Slack shows while each selected response is being produced. Leave empty to use Running. |
1931+
| `streamTaskDisplayMode` | string | No | Choose how Slack displays thinking and tool progress. |
1932+
| `streamIncludeThinking` | boolean | No | Show agent thinking as Slack task updates while the response is generated. |
1933+
| `streamIncludeToolCalls` | boolean | No | Show tool execution lifecycle as Slack task updates. |
20181934
| `emoji` | string | No | Comma-separated emoji names to restrict to. Leave empty to match any emoji. |
20191935
| `nameContains` | string | No | Only fire when the created channel name contains this text. |
20201936
| `interactionFilter` | string | No | Comma-separated action_ids \(buttons/selects\) or callback_ids \(modals\) to restrict to. Leave empty to fire on any interaction. |

‎apps/sim/blocks/blocks/slack.test.ts‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,11 @@ const AGENT_OPERATION_IDS = [
1414
'set_suggested_prompts',
1515
'set_agent_session_status',
1616
'rename_agent_session',
17-
'start_stream',
18-
'append_stream',
19-
'stop_stream',
2017
]
2118
const AGENT_TOOL_IDS = [
2219
'slack_set_suggested_prompts_v2',
2320
'slack_set_agent_session_status_v2',
2421
'slack_rename_agent_session_v2',
25-
'slack_start_stream_v2',
26-
'slack_append_stream_v2',
27-
'slack_stop_stream_v2',
2822
]
2923

3024
function operationIds(): string[] {
@@ -98,29 +92,29 @@ describe('Slack block release', () => {
9892
})
9993
})
10094

101-
it('uses the service-account tool and active content mode for new agent operations', () => {
95+
it('uses service-account tools for new agent operations', () => {
10296
const selectTool = SlackV2Block.tools.config?.tool
10397
if (!selectTool) throw new Error('Slack v2 tool selector is required')
10498

10599
expect(
106100
selectTool({ operation: 'set_suggested_prompts', agentCredentialId: 'custom-bot' })
107101
).toBe('slack_set_suggested_prompts_v2')
102+
expect(selectTool({ operation: 'set_agent_session_status' })).toBe(
103+
'slack_set_agent_session_status_v2'
104+
)
108105

109106
const mapped = mapSlackV2Params({
110-
operation: 'append_stream',
107+
operation: 'set_agent_session_status',
111108
agentCredentialId: 'custom-bot',
112109
agentChannelId: 'C123',
113-
streamTs: '1700000000.000001',
114-
streamContentMode: 'markdown',
115-
streamMarkdownText: 'Current content',
116-
streamChunks: [{ type: 'markdown_text', text: 'Stale content' }],
110+
agentThreadTs: '1700000000.000001',
111+
agentSessionStatus: 'processing',
117112
})
118113
expect(mapped).toMatchObject({
119114
credential: 'custom-bot',
120115
channel: 'C123',
121-
ts: '1700000000.000001',
122-
markdownText: 'Current content',
116+
threadTs: '1700000000.000001',
117+
status: 'processing',
123118
})
124-
expect(mapped.chunks).toBeUndefined()
125119
})
126120
})

0 commit comments

Comments
 (0)