Slack Adapter
The Slack adapter posts feedback messages, uploads voice recordings, creates support channels, and invites users, all via the Slack API using a bot token.
import { createMusHandlers } from '@datachef/mus/server'import { slackAdapter } from '@datachef/mus/adapters/slack'
export const { POST, POSTStandalone, POSTSupportChannel } = createMusHandlers({ adapter: slackAdapter({ token: process.env.SLACK_BOT_TOKEN!, }),})SLACK_BOT_TOKEN=xoxb-your-tokenRequired bot scopes
Section titled “Required bot scopes”| Scope | Used for |
|---|---|
chat:write | Post messages and threads |
files:write | Upload voice recordings |
channels:manage or groups:write | Create private support channels |
users:read.email | Look up users by email for channel invites |
Message formatting
Section titled “Message formatting”Override the default message format per event type or globally:
Per-event override
Section titled “Per-event override”slackAdapter({ token: process.env.SLACK_BOT_TOKEN!, format: { voice: (event) => ({ text: `🎤 ${event.user.name} recorded feedback on "${event.section.name}"`, blocks: [ { type: 'section', text: { type: 'mrkdwn', text: `*${event.user.name}* (${event.user.email}) left a voice note\n*Section:* ${event.section.name}\n*Note:* ${event.note ?? '—'}`, }, }, ], }), // all other event types use the default format },})Global override
Section titled “Global override”slackAdapter({ token: process.env.SLACK_BOT_TOKEN!, format: (event) => ({ text: `[${event.projectName}] ${event.type} from ${event.user.email} on "${event.section.name}"`, }),})Getting your Slack bot token
Section titled “Getting your Slack bot token”- Go to api.slack.com/apps → Create New App → From scratch
- Under OAuth & Permissions → Bot Token Scopes, add the scopes listed above
- Install the app to your workspace
- Copy the Bot User OAuth Token (
xoxb-...) - Invite the bot to your feedback channel:
/invite @your-bot-name
Getting the feedback channel ID
Section titled “Getting the feedback channel ID”- Open Slack → right-click the channel → View channel details
- The channel ID is at the bottom (e.g.
C0XXXXXXXXX)
Or from the channel URL: https://app.slack.com/client/T.../C0XXXXXXXXX. The channel ID is the C0XXXXXXXXX part.