Events API transport: a Plug that receives Slack's HTTP event callbacks.
It verifies Slack's request signature, answers the url_verification
challenge, responds 200 immediately, and dispatches the event off-process
(so your handler can't blow Slack's ~3s response budget).
Mount it in a router:
forward "/slack/events", to: Slink.EventsApi.Plug,
init_opts: [
module: MyBot,
signing_secret: System.fetch_env!("SLACK_SIGNING_SECRET"),
bot_token: System.fetch_env!("SLACK_BOT_TOKEN")
]Or run it standalone with Bandit:
Bandit.start_link(
plug: {Slink.EventsApi.Plug,
module: MyBot,
signing_secret: System.fetch_env!("SLACK_SIGNING_SECRET"),
bot_token: System.fetch_env!("SLACK_BOT_TOKEN")},
port: 4000
)Options:
:module(required) — a module implementing theSlinkbehaviour.:signing_secret(required) — the app's Signing Secret, for request verification.:bot_token— bot token (xoxb-…) passed to handlers for Web API calls.
Slash commands & interactivity
Slack delivers those as application/x-www-form-urlencoded, not JSON; this
plug decodes both. Point the app's Request URL for Interactivity and
Slash Commands at this same endpoint. Slash commands and most interactions
are handled off-process like events, and your handler replies via the
response_url (see Slink.reply/3).
The one exception is view_submission (a modal submit): Slack expects a
response_action in the immediate reply. For that type the handler runs
synchronously and its {:ack, map} return is sent back as the response — so
keep it fast (Slack's window is ~3s). Returning anything else closes the modal.