A Slack bot that responds to direct messages (DMs) and mentions using Slack Bolt in Socket Mode, built with TypeScript and Bun. The bot uses Anthropic Claude or OpenAI models via Vercel AI SDK and supports MCP (Model Context Protocol) integration for extended tool capabilities.
- 🤖 AI-powered responses using Claude or OpenAI models
- 💬 Responds to direct messages and @mentions
- 🔌 MCP integration for extended functionality (catalog search, health checks, playbooks, etc.)
- ✅ Tool approval workflow for sensitive operations
- ⚡ Built with Slack Bolt in Socket Mode
- Create a new Slack app at api.slack.com/apps
- Enable Socket Mode under Settings → Basic Information → Socket Mode
- Add the following Bot Token Scopes under OAuth & Permissions:
app_mentions:read- View messages that mention the appchat:write- Send messagesgroups:history- View messages in private channelsim:history- View messages in DMsim:read- View basic info about DMsim:write- Start direct messagesreactions:read- View emoji reactionsreactions:write- Add emoji reactions
- Enable Event Subscriptions under Features → Event Subscriptions
- Add the following Bot Events under Subscribe to bot events:
app_mention- Subscribe to message events that mention your appmessage.im- Subscribe to messages in direct message channels
- Install the app to your workspace under OAuth & Permissions
- Create an app-level token from Settings → Basic Information → App-Level Tokens with the
connections:writescope (required for Socket Mode)
Copy .env.example to .env and configure:
# Required: Slack credentials
SLACK_BOT_TOKEN=xoxb-...
SLACK_APP_TOKEN=xapp-...
# Required: At least one LLM provider
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
GOOGLE_GENERATIVE_AI_API_KEY=...
# Optional: Model selection (defaults: claude-haiku-4-5, gpt-5.2-chat-latest, gemini-3-flash-preview)
LLM_MODEL=claude-haiku-4-5
# Optional: Logging level (DEBUG, INFO, WARN, ERROR)
LOG_LEVEL=INFO
# Optional: MCP server integration
MCP_URL=http://localhost:8080/mcp
MCP_BEARER_TOKEN=your-bearer-tokenbun installbun startThe bot will connect to Slack via Socket Mode and respond to:
- Direct messages sent to the bot
- @mentions in channels and groups
Control log verbosity with the LOG_LEVEL environment variable:
LOG_LEVEL=DEBUG bun startAvailable log levels (from most to least verbose):
DEBUG- Detailed debug informationINFO- General informational messages (default)WARN- Warning messages onlyERROR- Error messages only
The log level can be set in your .env file or passed as an environment variable when starting the bot.
The bot supports connecting to an MCP server to extend its capabilities with custom tools. Configure MCP_URL and optionally MCP_BEARER_TOKEN to enable this feature.
Tools are automatically wrapped with an approval workflow - read-only operations like searching and viewing are auto-approved, while write operations require user approval in Slack.