A sophisticated Slack Assistant Bot that integrates with Anthropic's Claude API to provide intelligent AI assistance directly in Slack workspaces. Built with Python, Slack Bolt, and async architecture for high performance.
- 🤖 Slack Assistant Integration: Native Slack Assistant API for seamless conversational interfaces
- 🧠 Claude AI Models:
- Normal Mode: Claude Sonnet 4 (optimized for speed)
- Beast Mode: Claude Opus 4 (maximum intelligence) - selectable via interactive buttons
- 🔧 Tool Integration: Extensible architecture with built-in bash commands and Linear API integration
- ⚡ Real-time Streaming: Async streaming responses with live status updates
- 💭 Thinking Mode: Shows Claude's reasoning process with proper formatting
- 🛑 Emergency Stop: Cancel long-running operations with stop button
- 📊 Linear Integration: Query and manage Linear issues directly from Slack
- Python 3.8+
- Slack workspace with admin permissions
- Anthropic API key
- Linear API key (optional)
- Clone the repository
git clone https://github.com/yourusername/lebot.git
cd lebot- Set up Python environment
python3 -m venv .venv
source .venv/bin/activate # Windows: .\.venv\Scripts\Activate
pip install -r requirements.txt-
Create Slack App
- Go to api.slack.com/apps/new
- Choose "From an app manifest"
- Copy contents of
manifest.jsonand paste in the JSON tab - Click Create, then Install to Workspace
-
Configure environment variables
cp .env.example .envEdit .env with your credentials:
SLACK_BOT_TOKEN=xoxb-your-bot-token # From OAuth & Permissions
SLACK_APP_TOKEN=xapp-your-app-token # From Basic Information > App-Level Tokens
ANTHROPIC_API_KEY=sk-ant-api03-your-key # From Anthropic Console
LINEAR_OAUTH_KEY=lin_api_your_key # Optional: From Linear Settings- Run the bot
Using Slack CLI (recommended):
# Install Slack CLI if you haven't already
# Visit: https://api.slack.com/automation/cli/install
# Run the app with Slack CLI
slack runOr run directly with Python:
python3 app.py- Start a conversation: Click the ✨ Assistant button in any Slack channel or DM to start a new assistant thread
- Select AI model: Use the interactive buttons in the greeting:
- 🚀 Normal Mode: Fast responses with Claude Sonnet 4
- 🦾 Beast Mode: Maximum capability with Claude Opus 4
- Ask questions: Type naturally in the assistant thread - no @ mentions needed
- Use tools: The bot can execute bash commands and query Linear issues
In an assistant thread, simply type:
Can you help me understand this Python error?
Show me all in-progress Linear issues
What issues were created this week?
Can you analyze our test coverage?
User ↔ Slack Assistant ↔ LLM (Claude) ↔ Tools
app.py: Main entry point with async Slack Bolt appslack_hook/: Core Slack integrationassistant.py: Async event handlers with decoratorsclaude.py: Custom async Claude client with streamingconversation_manager.py: Thread context managementmessage_parser.py: Parsing for thinking blocks and tool uses
tools/: Extensible tool systemgraphql.py: GraphQL client with Linear API integration
The entire application uses async/await for optimal performance:
- Non-blocking I/O operations
- Real-time streaming responses
- Concurrent tool execution
- Proper resource management
# Linting
flake8 *.py && flake8 slack_hook/ && flake8 tools/
# Formatting (125 char line length)
black .
# Testing
pytestfrom tools.graphql import LinearClient
# Initialize client
linear = LinearClient(os.getenv('LINEAR_OAUTH_KEY'))
# Get issues
issues = linear.get_issues(limit=50)
in_progress = linear.get_in_progress_issues()
# Query by date
from datetime import datetime, timedelta
weekly_issues = linear.get_issues_by_date_range(
start_date=(datetime.now() - timedelta(days=7)).strftime('%Y-%m-%d'),
end_date=datetime.now().strftime('%Y-%m-%d')
)The manifest.json defines:
- Assistant feature with custom description
- Required OAuth scopes
- Event subscriptions
- Socket Mode configuration
See .env.example for all available options:
SLACK_BOT_TOKEN: Bot user OAuth tokenSLACK_APP_TOKEN: App-level token for Socket ModeANTHROPIC_API_KEY: Claude API keyLINEAR_OAUTH_KEY: Linear API key (optional)
See docs/claude-code-integration-architecture.md for planned Claude Code integration that would add:
- File operations and code generation
- Dynamic script discovery and execution
- Sandboxed development environment
- Enhanced tool capabilities
- Bot not responding: Check Socket Mode connection and app tokens
- Linear integration failing: Verify API key and permissions
- Streaming issues: Ensure async handlers are properly awaited
- Type errors: Run
flake8to check for type hint issues
Enable debug logging by setting:
export DEBUG=true- Fork the repository
- Create a feature branch
- Run tests and linting
- Submit a pull request
MIT License - see LICENSE file for details
- Store all API keys in
.envfile - Never commit credentials to version control
- Use environment variables for all sensitive data
- Review
manifest.jsonOAuth scopes before deployment