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
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
provenance: false
sbom: false
no-cache: true

# Build ARM64 images for GHCR (main branch only, runs in parallel)
build-ghcr-arm64:
Expand Down Expand Up @@ -205,7 +204,6 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
provenance: false
sbom: false
no-cache: true

# Create GHCR multi-arch manifests (only for main, after both builds)
create-ghcr-manifests:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
provenance: false
sbom: false
no-cache: true

build-ghcr-arm64:
name: Build ARM64 (GHCR Only)
Expand Down Expand Up @@ -144,11 +143,10 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
provenance: false
sbom: false
no-cache: true

create-ghcr-manifests:
name: Create GHCR Manifests
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: blacksmith-2vcpu-ubuntu-2404
needs: [build-amd64, build-ghcr-arm64]
if: github.ref == 'refs/heads/main'
strategy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
RESEND_API_KEY: 'dummy_key_for_ci_only'
AWS_REGION: 'us-west-2'
ENCRYPTION_KEY: '7cf672e460e430c1fba707575c2b0e2ad5a99dddf9b7b7e3b5646e630861db1c' # dummy key for CI only
run: bun run build
run: bunx turbo run build --filter=sim

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Create a new service request in Jira Service Management
| `summary` | string | Yes | Summary/title for the service request |
| `description` | string | No | Description for the service request |
| `raiseOnBehalfOf` | string | No | Account ID of customer to raise request on behalf of |
| `requestFieldValues` | json | No | Custom field values as key-value pairs \(overrides summary/description if provided\) |
| `requestFieldValues` | json | No | Request field values as key-value pairs \(overrides summary/description if provided\) |
| `requestParticipants` | string | No | Comma-separated account IDs to add as request participants |
| `channel` | string | No | Channel the request originates from \(e.g., portal, email\) |

Expand Down
29 changes: 27 additions & 2 deletions apps/docs/content/docs/en/tools/slack.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Slack
description: Send, update, delete messages, add reactions in Slack or trigger workflows from Slack events
description: Send, update, delete messages, send ephemeral messages, add reactions in Slack or trigger workflows from Slack events
---

