Commit d4632ff
authored
feat(slack): Socket Mode transport (#86)
Ports vercel/chat#162 — adds an opt-in Slack Socket Mode transport so bots can consume Slack events over a persistent WebSocket instead of (or alongside) signed HTTP webhooks.
The webhook code path is unchanged. Socket Mode is enabled per-adapter via SlackAdapterConfig(mode="socket", app_token="xapp-...").
- start_socket_mode() spawns a tracked asyncio.Task with shutdown signaling; idempotent
- Outer reconnect loop on top of slack_sdk SocketModeClient: 1s→30s exp backoff, 250ms shutdown poll
- Forwarded-events receiver in handle_webhook (x-slack-socket-token, hmac.compare_digest) for the serverless variant
- ModalResponse(action="clear") emits response_action: clear
- ContextVar isolation via contextvars.copy_context() for spawned handler tasks
- New optional extra slack-socket = ["slack-sdk>=3.27.0", "aiohttp>=3.9"]
- Outer reconnect loop and the not-ported serverless startSocketModeListener are documented divergences1 parent 1ddc8d3 commit d4632ff
6 files changed
Lines changed: 1652 additions & 11 deletions
File tree
- docs
- src/chat_sdk
- adapters/slack
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| 503 | + | |
| 504 | + | |
503 | 505 | | |
504 | 506 | | |
505 | 507 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
0 commit comments