This guide walks you through creating and configuring a Slack bot for SlackONOS using Socket Mode. It mirrors the structure of DISCORD.md and focuses on the exact scopes, events, and settings SlackONOS requires.
- Uses Socket Mode (WebSocket) — no public HTTP endpoints required
- Requires two tokens:
- App-level token:
xapp-...withconnections:write - Bot user token:
xoxb-...for API actions
- App-level token:
- Subscribes to bot events to receive messages and mentions
- Slack workspace admin access (to create and install apps)
- SlackONOS repository cloned and Docker installed (optional)
- Go to https://api.slack.com/apps and click "Create New App"
- Choose "From scratch", give it a name (e.g., "SlackONOS"), and select your workspace
- Open your app → "Socket Mode"
- Toggle "Enable Socket Mode" to ON
- Click "Generate App-Level Token" (or manage tokens)
- Ensure the token has scope
connections:write - Copy the token (
xapp-1-...) — you'll put this inconfig.jsonasslackAppToken
Open "OAuth & Permissions" → scroll to "Bot Token Scopes" and add:
app_mentions:read— receive mentions of your botchat:write— send messageschannels:read— read public channel listchannels:history— read public channel messagesgroups:read— read private channel listgroups:history— read private channel messagesreactions:read— read reactions on messages (required for reaction voting)users:read— read user information (for reaction handler)- Optional (DMs):
im:history
Note: You don’t need a Request URL when using Socket Mode.
Open "Event Subscriptions" → toggle "Enable Events" ON → "Subscribe to bot events" and add:
app_mention— for @SlackONOS mentionsmessage.channels— messages in public channelsmessage.groups— messages in private channelsreaction_added— reactions added to messages (required for reaction voting)- Optional:
message.im— direct messages to the bot
Click "Save Changes".
- Open "Install App"
- Click "Install to Workspace" or "Reinstall to Workspace" to apply new scopes
- Copy the Bot User OAuth Token (starts with
xoxb-) — use it astokeninconfig.json
In Slack, invite the bot user to the channels where it should operate:
/invite @SlackONOS
Create or edit config/config.json. Minimal example:
{
"adminChannel": "music-admin", // or channel ID: C01ABC123XY (recommended)
"standardChannel": "music", // or channel ID: C987DEF654 (recommended)
"slackAppToken": "xapp-1-...", // Socket Mode app-level token
"token": "xoxb-...", // Bot User OAuth token
"sonos": "192.168.0.50", // Sonos IP
"market": "US",
"maxVolume": 75,
"logLevel": "info"
}- Using names like
music-adminforces a full channel scan on first run (can hit rate limits) - SlackONOS now auto-saves discovered channel IDs back to
config.jsonafter the first successful startup - To skip the slow first run, set IDs directly:
{
"adminChannel": "C01ABC123XY",
"standardChannel": "C987DEF654"
}How to find IDs: Slack web → open channel → URL has /C... or "View channel details" → copy ID.
Node (local):
npm install
node index.jsDocker Compose:
docker compose pull
docker compose up -dVerify logs:
[info] ✅ Voting module initialized
[info] ✅ Command router initialized with AI support
[info] Bot user ID loaded: U123...
[info] ✅ Successfully connected to Slack via Socket Mode
On first startup with names:
[warn] Channel names detected — performing lookup (slow in large workspaces)
[info] Fetched 1247 channels total
[info] ✅ Auto-saved channel IDs to config.json
missing_scope- Revisit OAuth & Permissions → ensure scopes above
- Event Subscriptions → Save Changes
- Install App → Reinstall to Workspace
- Update
config.jsonwith the newxoxb-token
- Bot not responding
- Ensure bot is invited to channels
- Confirm Socket Mode is ON and
slackAppTokenis present - Check logs for rate limit messages and wait/backoff
- Rate limits on startup
- Use channel IDs directly to avoid workspace-wide scans
- Treat
xapp-andxoxb-tokens as secrets - Prefer environment variables or Docker secrets for production
- Consider Slack token rotation features if your org requires it
If you want slash commands (e.g., /slackonos):
- Enable "Slash Commands"
- Define a command (no Request URL needed for Socket Mode)
- Ensure
commandsscope is added - Implement handler mapping in your app (SlackONOS has infrastructure ready, not enabled by default)
That’s it! Your Slack bot should be connected via Socket Mode and ready to handle mentions and channel messages.