Slack Integration¶
Integrate Dev Agents with Slack to interact with your AI assistant directly from your team channels.
Slack App Setup¶
Step 1: Create Slack App¶
- Go to https://api.slack.com/apps
- Click "Create New App"
- Select "From scratch"
- Choose an app name (e.g., "Dev Agents")
- Select your Slack workspace
Step 2: Configure App Permissions¶
Navigate to OAuth & Permissions and add these Bot Token Scopes:
Required Scopes¶
app_mentions:read # Listen to @mentions
chat:write # Send messages
chat:write.public # Send messages to public channels
channels:history # Read message history
channels:read # List channels
groups:history # Read private channel history
groups:read # List private channels
im:history # Read DM history
im:read # List DMs
mpim:history # Read group DM history
mpim:read # List group DMs
users:read # Read user information
Step 3: Enable Socket Mode¶
- Go to Socket Mode
- Enable Socket Mode
- Generate an App-Level Token with
connections:write
scope - Save the token (starts with
xapp-
)
Step 4: Configure Event Subscriptions¶
In Event Subscriptions:
- Enable Events
- Subscribe to these Bot Events:
Step 5: Install App¶
- Go to Install App
- Install to your workspace
- Copy the Bot User OAuth Token (starts with
xoxb-
)
Environment Configuration¶
Add these to your .env
file:
# Slack Integration
SLACK_BOT_TOKEN=xoxb-your-bot-user-oauth-token
SLACK_APP_TOKEN=xapp-your-app-level-token
SLACK_SIGNING_SECRET=your-signing-secret
# Optional: Agent identity in Slack
AGENT_NAME=BettySharp
Configuration File¶
Add to your config/config.yaml
:
integrations:
slack:
enabled: true
mock_mode: false
# Optional: Restrict to specific channels
channels:
- "#development"
- "#devops"
- "#code-review"
# Optional: Slack-specific settings
settings:
thread_replies: true # Reply in threads by default
mention_required: false # Respond without @mention in DMs
typing_indicator: true # Show typing indicator
Starting the Slack Bot¶
Development Mode¶
# Activate virtual environment
source venv/bin/activate
# Start the Slack bot
python -m src.entrypoints.slack_bot
Production Mode¶
Usage Examples¶
Basic Commands¶
# In any channel or DM
@BettySharp analyze the latest changes
@BettySharp help me understand the authentication flow
@BettySharp what tests should I write for PR #123?
Advanced Interactions¶
# Code analysis
@BettySharp review the changes in commit abc123
# Impact analysis
@BettySharp analyze impact of refactoring the payment system
# Release planning
@BettySharp generate release notes for sprint 42
Channel Management¶
Adding the Bot to Channels¶
- Invite to channel:
/invite @BettySharp
- Public channels: Bot can be mentioned once invited
- Private channels: Requires explicit invitation
Channel Permissions¶
The bot will: - ✅ Respond to @mentions in any channel it's in - ✅ Answer direct messages - ✅ Read conversation context for better responses - ❌ Never post unsolicited messages - ❌ Never react to messages unless mentioned
Threading and Context¶
Thread Behavior¶
Dev Agents maintains conversation context:
You: @BettySharp analyze this PR
Bot: I'll analyze PR #123. Here's what I found... [thread]
You: What about security implications? [in thread]
Bot: For security, I notice... [continues in thread]
Context Awareness¶
The bot understands: - Previous messages in the thread - File attachments and links - User mentions and relationships - Channel topic and purpose
Troubleshooting¶
Common Issues¶
Bot Not Responding¶
Check these items:
# 1. Verify tokens are set
echo $SLACK_BOT_TOKEN | head -c 10
echo $SLACK_APP_TOKEN | head -c 10
# 2. Check bot is running
ps aux | grep slack_bot
# 3. Verify permissions
# Bot needs to be in the channel where you're messaging
Permission Errors¶
Connection Issues¶
# Test network connectivity
curl -X POST https://slack.com/api/auth.test \
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
Debug Mode¶
Enable debug logging:
# Set debug level
export LOG_LEVEL=DEBUG
# Start with verbose output
python -m src.entrypoints.slack_bot --verbose
Security Considerations¶
Token Security¶
- Never commit tokens to version control
- Use environment variables for all secrets
- Rotate tokens periodically
- Limit app permissions to minimum required
Message Privacy¶
Dev Agents: - Reads messages only when mentioned or in DMs - Doesn't store conversation history persistently - Processes locally or via configured AI service - Respects Slack's data retention policies
Best Practices¶
- Clear naming - Use descriptive agent names (@BettySharp)
- Channel organization - Dedicate channels for dev discussions
- Thread usage - Keep related conversations in threads
- Context sharing - Include relevant links and details
- Team training - Help team members learn effective prompts
Advanced Configuration¶
Custom Responses¶
Modify prompts in config/prompts.yaml
:
slack:
messages:
greeting: |
👋 Hi! I'm {agent_name}, your development assistant.
I can help with:
• Code analysis and reviews
• Impact assessment
• Testing recommendations
• Documentation questions
Just @mention me with your question!
Multi-Workspace Setup¶
For multiple Slack workspaces:
integrations:
slack:
workspaces:
- name: "team-alpha"
bot_token: "${SLACK_ALPHA_BOT_TOKEN}"
app_token: "${SLACK_ALPHA_APP_TOKEN}"
- name: "team-beta"
bot_token: "${SLACK_BETA_BOT_TOKEN}"
app_token: "${SLACK_BETA_APP_TOKEN}"
Next Steps¶
- Configure Azure DevOps integration
- Set up GitLab integration
- Customize prompts for your team