Skip to content

fix(slack): switch adapter to Socket Mode#2702

Open
mperraillon wants to merge 1 commit into
nanocoai:channelsfrom
mperraillon:fix/slack-adapter-socket-mode
Open

fix(slack): switch adapter to Socket Mode#2702
mperraillon wants to merge 1 commit into
nanocoai:channelsfrom
mperraillon:fix/slack-adapter-socket-mode

Conversation

@mperraillon

Copy link
Copy Markdown

Type of Change

  • Fix - bug fix or security fix to source code

Description

src/channels/slack.ts wires createSlackAdapter for HTTP webhook mode (botToken + signingSecret), which requires a publicly reachable URL. But the rest of the codebase already expects Socket Mode:

  • setup/verify.ts checks SLACK_BOT_TOKEN + SLACK_APP_TOKEN
  • setup/migrate-v2/shared.ts preserves SLACK_APP_TOKEN from v1
  • The /add-slack skill on main walks users through obtaining an App-Level Token (xapp-...) — see companion PR fix(skill/add-slack): switch to Socket Mode setup #2700

Result: a configured install has the right env vars (xoxb-... + xapp-...) but the adapter ignores SLACK_APP_TOKEN and falls back to webhook mode, which fails because no signing secret is set.

Fix

Read SLACK_APP_TOKEN, fail-fast if either token is missing, and pass mode: 'socket' + appToken to createSlackAdapter. The underlying @chat-adapter/slack package then opens a WebSocket to Slack instead of expecting inbound HTTP.

Heads-up for the reviewer

This change needs @chat-adapter/slack >= 4.27.0 (where the mode and appToken fields were added). The lockfile on this branch pins 4.26.0, so the code doesn't compile as-is.

I tried bumping @chat-adapter/slack to ^4.27.0 alone — it pulls in chat@4.27.0 transitively, which doesn't match the project's pinned chat@4.26.0. Fixing that by bumping chat to ^4.27.0 then surfaced a separate type issue: createChatSdkBridge's return type no longer exposes resolveChannelName, breaking the existing pattern used here and in telegram.ts.

So the version bump is bigger than a single-adapter fix — it's a coordinated @chat-adapter/* + chat SDK upgrade across all the channels. I left it out of this PR to keep the diff focused on the Socket Mode switch. Happy to bundle the SDK upgrade in if you'd prefer one PR.

Testing

  • Manually verified in a local install (with the SDK upgrade applied locally): host log shows Slack auth completed, Slack socket mode connected, and Channel adapter started channel="slack" on startup. No public URL, no webhook server. DMs deliver end-to-end.
  • Companion PR fix(skill/add-slack): switch to Socket Mode setup #2700 documents this setup on the user-facing side.

The Slack channel adapter was wired for HTTP webhook mode:

  createSlackAdapter({ botToken, signingSecret })

which requires a publicly reachable URL for Slack to deliver
events to. But the rest of the codebase already expects Socket Mode:

- setup/verify.ts checks for SLACK_BOT_TOKEN + SLACK_APP_TOKEN
- setup/migrate-v2/shared.ts preserves SLACK_APP_TOKEN from v1
- The /add-slack skill walks users through obtaining xapp-... and
  xoxb-... (companion PR on main)

Result: a configured install has the right env vars (xapp-... +
xoxb-...) but the adapter ignores SLACK_APP_TOKEN and silently
falls back to webhook mode, which then fails because no signing
secret is set.

Read SLACK_APP_TOKEN, fail-fast if either token is missing, and
pass `mode: 'socket'` + `appToken` to createSlackAdapter so the
underlying @chat-adapter/slack package opens a WebSocket to Slack
instead of expecting inbound HTTP.

Note: this needs @chat-adapter/slack >= 4.27.0 (where the `mode`
and `appToken` fields were added) — the channels-branch lockfile
currently pins 4.26.0. Bumping the slack dep alone pulls in
chat@4.27+, which mismatches the project's pinned chat@4.26.0 and
also surfaces a separate type issue in the chat-sdk-bridge return
type. So this change is best landed alongside a coordinated bump
of @chat-adapter/* and chat — left as a follow-up so this PR
stays focused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

follows-guidelines PR was created using the current contributing template PR: Fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant