Slack adapter for chat
npm install @chat-adapter/slackSlack adapter for the chat SDK.
``bash`
npm install chat @chat-adapter/slack
`typescript
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!");
});
`
| Option | Required | Description |
|--------|----------|-------------|
| botToken | Yes | Slack bot token (starts with xoxb-) |signingSecret
| | Yes | Slack signing secret for webhook verification |
`bash`
SLACK_BOT_TOKEN=xoxb-...
SLACK_SIGNING_SECRET=...
1. Go to api.slack.com/apps
2. Click Create New App → From scratch
3. Enter app name and select workspace
4. Click Create App
1. Go to OAuth & Permissions in the sidebar
2. Under Scopes → Bot Token Scopes, add:
- app_mentions:read - Receive @mention eventschannels:history
- - Read messages in public channelschannels:read
- - View basic channel infochat:write
- - Send messagesgroups:history
- - Read messages in private channelsgroups:read
- - View basic private channel infoim:history
- - Read direct messagesim:read
- - View basic DM inforeactions:read
- - View emoji reactionsreactions:write
- - Add/remove emoji reactionsusers:read
- - View user info (for display names)
1. Go to OAuth & Permissions
2. Click Install to Workspace
3. Authorize the app
4. Copy the Bot User OAuth Token (starts with xoxb-) → SLACK_BOT_TOKEN
1. Go to Basic Information
2. Under App Credentials, copy Signing Secret → SLACK_SIGNING_SECRET
1. Go to Event Subscriptions
2. Toggle Enable Events to On
3. Set Request URL to: https://your-domain.com/api/webhooks/slackapp_mention
- Slack will verify the URL immediately
4. Under Subscribe to bot events, add:
- - When someone @mentions your botmessage.channels
- - Messages in public channelsmessage.groups
- - Messages in private channelsmessage.im
- - Direct messages
5. Click Save Changes
If you want to use buttons, modals, or other interactive components:
1. Go to Interactivity & Shortcuts
2. Toggle Interactivity to On
3. Set Request URL to: https://your-domain.com/api/webhooks/slack
- Message posting and editing
- Thread subscriptions
- Reaction handling (add/remove/events)
- File attachments
- Rich cards (Block Kit)
- Action callbacks (interactive components)
- Direct messages
MIT