Skip to content

Commit fd23220

Browse files
fix(slack): tool params should be in line with block (#2860)
* env var pattern outside loop * fix(slack): tool params should line up with block * remove comments
1 parent a8d8109 commit fd23220

File tree

5 files changed

+55
-18
lines changed

5 files changed

+55
-18
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,14 +557,15 @@ function FileUploadSyncWrapper({
557557
)
558558
}
559559

560-
function ChannelSelectorSyncWrapper({
560+
function SlackSelectorSyncWrapper({
561561
blockId,
562562
paramId,
563563
value,
564564
onChange,
565565
uiComponent,
566566
disabled,
567567
previewContextValues,
568+
selectorType,
568569
}: {
569570
blockId: string
570571
paramId: string
@@ -573,14 +574,15 @@ function ChannelSelectorSyncWrapper({
573574
uiComponent: any
574575
disabled: boolean
575576
previewContextValues?: Record<string, any>
577+
selectorType: 'channel-selector' | 'user-selector'
576578
}) {
577579
return (
578580
<GenericSyncWrapper blockId={blockId} paramId={paramId} value={value} onChange={onChange}>
579581
<SlackSelectorInput
580582
blockId={blockId}
581583
subBlock={{
582584
id: paramId,
583-
type: 'channel-selector' as const,
585+
type: selectorType,
584586
title: paramId,
585587
serviceId: uiComponent.serviceId,
586588
placeholder: uiComponent.placeholder,
@@ -1952,14 +1954,29 @@ export function ToolInput({
19521954

19531955
case 'channel-selector':
19541956
return (
1955-
<ChannelSelectorSyncWrapper
1957+
<SlackSelectorSyncWrapper
19561958
blockId={blockId}
19571959
paramId={param.id}
19581960
value={value}
19591961
onChange={onChange}
19601962
uiComponent={uiComponent}
19611963
disabled={disabled}
19621964
previewContextValues={currentToolParams as any}
1965+
selectorType='channel-selector'
1966+
/>
1967+
)
1968+
1969+
case 'user-selector':
1970+
return (
1971+
<SlackSelectorSyncWrapper
1972+
blockId={blockId}
1973+
paramId={param.id}
1974+
value={value}
1975+
onChange={onChange}
1976+
uiComponent={uiComponent}
1977+
disabled={disabled}
1978+
previewContextValues={currentToolParams as any}
1979+
selectorType='user-selector'
19631980
/>
19641981
)
19651982

apps/sim/lib/environment/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export async function ensureBlockEnvVarsResolvable(
143143
options: { requestId?: string } = {}
144144
): Promise<void> {
145145
const requestId = options.requestId
146+
const envVarPattern = createEnvVarPattern()
146147
await Promise.all(
147148
Object.values(blocks).map(async (block) => {
148149
const subBlocks = block.subBlocks ?? {}
@@ -157,7 +158,6 @@ export async function ensureBlockEnvVarsResolvable(
157158
return
158159
}
159160

160-
const envVarPattern = createEnvVarPattern()
161161
const matches = value.match(envVarPattern)
162162
if (!matches) {
163163
return

apps/sim/tools/slack/message.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ export const slackMessageTool: ToolConfig<SlackMessageParams, SlackMessageRespon
2020
visibility: 'user-only',
2121
description: 'Authentication method: oauth or bot_token',
2222
},
23+
destinationType: {
24+
type: 'string',
25+
required: false,
26+
visibility: 'user-only',
27+
description: 'Destination type: channel or dm',
28+
},
2329
botToken: {
2430
type: 'string',
2531
required: false,
@@ -38,11 +44,11 @@ export const slackMessageTool: ToolConfig<SlackMessageParams, SlackMessageRespon
3844
visibility: 'user-only',
3945
description: 'Target Slack channel (e.g., #general)',
4046
},
41-
userId: {
47+
dmUserId: {
4248
type: 'string',
4349
required: false,
4450
visibility: 'user-only',
45-
description: 'Target Slack user ID for direct messages (e.g., U1234567890)',
51+
description: 'Target Slack user for direct messages',
4652
},
4753
text: {
4854
type: 'string',
@@ -71,10 +77,11 @@ export const slackMessageTool: ToolConfig<SlackMessageParams, SlackMessageRespon
7177
'Content-Type': 'application/json',
7278
}),
7379
body: (params: SlackMessageParams) => {
80+
const isDM = params.destinationType === 'dm'
7481
return {
7582
accessToken: params.accessToken || params.botToken,
76-
channel: params.channel,
77-
userId: params.userId,
83+
channel: isDM ? undefined : params.channel,
84+
userId: isDM ? params.dmUserId : params.userId,
7885
text: params.text,
7986
thread_ts: params.thread_ts || undefined,
8087
files: params.files || null,

apps/sim/tools/slack/message_reader.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ export const slackMessageReaderTool: ToolConfig<
2323
visibility: 'user-only',
2424
description: 'Authentication method: oauth or bot_token',
2525
},
26+
destinationType: {
27+
type: 'string',
28+
required: false,
29+
visibility: 'user-only',
30+
description: 'Destination type: channel or dm',
31+
},
2632
botToken: {
2733
type: 'string',
2834
required: false,
@@ -41,11 +47,11 @@ export const slackMessageReaderTool: ToolConfig<
4147
visibility: 'user-only',
4248
description: 'Slack channel to read messages from (e.g., #general)',
4349
},
44-
userId: {
50+
dmUserId: {
4551
type: 'string',
4652
required: false,
4753
visibility: 'user-only',
48-
description: 'User ID for DM conversation (e.g., U1234567890)',
54+
description: 'Target Slack user for DM conversation',
4955
},
5056
limit: {
5157
type: 'number',
@@ -73,14 +79,17 @@ export const slackMessageReaderTool: ToolConfig<
7379
headers: () => ({
7480
'Content-Type': 'application/json',
7581
}),
76-
body: (params: SlackMessageReaderParams) => ({
77-
accessToken: params.accessToken || params.botToken,
78-
channel: params.channel,
79-
userId: params.userId,
80-
limit: params.limit,
81-
oldest: params.oldest,
82-
latest: params.latest,
83-
}),
82+
body: (params: SlackMessageReaderParams) => {
83+
const isDM = params.destinationType === 'dm'
84+
return {
85+
accessToken: params.accessToken || params.botToken,
86+
channel: isDM ? undefined : params.channel,
87+
userId: isDM ? params.dmUserId : params.userId,
88+
limit: params.limit,
89+
oldest: params.oldest,
90+
latest: params.latest,
91+
}
92+
},
8493
},
8594

8695
transformResponse: async (response: Response) => {

apps/sim/tools/slack/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export interface SlackBaseParams {
77
}
88

99
export interface SlackMessageParams extends SlackBaseParams {
10+
destinationType?: 'channel' | 'dm'
1011
channel?: string
12+
dmUserId?: string
1113
userId?: string
1214
text: string
1315
thread_ts?: string
@@ -22,7 +24,9 @@ export interface SlackCanvasParams extends SlackBaseParams {
2224
}
2325

2426
export interface SlackMessageReaderParams extends SlackBaseParams {
27+
destinationType?: 'channel' | 'dm'
2528
channel?: string
29+
dmUserId?: string
2630
userId?: string
2731
limit?: number
2832
oldest?: string

0 commit comments

Comments
 (0)