Socket Mode transport: a GenServer that keeps a WebSocket open to Slack.
It opens a connection URL via apps.connections.open, upgrades to a
WebSocket with Mint.WebSocket, acknowledges every envelope immediately
(Slack requires an ACK within 3 seconds), and dispatches the decoded event to
your module off-process. Slack's periodic disconnect refreshes and dropped
connections are handled by transparently reconnecting.
Add it to a supervision tree:
{Slink.SocketMode,
module: MyBot,
app_token: System.fetch_env!("SLACK_APP_TOKEN"),
bot_token: System.fetch_env!("SLACK_BOT_TOKEN")}Options:
:module(required) — a module implementing theSlinkbehaviour.:app_token(required) — app-level token (xapp-…,connections:write).:bot_token— bot token (xoxb-…) passed to handlers for Web API calls.:name— process name (defaults toSlink.SocketMode; passnilto run unregistered, e.g. to run several clients at once).:join— a list of channel IDs toconversations.joinonce connected (requires thechannels:joinscope). Defaults to[].:open_connection— a 0-arity function returning{:ok, ws_url}used to obtain the WebSocket URL. Defaults to callingapps.connections.openwith:app_token. Primarily a testing seam.:verbose— whentrue, log every incoming WebSocket frame at:info(raw text for text frames). Useful for debugging what Slack actually delivers. Defaults tofalse.
Summary
Functions
Returns a specification to start this module under a supervisor.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.