Slackbot Agent
Build intelligent Slack bots that can respond to messages, handle mentions, and execute tasks.Quick Start
Configuration
Event Handlers
Message Handler
App Mention Handler
Reaction Handler
Rich Responses
With Blocks
Socket Mode (Development)
For local development without exposing a public URL:Webhook Mode (Production)
For production deployments:With Tools
Environment Variables
| Variable | Required | Description |
|---|---|---|
SLACK_BOT_TOKEN | Yes | Bot token (xoxb-…) |
SLACK_SIGNING_SECRET | Webhook | Signing secret |
SLACK_APP_TOKEN | Socket | App token (xapp-…) |
OPENAI_API_KEY | Yes | For the agent |
Slack App Setup
- Create a Slack App at https://api.slack.com/apps
- Enable Socket Mode or configure Event Subscriptions
- Add bot scopes:
chat:write,app_mentions:read,channels:history - Install to workspace
- Copy tokens to environment variables
Best Practices
- Use threads - Reply in threads to keep channels clean
- Handle errors gracefully - Return friendly error messages
- Rate limit - Respect Slack’s rate limits
- Log interactions - Track usage for debugging