import { BlockInfoCard } from "@/components/ui/block-info-card"
Expand Down Expand Up @@ -59,7 +59,7 @@ If you encounter issues with the Slack integration, contact us at [help@sim.ai](

## Usage Instructions

Integrate Slack into the workflow. Can send, update, and delete messages, create canvases, read messages, and add reactions. Requires Bot Token instead of OAuth in advanced mode. Can be used in trigger mode to trigger a workflow when a message is sent to a channel.
Integrate Slack into the workflow. Can send, update, and delete messages, send ephemeral messages visible only to a specific user, create canvases, read messages, and add reactions. Requires Bot Token instead of OAuth in advanced mode. Can be used in trigger mode to trigger a workflow when a message is sent to a channel.



Expand All @@ -80,6 +80,7 @@ Send messages to Slack channels or direct messages. Supports Slack mrkdwn format
| `dmUserId` | string | No | Slack user ID for direct messages \(e.g., U1234567890\) |
| `text` | string | Yes | Message text to send \(supports Slack mrkdwn formatting\) |
| `threadTs` | string | No | Thread timestamp to reply to \(creates thread reply\) |
| `blocks` | json | No | Block Kit layout blocks as a JSON array. When provided, text becomes the fallback notification text. |
| `files` | file[] | No | Files to attach to the message |

#### Output
Expand Down Expand Up @@ -146,6 +147,29 @@ Send messages to Slack channels or direct messages. Supports Slack mrkdwn format
| `fileCount` | number | Number of files uploaded \(when files are attached\) |
| `files` | file[] | Files attached to the message |

### `slack_ephemeral_message`

Send an ephemeral message visible only to a specific user in a channel. Optionally reply in a thread. The message does not persist across sessions.

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `authMethod` | string | No | Authentication method: oauth or bot_token |
| `botToken` | string | No | Bot token for Custom Bot |
| `channel` | string | Yes | Slack channel ID \(e.g., C1234567890\) |
| `user` | string | Yes | User ID who will see the ephemeral message \(e.g., U1234567890\). Must be a member of the channel. |
| `text` | string | Yes | Message text to send \(supports Slack mrkdwn formatting\) |
| `threadTs` | string | No | Thread timestamp to reply in. When provided, the ephemeral message appears as a thread reply. |
| `blocks` | json | No | Block Kit layout blocks as a JSON array. When provided, text becomes the fallback notification text. |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `messageTs` | string | Timestamp of the ephemeral message \(cannot be used with chat.update\) |
| `channel` | string | Channel ID where the ephemeral message was sent |

### `slack_canvas`

Create and share Slack canvases in channels. Canvases are collaborative documents within Slack.
Expand Down Expand Up @@ -682,6 +706,7 @@ Update a message previously sent by the bot in Slack
| `channel` | string | Yes | Channel ID where the message was posted \(e.g., C1234567890\) |
| `timestamp` | string | Yes | Timestamp of the message to update \(e.g., 1405894322.002768\) |
| `text` | string | Yes | New message text \(supports Slack mrkdwn formatting\) |
| `blocks` | json | No | Block Kit layout blocks as a JSON array. When provided, text becomes the fallback notification text. |

#### Output

Expand Down
96 changes: 96 additions & 0 deletions apps/sim/app/api/tools/slack/send-ephemeral/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import { generateRequestId } from '@/lib/core/utils/request'

export const dynamic = 'force-dynamic'

const logger = createLogger('SlackSendEphemeralAPI')

const SlackSendEphemeralSchema = z.object({
accessToken: z.string().min(1, 'Access token is required'),
channel: z.string().min(1, 'Channel ID is required'),
user: z.string().min(1, 'User ID is required'),
text: z.string().min(1, 'Message text is required'),
thread_ts: z.string().optional().nullable(),
blocks: z.array(z.record(z.unknown())).optional().nullable(),
})

export async function POST(request: NextRequest) {
const requestId = generateRequestId()

try {
const authResult = await checkInternalAuth(request, { requireWorkflowId: false })

if (!authResult.success) {
logger.warn(`[${requestId}] Unauthorized Slack ephemeral send attempt: ${authResult.error}`)
return NextResponse.json(
{
success: false,
error: authResult.error || 'Authentication required',
},
{ status: 401 }
)
}

logger.info(
`[${requestId}] Authenticated Slack ephemeral send request via ${authResult.authType}`,
{ userId: authResult.userId }
)

const body = await request.json()
const validatedData = SlackSendEphemeralSchema.parse(body)

logger.info(`[${requestId}] Sending ephemeral message`, {
channel: validatedData.channel,
user: validatedData.user,
threadTs: validatedData.thread_ts ?? undefined,
})

const response = await fetch('https://slack.com/api/chat.postEphemeral', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${validatedData.accessToken}`,
},
body: JSON.stringify({
channel: validatedData.channel,
user: validatedData.user,
text: validatedData.text,
...(validatedData.thread_ts && { thread_ts: validatedData.thread_ts }),
...(validatedData.blocks &&
validatedData.blocks.length > 0 && { blocks: validatedData.blocks }),
}),
})

const data = await response.json()

if (!data.ok) {
logger.error(`[${requestId}] Slack API error:`, data.error)
return NextResponse.json(
{ success: false, error: data.error || 'Failed to send ephemeral message' },
{ status: 400 }
)
}

logger.info(`[${requestId}] Ephemeral message sent successfully`)

return NextResponse.json({
success: true,
output: {
messageTs: data.message_ts,
channel: validatedData.channel,
},
})
} catch (error) {
logger.error(`[${requestId}] Error sending ephemeral message:`, error)
return NextResponse.json(
{
success: false,
error: error instanceof Error ? error.message : 'Unknown error occurred',
},
{ status: 500 }
)
}
}
2 changes: 2 additions & 0 deletions apps/sim/app/api/tools/slack/send-message/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const SlackSendMessageSchema = z
userId: z.string().optional().nullable(),
text: z.string().min(1, 'Message text is required'),
thread_ts: z.string().optional().nullable(),
blocks: z.array(z.record(z.unknown())).optional().nullable(),
files: RawFileInputArraySchema.optional().nullable(),
})
.refine((data) => data.channel || data.userId, {
Expand Down Expand Up @@ -63,6 +64,7 @@ export async function POST(request: NextRequest) {
userId: validatedData.userId ?? undefined,
text: validatedData.text,
threadTs: validatedData.thread_ts ?? undefined,
blocks: validatedData.blocks ?? undefined,
files: validatedData.files ?? undefined,
},
requestId,
Expand Down
3 changes: 3 additions & 0 deletions apps/sim/app/api/tools/slack/update-message/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const SlackUpdateMessageSchema = z.object({
channel: z.string().min(1, 'Channel is required'),
timestamp: z.string().min(1, 'Message timestamp is required'),
text: z.string().min(1, 'Message text is required'),
blocks: z.array(z.record(z.unknown())).optional().nullable(),
})

export async function POST(request: NextRequest) {
Expand Down Expand Up @@ -57,6 +58,8 @@ export async function POST(request: NextRequest) {
channel: validatedData.channel,
ts: validatedData.timestamp,
text: validatedData.text,
...(validatedData.blocks &&
validatedData.blocks.length > 0 && { blocks: validatedData.blocks }),
}),
})

Expand Down
11 changes: 7 additions & 4 deletions apps/sim/app/api/tools/slack/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export async function postSlackMessage(
accessToken: string,
channel: string,
text: string,
threadTs?: string | null
threadTs?: string | null,
blocks?: unknown[] | null
): Promise<{ ok: boolean; ts?: string; channel?: string; message?: any; error?: string }> {
const response = await fetch('https://slack.com/api/chat.postMessage', {
method: 'POST',
Expand All @@ -23,6 +24,7 @@ export async function postSlackMessage(
channel,
text,
...(threadTs && { thread_ts: threadTs }),
...(blocks && blocks.length > 0 && { blocks }),
}),
})

Expand Down Expand Up @@ -220,6 +222,7 @@ export interface SlackMessageParams {
userId?: string
text: string
threadTs?: string | null
blocks?: unknown[] | null
files?: any[] | null
}

Expand All @@ -242,7 +245,7 @@ export async function sendSlackMessage(
}
error?: string
}> {
const { accessToken, text, threadTs, files } = params
const { accessToken, text, threadTs, blocks, files } = params
let { channel } = params

if (!channel && params.userId) {
Expand All @@ -258,7 +261,7 @@ export async function sendSlackMessage(
if (!files || files.length === 0) {
logger.info(`[${requestId}] No files, using chat.postMessage`)

const data = await postSlackMessage(accessToken, channel, text, threadTs)
const data = await postSlackMessage(accessToken, channel, text, threadTs, blocks)

if (!data.ok) {
logger.error(`[${requestId}] Slack API error:`, data.error)
Expand All @@ -282,7 +285,7 @@ export async function sendSlackMessage(
if (fileIds.length === 0) {
logger.warn(`[${requestId}] No valid files to upload, sending text-only message`)

const data = await postSlackMessage(accessToken, channel, text, threadTs)
const data = await postSlackMessage(accessToken, channel, text, threadTs, blocks)

if (!data.ok) {
return { success: false, error: data.error || 'Failed to send message' }
Expand Down
Loading