diff --git a/docs/channels/slack.md b/docs/channels/slack.md index afb6a219b5c7..a882319d9fec 100644 --- a/docs/channels/slack.md +++ b/docs/channels/slack.md @@ -1282,7 +1282,7 @@ Primary reference: [Configuration reference - Slack](/gateway/config-channels#sl - channel access: `groupPolicy`, `channels.*`, `channels.*.users`, `channels.*.requireMention` - threading/history: `replyToMode`, `replyToModeByChatType`, `thread.*`, `historyLimit`, `dmHistoryLimit`, `dms.*.historyLimit` - delivery: `textChunkLimit`, `chunkMode`, `mediaMaxMb`, `streaming`, `streaming.nativeTransport`, `streaming.preview.toolProgress` -- unfurls: `unfurlLinks`, `unfurlMedia` for `chat.postMessage` link/media preview control +- unfurls: `unfurlLinks` (default: `false`), `unfurlMedia` for `chat.postMessage` link/media preview control - ops/features: `configWrites`, `commands.native`, `slashCommand.*`, `actions.*`, `userToken`, `userTokenReadOnly` diff --git a/extensions/slack/src/send.ts b/extensions/slack/src/send.ts index 36fd7110737b..6b3985690524 100644 --- a/extensions/slack/src/send.ts +++ b/extensions/slack/src/send.ts @@ -128,7 +128,10 @@ function hasCustomIdentity(identity?: SlackSendIdentity): boolean { function buildSlackUnfurlPayload(options?: SlackUnfurlOptions) { return { - ...(typeof options?.unfurlLinks === "boolean" ? { unfurl_links: options.unfurlLinks } : {}), + // Default unfurl_links to false so bot messages don't expand inline + // link previews (Slack message links, URLs, etc.) unless the operator + // explicitly opts in via `channels.slack.unfurlLinks: true`. + unfurl_links: options?.unfurlLinks ?? false, ...(typeof options?.unfurlMedia === "boolean" ? { unfurl_media: options.unfurlMedia } : {}), }; } diff --git a/extensions/slack/src/send.unfurl.test.ts b/extensions/slack/src/send.unfurl.test.ts index 767306c34768..bb05dc7cb850 100644 --- a/extensions/slack/src/send.unfurl.test.ts +++ b/extensions/slack/src/send.unfurl.test.ts @@ -47,7 +47,7 @@ function requireLastPostMessagePayload(client: SlackUnfurlTestClient) { } describe("sendMessageSlack unfurl controls", () => { - it("omits Slack unfurl flags when config is unset", async () => { + it("defaults unfurl_links to false when config is unset", async () => { const client = createSlackSendTestClient(); await sendMessageSlack("channel:C123", "https://example.com", { @@ -58,7 +58,7 @@ describe("sendMessageSlack unfurl controls", () => { expect(client.chat.postMessage).toHaveBeenCalledTimes(1); const payload = requirePostMessagePayload(client); - expect("unfurl_links" in payload).toBe(false); + expect(payload.unfurl_links).toBe(false); expect("unfurl_media" in payload).toBe(false); });