Slack Bot
This guide will help you set up the Qodo Slack Bot with support for both HTTP Webhook and Socket Mode approaches.
Choose Your Mode
Qodo Gen CLI supports two communication modes with Slack:
HTTP Webhook Mode (default): Requires a public endpoint, best for production
Socket Mode: Works behind firewalls, great for development and enterprise environments
Public endpoint required
✅ Yes
❌ No
Works behind firewalls
❌ No
✅ Yes
Slack Marketplace compatible
✅ Yes
❌ No
Scalability
✅ Excellent
⚠️ Limited (10 connections)
Local development
⚠️ Needs tunneling
✅ Direct
Prerequisites
A Slack workspace where you have permission to install apps
A Qodo API key (get one from Qodo Dashboard)
Node.js and the Qodo CLI installed
Step 1: Create a Slack App
Go to Slack API Apps
Click "Create New App"
Choose "From scratch"
Enter your app name (e.g., "Qodo Bot")
Select your workspace
Click "Create App"
Step 2: Configure OAuth & Permissions
In your app settings, go to "OAuth & Permissions"
Scroll down to "Scopes" → "Bot Token Scopes"
Add the following scopes:
chat:write
- Send messageschat:write.public
- Send messages to channels the bot isn't inreactions:write
- Add reactions to messageschannels:read
- Read channel informationgroups:read
- Read private channel informationim:read
- Read direct message informationmpim:read
- Read group direct message information
Scroll up and click "Install to Workspace"
Authorize the app
Copy the "Bot User OAuth Token" (starts with
xoxb-
)
Step 3A: Configure Event Subscriptions (HTTP Webhook Mode)
Skip this step if you're using Socket Mode
Go to "Event Subscriptions" in your app settings
Turn on "Enable Events"
Set the Request URL to:
http://your-server.com/slack/events
For local development:
http://localhost:4444/slack/events
(default port)For custom port:
http://localhost:YOUR_PORT/slack/events
For production: Use your actual server URL with HTTPS
Under "Subscribe to bot events", add:
app_mention
- When your bot is mentionedmessage.channels
- Messages in public channelsmessage.groups
- Messages in private channelsmessage.im
- Direct messagesmessage.mpim
- Group direct messages
Click "Save Changes"
Step 3B: Configure Socket Mode (Socket Mode Only)
Skip this step if you're using HTTP Webhook Mode
Go to "Socket Mode" in your app settings
Toggle "Enable Socket Mode" to ON
Go to "Event Subscriptions" in your app settings
Turn on "Enable Events" (no Request URL needed for Socket Mode)
Under "Subscribe to bot events", add:
app_mention
- When your bot is mentionedmessage.channels
- Messages in public channelsmessage.groups
- Messages in private channelsmessage.im
- Direct messagesmessage.mpim
- Group direct messages
Click "Save Changes"
Step 4A: Get Your Signing Secret (HTTP Webhook Mode Only)
Skip this step if you're using Socket Mode
Go to "Basic Information" in your app settings
Under "App Credentials", find "Signing Secret"
Click "Show" and copy the secret
Step 4B: Generate App-Level Token (Socket Mode Only)
Skip this step if you're using HTTP Webhook Mode
Go to "Basic Information" in your app settings
Scroll down to "App-Level Tokens"
Click "Generate Token and Scopes"
Enter a token name (e.g., "socket-mode-token")
Add the scope:
connections:write
Click "Generate"
Copy the token (starts with
xapp-
)
Step 5: Configure Environment Variables
Copy the example environment file:
cp .env.slack.example .env
Edit
.env
and fill in your values based on your chosen mode:
For HTTP Webhook Mode (default):
SLACK_BOT_TOKEN=xoxb-your-actual-bot-token
SLACK_SIGNING_SECRET=your-actual-signing-secret
SLACK_BOT_USER_ID=U1234567890 # Optional but recommended
QODO_API_KEY=your-qodo-api-key
# SLACK_USE_SOCKET_MODE=false # This is the default
For Socket Mode:
SLACK_BOT_TOKEN=xoxb-your-actual-bot-token
SLACK_APP_TOKEN=xapp-your-actual-app-token
SLACK_USE_SOCKET_MODE=true
SLACK_BOT_USER_ID=U1234567890 # Optional but recommended
QODO_API_KEY=your-qodo-api-key
# No SLACK_SIGNING_SECRET needed for Socket Mode
Step 6: Find Your Bot User ID (Optional but Recommended)
In your Slack workspace, mention your bot:
@YourBotName
Right-click on the bot mention and select "Copy link"
The link will contain the user ID:
https://yourworkspace.slack.com/team/U1234567890
Copy the
U1234567890
part to your.env
file
Step 7: Test Your Setup
Start the Slack bot:
qodo --slack
Or with a custom port:
qodo --slack --port 3000
You should see different output depending on your mode:
HTTP Webhook Mode:
🚀 Starting Slack Bot... 📡 Using HTTP Webhook (webhook mode) 🔗 Slack event handler listening on port 4444 📡 Webhook URL: http://localhost:4444/slack/events ✅ Slack Bot is running and listening for events 🌐 Webhook Mode: Ensure your endpoint is publicly accessible
Socket Mode:
🚀 Starting Slack Bot... 📡 Using Socket Mode (socket mode) 🚀 Starting Slack Socket Mode connection... ✅ Socket Mode connected to Slack 🔗 Socket Mode handler started successfully ✅ Slack Bot is running and listening for events 🔌 Socket Mode: No public endpoint required
In Slack, mention your bot:
@YourBotName help
The bot should respond with available commands.
Step 8: Configure Your Agent Commands
Create an agent configuration file (e.g., agent.toml
):
[commands.review]
description = "Review code for issues and improvements"
instructions = "Please review the provided code for potential issues, bugs, and improvements."
[commands.test]
description = "Generate or run tests"
instructions = "Help with testing - generate test cases or run existing tests."
[commands.deploy]
description = "Help with deployment tasks"
instructions = "Assist with deployment processes and configurations."
Then start the bot with your agent file:
qodo --slack --agentFile=agent.toml
Switching Between Modes
You can easily switch between HTTP Webhook and Socket Mode by changing your environment variables:
Switch to Socket Mode:
# Add these to your .env file
SLACK_USE_SOCKET_MODE=true
SLACK_APP_TOKEN=xapp-your-app-token
# Remove or comment out SLACK_SIGNING_SECRET
Switch to HTTP Webhook Mode:
# Remove or comment out these from your .env file
# SLACK_USE_SOCKET_MODE=true
# SLACK_APP_TOKEN=xapp-your-app-token
# Add back SLACK_SIGNING_SECRET
SLACK_SIGNING_SECRET=your-signing-secret
Restart the bot after making changes.
Troubleshooting
Bot Not Responding
For HTTP Webhook Mode:
Check that your webhook URL is accessible from the internet
Verify your bot token and signing secret are correct
Ensure your Slack app's Request URL is set correctly
For Socket Mode:
Verify your bot token and app-level token are correct
Check that Socket Mode is enabled in your Slack app settings
Ensure your app-level token has
connections:write
scope
For Both Modes:
Check the bot has the required OAuth scopes
Make sure the bot is invited to the channel
Verify the bot is mentioned correctly (e.g.,
@YourBotName
)
Environment Variable Errors
"SLACK_SIGNING_SECRET is required":
You're in HTTP Webhook mode but missing the signing secret
Either add the signing secret or switch to Socket Mode
"SLACK_APP_TOKEN is required":
You're in Socket Mode but missing the app-level token
Either add the app-level token or switch to HTTP Webhook mode
"Unknown command" Errors
Ensure your agent configuration file is loaded
Check that command names match exactly
Verify the agent file syntax is correct
Permission Errors
Make sure the bot has the required OAuth scopes
Check that the bot is invited to channels where you're trying to use it
Verify your Qodo API key is valid
Local Development
For local development, you'll need to expose your local server to the internet so Slack can send events to it. You can use tools like:
ngrok:
ngrok http 3000
localtunnel:
lt --port 4444
Update your Slack app's Request URL with the public URL provided by these tools.
Production Deployment
For production:
Deploy your bot to a server with a public HTTPS URL
Update the Request URL in your Slack app settings
Set environment variables on your server
Ensure your server can handle Slack's event delivery requirements
Consider using a process manager like PM2 to keep the bot running
Usage Examples
Once set up, you can use the bot like this:
@YourBotName review this pull request
@YourBotName test the authentication module
@YourBotName deploy to staging with extra logging
@YourBotName help
The bot maintains separate conversation sessions per thread, so you can have multiple ongoing conversations.
Was this helpful?