Slack App
TL;DR
The Slack channel (pip install "cmdop-bot[slack]") uses slack-bolt with Socket Mode to
control CMDOP machines from Slack. All commands use the /cmdop prefix. Requires a bot
token (xoxb-) and app-level token (xapp-). Supports Block Kit messages, interactive
buttons, and PermissionManager integration. No public webhooks needed.
Control your CMDOP machines from Slack using Socket Mode. Built on slack-boltΒ .
How do I set up a Slack app?
- Create app at Slack APIΒ
- Enable Socket Mode and get App Token (
xapp-...) - Create Bot Token (
xoxb-...) - Add slash command
/cmdop - Install to workspace
How do I install?
# Install cmdop-bot with the Slack extras (includes slack-bolt dependency)
pip install "cmdop-bot[slack]"How do I use the Slack bot?
from cmdop_bot.channels.slack import SlackApp
# Initialize SlackApp with bot token, app-level token, and CMDOP credentials
app = SlackApp(
bot_token="xoxb-YOUR-BOT-TOKEN", # Bot user OAuth token from Slack
app_token="xapp-YOUR-APP-TOKEN", # App-level token for Socket Mode
cmdop_api_key="cmdop_xxx", # Your CMDOP API key
machine="my-server", # Default target machine hostname
)
# Start the bot β connects via Socket Mode (no public URL needed)
app.run()What parameters are available?
| Parameter | Type | Required | Description |
|---|---|---|---|
bot_token | str | Yes | Slack bot token (xoxb-...) |
app_token | str | Yes | Slack app-level token for Socket Mode (xapp-...) |
cmdop_api_key | str | Yes | CMDOP API key |
allowed_users | list[str] | No | Allowed Slack user IDs. None = allow all |
permissions | PermissionManager | No | Fine-grained permission control |
machine | str | No | Default target machine hostname |
model | str | No | AI model tier |
timeout | float | No | Command timeout in seconds (default: 30.0) |
What commands are supported?
All commands use the /cmdop prefix:
| Command | Description |
|---|---|
/cmdop help | Show available commands |
/cmdop shell <cmd> | Execute shell command |
/cmdop exec <cmd> | Alias for shell |
/cmdop agent <task> | Run AI agent task |
/cmdop ls [path] | List directory |
/cmdop cat <path> | Read file |
/cmdop machine <hostname> | Set target machine |
/cmdop skills list | List available skills |
/cmdop skills show <name> | Show skill details |
/cmdop skills run <name> <prompt> | Run a skill |
/cmdop skill <name> <prompt> | Run a skill (shorthand) |
/cmdop status | Show connection status |
What features does the Slack bot have?
- Socket Mode (no public webhooks needed)
- Block Kit messages for rich formatting
- Interactive buttons
- Slash command handling
What environment variables are used?
# Slack bot user OAuth token (starts with xoxb-)
export SLACK_BOT_TOKEN="xoxb-your-bot-token"
# Slack app-level token for Socket Mode (starts with xapp-)
export SLACK_APP_TOKEN="xapp-your-app-token"
# CMDOP API key for authenticating with the CMDOP service
export CMDOP_API_KEY="cmdop_xxx"
# Default target machine hostname for commands
export CMDOP_MACHINE="my-server"How do I add permissions?
from cmdop_bot.channels.slack import SlackApp
from cmdop_bot import PermissionManager, PermissionLevel
# Create a PermissionManager to control who can run what
pm = PermissionManager()
# Grant full admin access to a specific Slack user (by user ID)
pm.add_admin("slack:U12345678")
# Grant execute-level access to another user, scoped to a specific machine
pm.grant("slack:U87654321", machine="dev-server", level=PermissionLevel.EXECUTE)
# Pass the PermissionManager to SlackApp to enforce access control
app = SlackApp(
bot_token="xoxb-...",
app_token="xapp-...",
cmdop_api_key="cmdop_xxx",
permissions=pm, # Attach permission rules
)
# Start the bot with permission enforcement active
app.run()How do I configure the Slack app?
Required Scopes (Bot Token)
chat:writeβ Send messagescommandsβ Handle slash commands
Optional Scopes
app_mentions:readβ Respond to @mentions
Socket Mode
Enable Socket Mode in your app settings to use xapp- tokens. This allows your bot to receive events without a public URL.
Slash Command Setup
- Go to βSlash Commandsβ in your app settings
- Create new command:
/cmdop - Description: βControl CMDOP machinesβ
- Usage hint:
shell <command> | agent <task> | ls [path] | cat <path> | skills list|show|run
Last updated on