Skip to Content

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?

  1. Create app at Slack API 
  2. Enable Socket Mode and get App Token (xapp-...)
  3. Create Bot Token (xoxb-...)
  4. Add slash command /cmdop
  5. 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?

ParameterTypeRequiredDescription
bot_tokenstrYesSlack bot token (xoxb-...)
app_tokenstrYesSlack app-level token for Socket Mode (xapp-...)
cmdop_api_keystrYesCMDOP API key
allowed_userslist[str]NoAllowed Slack user IDs. None = allow all
permissionsPermissionManagerNoFine-grained permission control
machinestrNoDefault target machine hostname
modelstrNoAI model tier
timeoutfloatNoCommand timeout in seconds (default: 30.0)

What commands are supported?

All commands use the /cmdop prefix:

CommandDescription
/cmdop helpShow 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 listList 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 statusShow 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 messages
  • commands — 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

  1. Go to “Slash Commands” in your app settings
  2. Create new command: /cmdop
  3. Description: “Control CMDOP machines”
  4. Usage hint: shell <command> | agent <task> | ls [path] | cat <path> | skills list|show|run
Last updated on