Skip to content

feat(slack): add Socket Mode support to Slack adapter#2613

Open
apparentsoft wants to merge 1 commit into
nanocoai:channelsfrom
apparentsoft:pr/slack-socket-mode
Open

feat(slack): add Socket Mode support to Slack adapter#2613
apparentsoft wants to merge 1 commit into
nanocoai:channelsfrom
apparentsoft:pr/slack-socket-mode

Conversation

@apparentsoft
Copy link
Copy Markdown

Summary

Adds Socket Mode support to the Slack channel adapter. Mode is auto-detected from env:

  • If SLACK_APP_TOKEN is set → Socket Mode
  • Otherwise → existing webhook flow using SLACK_SIGNING_SECRET

Purely additive. Existing webhook installs are byte-identical at runtime — no env change, no config change, same code path.

Motivation

Webhook mode requires a stable, publicly reachable URL for Slack to POST events. For installs on a laptop, home NAS, or anything behind NAT, that means setting up ngrok / Cloudflare Tunnel / a reverse-proxy. Socket Mode opens an outbound WebSocket from the bot to Slack and removes the public-URL requirement entirely.

What changed

  • src/channels/slack.ts — adds an env.SLACK_APP_TOKEN ? socket : webhook branch around createSlackAdapter. Everything else (resolveChannelName, concurrency, thread support, bridge wiring) is unchanged.
  • .claude/skills/add-slack/SKILL.md — adds a mode-comparison table at the top of the Credentials section and side-by-side step-by-step setup for each mode. Bumps the pinned install from @chat-adapter/slack@4.26.04.27.0 because mode: 'socket' is not present in 4.26's SlackAdapterConfig type (added in 4.27).

Test plan for review

  • Confirm @chat-adapter/slack@4.27.0 is acceptable as the new install pin (the current ^4.24.0 range allows it; mode: 'socket' is required for the new branch to typecheck).
  • Webhook regression: existing installs without SLACK_APP_TOKEN continue to construct the adapter via the unchanged signingSecret path.
  • Socket Mode: install with SLACK_BOT_TOKEN + SLACK_APP_TOKEN (no signing secret, no public URL), follow Socket Mode setup steps in SKILL.md, verify events delivered for message.channels, message.im, app_mention.

Compatibility

No breaking changes. No schema/DB changes. No host or container API surface changes. Single new optional env var.

The Slack adapter now auto-detects Socket Mode when `SLACK_APP_TOKEN`
is set, and falls back to webhook mode using `SLACK_SIGNING_SECRET`
otherwise. This is purely additive — existing webhook installs keep
working without changes.

Why Socket Mode matters:
- Removes the requirement for a publicly reachable webhook URL,
  which is the biggest install blocker for NanoClaw users running
  on a laptop, NAS, or home network.
- No ngrok / Cloudflare Tunnel / reverse-proxy setup needed.
- Slack opens the outbound WebSocket from the bot, not the other
  way around — works behind NAT.

Implementation:
- `src/channels/slack.ts` reads `SLACK_APP_TOKEN` in addition to the
  existing env keys. If present, constructs the adapter with
  `mode: 'socket'`; otherwise uses the existing webhook construction.
- Bumps the `/add-slack` install pin from `@chat-adapter/slack@4.26.0`
  to `4.27.0` because `mode: 'socket'` is not present in 4.26's
  `SlackAdapterConfig` type.
- `SKILL.md` documents both delivery modes with a comparison table
  and step-by-step setup for each. Socket Mode is presented as the
  recommended path for local installs.

Tested locally against my own Slack workspace in Socket Mode for
months on a Mac without a public endpoint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant