Skip to content

Commit a922946

Browse files
fix(slack): preserve agent workflow compatibility
1 parent 545a0a6 commit a922946

4 files changed

Lines changed: 41 additions & 3 deletions

File tree

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ function operationIds(): string[] {
3232
return operation?.options?.map((option) => option.id) ?? []
3333
}
3434

35+
function mapSlackV2Params(params: Record<string, unknown>): Record<string, unknown> {
36+
const mapParams = SlackV2Block.tools.config?.params
37+
if (!mapParams) throw new Error('Slack v2 parameter mapper is required')
38+
return mapParams(params)
39+
}
40+
3541
describe('Slack block release', () => {
3642
it('releases slack_v2 and keeps the legacy block executable but hidden', () => {
3743
expect(SlackBlock.hideFromToolbar).toBe(true)
@@ -63,4 +69,23 @@ describe('Slack block release', () => {
6369
required: true,
6470
})
6571
})
72+
73+
it('preserves persisted suggested-prompt inputs while requiring the custom-bot tool', () => {
74+
expect(
75+
mapSlackV2Params({
76+
operation: 'set_suggested_prompts',
77+
oauthCredential: 'custom-bot-credential',
78+
channel: 'C123',
79+
getThreadTimestamp: '1700000000.000001',
80+
suggestedPrompts: '[{"title":"Summarize","message":"Summarize this thread"}]',
81+
promptsTitle: 'Try asking',
82+
})
83+
).toMatchObject({
84+
credential: 'custom-bot-credential',
85+
channel: 'C123',
86+
threadTs: '1700000000.000001',
87+
prompts: '[{"title":"Summarize","message":"Summarize this thread"}]',
88+
promptsTitle: 'Try asking',
89+
})
90+
})
6691
})

apps/sim/blocks/blocks/slack.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3512,11 +3512,20 @@ export const SlackV2Block: BlockConfig<SlackResponse> = {
35123512
const baseParams = mapParams(params)
35133513
if (!SLACK_V2_AGENT_OPERATIONS.includes(params.operation as never)) return baseParams
35143514

3515+
const persistedSuggestedPromptParams =
3516+
params.operation === 'set_suggested_prompts'
3517+
? {
3518+
credential: baseParams.credential,
3519+
channel: baseParams.channel,
3520+
threadTs: baseParams.threadTs,
3521+
}
3522+
: undefined
3523+
35153524
return {
35163525
...baseParams,
3517-
credential: params.agentCredentialId,
3518-
channel: params.agentChannelId,
3519-
threadTs: params.agentThreadTs,
3526+
credential: params.agentCredentialId ?? persistedSuggestedPromptParams?.credential,
3527+
channel: params.agentChannelId ?? persistedSuggestedPromptParams?.channel,
3528+
threadTs: params.agentThreadTs ?? persistedSuggestedPromptParams?.threadTs,
35203529
status: params.agentSessionStatus,
35213530
title: params.agentSessionTitle,
35223531
initiatorUserId: params.agentInitiatorUserId,

apps/sim/triggers/slack/capabilities.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const REQUIRED_AGENT_EVENTS = [
2222
'agent_session_title_changed',
2323
'app_context_changed',
2424
'app_home_opened',
25+
'assistant_thread_context_changed',
26+
'assistant_thread_started',
2527
'message.im',
2628
]
2729

apps/sim/triggers/slack/capabilities.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ export const SLACK_AGENT_EVENTS = [
208208
'agent_session_title_changed',
209209
'app_context_changed',
210210
'app_home_opened',
211+
'assistant_thread_context_changed',
212+
'assistant_thread_started',
211213
'message.im',
212214
] as const
213215

0 commit comments

Comments
 (0)