Slack Socket Mode
Recieve events from Slack's Events API over a WebSocket connection. Deno port of @slack/socket-mode
Usage
import "https://deno.land/x/dotenv@v2.0.0/load.ts"
import { SocketModeClient } from "https://deno.land/x/slack_socket_mode@1.0.1/mod.ts"
const appToken = Deno.env.get("SLACK_APP_TOKEN")
const socketModeClient = new SocketModeClient({ appToken })
// Attach listeners to events by type. See: https://api.slack.com/events/message
socketModeClient.addEventListener("message", ({ detail: { body, ack } }) => {
ack()
console.log(body)
})
await socketModeClient.start()
API
- API is similar to the node @slack/socket-mode, where
.addEventListener
is used instead of.on
(EventTarget docs) - Complete generated docs are also available