Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,15 @@ function FileUploadSyncWrapper({
)
}

function ChannelSelectorSyncWrapper({
function SlackSelectorSyncWrapper({
blockId,
paramId,
value,
onChange,
uiComponent,
disabled,
previewContextValues,
selectorType,
}: {
blockId: string
paramId: string
Expand All @@ -573,14 +574,15 @@ function ChannelSelectorSyncWrapper({
uiComponent: any
disabled: boolean
previewContextValues?: Record<string, any>
selectorType: 'channel-selector' | 'user-selector'
}) {
return (
<GenericSyncWrapper blockId={blockId} paramId={paramId} value={value} onChange={onChange}>
<SlackSelectorInput
blockId={blockId}
subBlock={{
id: paramId,
type: 'channel-selector' as const,
type: selectorType,
title: paramId,
serviceId: uiComponent.serviceId,
placeholder: uiComponent.placeholder,
Expand Down Expand Up @@ -1952,14 +1954,29 @@ export function ToolInput({

case 'channel-selector':
return (
<ChannelSelectorSyncWrapper
<SlackSelectorSyncWrapper
blockId={blockId}
paramId={param.id}
value={value}
onChange={onChange}
uiComponent={uiComponent}
disabled={disabled}
previewContextValues={currentToolParams as any}
selectorType='channel-selector'
/>
)

case 'user-selector':
return (
<SlackSelectorSyncWrapper
blockId={blockId}
paramId={param.id}
value={value}
onChange={onChange}
uiComponent={uiComponent}
disabled={disabled}
previewContextValues={currentToolParams as any}
selectorType='user-selector'
/>
)

Expand Down
2 changes: 1 addition & 1 deletion apps/sim/lib/environment/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export async function ensureBlockEnvVarsResolvable(
options: { requestId?: string } = {}
): Promise<void> {
const requestId = options.requestId
const envVarPattern = createEnvVarPattern()
await Promise.all(
Object.values(blocks).map(async (block) => {
const subBlocks = block.subBlocks ?? {}
Expand All @@ -157,7 +158,6 @@ export async function ensureBlockEnvVarsResolvable(
return
}

const envVarPattern = createEnvVarPattern()
const matches = value.match(envVarPattern)
if (!matches) {
return
Expand Down
15 changes: 11 additions & 4 deletions apps/sim/tools/slack/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export const slackMessageTool: ToolConfig<SlackMessageParams, SlackMessageRespon
visibility: 'user-only',
description: 'Authentication method: oauth or bot_token',
},
destinationType: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Destination type: channel or dm',
},
botToken: {
type: 'string',
required: false,
Expand All @@ -38,11 +44,11 @@ export const slackMessageTool: ToolConfig<SlackMessageParams, SlackMessageRespon
visibility: 'user-only',
description: 'Target Slack channel (e.g., #general)',
},
userId: {
dmUserId: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Target Slack user ID for direct messages (e.g., U1234567890)',
description: 'Target Slack user for direct messages',
},
text: {
type: 'string',
Expand Down Expand Up @@ -71,10 +77,11 @@ export const slackMessageTool: ToolConfig<SlackMessageParams, SlackMessageRespon
'Content-Type': 'application/json',
}),
body: (params: SlackMessageParams) => {
const isDM = params.destinationType === 'dm'
return {
accessToken: params.accessToken || params.botToken,
channel: params.channel,
userId: params.userId,
channel: isDM ? undefined : params.channel,
userId: isDM ? params.dmUserId : params.userId,
text: params.text,
thread_ts: params.thread_ts || undefined,
files: params.files || null,
Expand Down
29 changes: 19 additions & 10 deletions apps/sim/tools/slack/message_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export const slackMessageReaderTool: ToolConfig<
visibility: 'user-only',
description: 'Authentication method: oauth or bot_token',
},
destinationType: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Destination type: channel or dm',
},
botToken: {
type: 'string',
required: false,
Expand All @@ -41,11 +47,11 @@ export const slackMessageReaderTool: ToolConfig<
visibility: 'user-only',
description: 'Slack channel to read messages from (e.g., #general)',
},
userId: {
dmUserId: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'User ID for DM conversation (e.g., U1234567890)',
description: 'Target Slack user for DM conversation',
},
limit: {
type: 'number',
Expand Down Expand Up @@ -73,14 +79,17 @@ export const slackMessageReaderTool: ToolConfig<
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params: SlackMessageReaderParams) => ({
accessToken: params.accessToken || params.botToken,
channel: params.channel,
userId: params.userId,
limit: params.limit,
oldest: params.oldest,
latest: params.latest,
}),
body: (params: SlackMessageReaderParams) => {
const isDM = params.destinationType === 'dm'
return {
accessToken: params.accessToken || params.botToken,
channel: isDM ? undefined : params.channel,
userId: isDM ? params.dmUserId : params.userId,
limit: params.limit,
oldest: params.oldest,
latest: params.latest,
}
},
},

transformResponse: async (response: Response) => {
Expand Down
4 changes: 4 additions & 0 deletions apps/sim/tools/slack/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export interface SlackBaseParams {
}

export interface SlackMessageParams extends SlackBaseParams {
destinationType?: 'channel' | 'dm'
channel?: string
dmUserId?: string
userId?: string
text: string
thread_ts?: string
Expand All @@ -22,7 +24,9 @@ export interface SlackCanvasParams extends SlackBaseParams {
}

export interface SlackMessageReaderParams extends SlackBaseParams {
destinationType?: 'channel' | 'dm'
channel?: string
dmUserId?: string
userId?: string
limit?: number
oldest?: string
Expand Down