How Does Slack Socket Mode Work?
Receiving Events via Outbound WebSocket Without Webhooks
Slack originally delivered events via Webhooks (Event Subscriptions), but this required a public URL. Socket Mode has the Bot server establish an outbound WebSocket connection to Slack first, and Slack pushes events through that connection. No public URL, SSL certificate, or firewall configuration needed. Internally, it uses the apps.connections.open API to receive a WebSocket URL for connection.
Architecture Diagram
How It Works
Bot calls apps.connections.open API โ receives temporary WebSocket URL
Bot establishes WebSocket connection to that URL (outbound)
Event occurs in Slack (message, slash command, interaction, etc.)
Slack pushes event payload to Bot via WebSocket
Bot processes the event and sends acknowledge response (within 3 seconds)
Send/update messages via Slack Web API as needed
Pros
- ✓ No public URL needed
- ✓ Works behind firewalls/NAT
- ✓ Local development possible without ngrok
- ✓ No SSL certificate needed
Cons
- ✗ Connection maintenance required (30s ping)
- ✗ Possible event loss on disconnect
- ✗ Not suitable for large-scale apps (connection limits)
- ✗ Fewer debugging tools compared to Webhooks