mirror of
https://github.com/vercel/chat.git
synced 2026-09-14 18:32:29 +08:00
85d35c0516
Version Packages
@chat-adapter/slack
Slack adapter for the chat SDK.
Installation
npm install chat @chat-adapter/slack
Usage
import { Chat } from "chat";
import { createSlackAdapter } from "@chat-adapter/slack";
const chat = new Chat({
userName: "mybot",
adapters: {
slack: createSlackAdapter({
botToken: process.env.SLACK_BOT_TOKEN!,
signingSecret: process.env.SLACK_SIGNING_SECRET!,
}),
},
});
// Handle @mentions
chat.onNewMention(async (thread, message) => {
await thread.post("Hello from Slack!");
});
Configuration
| Option | Required | Description |
|---|---|---|
botToken |
Yes | Slack bot token (starts with xoxb-) |
signingSecret |
Yes | Slack signing secret for webhook verification |
Required Slack Scopes
Your Slack app needs these OAuth scopes:
Bot Token Scopes:
chat:write- Send messageschannels:history- Read channel messagesgroups:history- Read private channel messagesim:history- Read DM messagesmpim:history- Read group DM messagesreactions:read- Read reactionsreactions:write- Add reactionsfiles:read- Read file attachmentsusers:read- Read user info
Event Subscriptions:
message.channels- Channel messagesmessage.groups- Private channel messagesmessage.im- Direct messagesmessage.mpim- Group DMsapp_mention- @mentionsreaction_added- Reaction eventsreaction_removed- Reaction events
Features
- Message posting and editing
- Thread subscriptions
- Reaction handling (add/remove/events)
- File attachments
- Rich cards (Block Kit)
- Action callbacks (interactive components)
- Direct messages
License
MIT