relaybot
v1.0.10
Published
An AI assistant that lives in your Slack DMs — powered by Claude or Codex
Maintainers
Readme
RelayBot
An AI assistant that lives in your Slack channels and DMs — powered by Claude or Codex.
What is RelayBot?
RelayBot acts as a bridge between Slack and AI coding agents, allowing you to interact with Claude or Codex by mentioning the bot in channels or sending a DM. Instead of switching between tools, you can request code changes, ask questions, and manage development tasks without leaving Slack.
Key Features
- Conversational AI Access — Chat with Claude or Codex from Slack channels via mentions or via DM
- Code Execution — AI can read, write, and modify code in your projects
- Task Automation — Request file changes, refactoring, bug fixes, or new features
- Context-Aware Responses — Maintains project directory context across conversations
- Summarized Replies — Long AI outputs are condensed into concise, actionable messages
- Persistent Sessions — AI session stays alive between messages, preserving context
Use Cases
- Quick Code Changes — "Add a loading spinner to the login button"
- Code Review — "Review the latest PR and suggest improvements"
- Bug Investigation — "Why is the checkout flow failing for guest users?"
- Refactoring — "Refactor the authentication module to use async/await"
- Documentation — "Generate API docs for the user service"
- Learning — "Explain how the caching layer works in this codebase"
Architecture
┌─────────────────────────────────────────────────────────────────────┐
│ SLACK │
│ ┌──────────┐ ┌──────────────┐ │
│ │ User │ ───── sends message ─────────────► │ Channel/ │ │
│ │ │ ◄──── receives reply ───────────── │ Channel │ │
│ └──────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
│ ▲
│ │
Slack WebSocket │ │ Slack Sender
(Socket Mode) │ │
▼ │
┌─────────────────────────────────────────────────────────────────────┐
│ RELAYBOT │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │ Slack Listener │ │
│ │ (Socket Mode Connection) │ │
│ └────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ forwards message │
│ ▼ │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │ PTY Bridge │ │
│ │ Spawns persistent AI CLI process │ │
│ └────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
│
│ stdin/stdout
▼
┌─────────────────────────────────────────────────────────────────────┐
│ CLAUDE / CODEX CLI │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │ AI Agent Session │ │
│ │ • Processes user requests │ │
│ │ • Executes tasks (code, commands, etc.) │ │
│ │ • Maintains project context │ │
│ └────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ summarizes response │
│ ▼ │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │ Response Summarizer │ │
│ │ • Condenses long outputs to concise messages │ │
│ │ • Includes relevant links (PRs, docs, etc.) │ │
│ │ • Sends reply back to Slack │ │
│ └────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘How It Works
- Slack Connection — RelayBot connects to Slack via WebSocket (Socket Mode) and listens for mentions and DMs
- Message Reception — When you send a message, Slack forwards it to RelayBot
- AI Bridge — RelayBot spawns a persistent Claude or Codex CLI session and forwards your message
- AI Processing — The AI processes your request with full access to your codebase
- Response Summarization — Long outputs are summarized into concise, actionable messages
- Slack Reply — The summarized response is sent back to the same channel or DM
Slack Commands
Send these as a DM to the bot (or in a channel mention) to control the agent session:
$status— Show whether the agent is running, plus PID, start time, uptime, cwd, WORKING_DIR, and last exit$stop— Stop the agent session (equivalent to Ctrl-C)$start [--codex] [--noyolo]— Start the agent with optional flags$restart [--codex] [--noyolo]— Restart the agent with optional flags$dir /path/to/working/dir— Update the configured working directory (must exist).
Examples:
$status
$stop
$start --codex
$restart --noyolo
$dir /Users/you/work/projectInstallation
Option 1: Install via npm (Recommended)
npm install -g relaybotThen run:
# Configure Slack credentials
relaybot setup
# Start the bot (Claude by default)
relaybot start
# Start the bot with Codex
relaybot start --codex
# Start the bot without auto-approve flags
relaybot start --noyoloOption 2: Run from Source
# Clone the repository
git clone https://github.com/dinhquan/relaybot.git
cd relaybot
# Install dependencies
npm install
# Configure Slack credentials
npm run setup
# Start the bot (Claude by default)
npm start
# Start the bot with Codex
node main.js --codex
# Start the bot without auto-approve flags
node main.js --noyolo
`--noyolo` disables passing `--yolo` (Codex) or `--dangerously-skip-permissions` (Claude) to the underlying CLI.Setup
Before running the bot, you need to configure your Slack credentials.
Interactive Setup
Run the setup command and follow the prompts:
# If installed globally
relaybot setup
# If running from source
npm run setupYou will be asked for:
- SLACK_BOT_TOKEN - Bot User OAuth Token (starts with
xoxb-) - SLACK_APP_TOKEN - App-Level Token (starts with
xapp-) - SLACK_USER_ID (optional) - Your Slack User ID (starts with
U). Provide this to prevent the bot from replying to other users. - WORKING_DIR (optional) - Directory where the AI will operate. Set this to give the bot better context about where to work.
Manual Setup
Alternatively, create the config file manually at ~/.relaybot/config.conf:
mkdir -p ~/.relaybotThen create ~/.relaybot/config.conf:
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_APP_TOKEN=xapp-your-app-token
SLACK_USER_ID=U0XXXXXXXX
WORKING_DIR=/path/to/directoryCreating a Slack App
If you don't have a Slack app yet, follow these steps:
1. Create the App
- Go to api.slack.com/apps
- Click Create New App
- Choose From a manifest (recommended) and paste the contents of
manifest.jsonfrom this repo, then skip to step 5 - Or choose From scratch to configure manually (continue with steps below)
- Choose From scratch
- Enter an app name (e.g., "RelayBot") and select your workspace
- Click Create App
2. Enable Socket Mode
Socket Mode allows the bot to receive events via WebSocket instead of HTTP endpoints.
- Go to Socket Mode in the left sidebar
- Toggle Enable Socket Mode to ON
- You'll be prompted to create an App-Level Token:
- Token Name:
socket-token(or any name) - Scope:
connections:write - Click Generate
- Token Name:
- Copy the token (starts with
xapp-) — this is your SLACK_APP_TOKEN
3. Configure Bot Permissions
- Go to OAuth & Permissions in the left sidebar
- Scroll to Scopes → Bot Token Scopes
- Add these scopes:
chat:write— Send messagesapp_mentions:read— Read mentions of your appim:history— Read DM historyim:read— View DM metadataim:write— Start DMs with usersusers:read— View user info
4. Enable Event Subscriptions
- Go to Event Subscriptions in the left sidebar
- Toggle Enable Events to ON
- Expand Subscribe to bot events
- Add these events:
app_mention— Receive mentions in channelsmessage.im— Receive DM messages
5. Install the App
- Go to Install App in the left sidebar
- Click Install to Workspace
- Review permissions and click Allow
- Copy the Bot User OAuth Token (starts with
xoxb-) — this is your SLACK_BOT_TOKEN
6. Get Your User ID
- Open Slack
- Click on your profile picture → Profile
- Click the ⋮ (more) button
- Click Copy member ID — this is your SLACK_USER_ID
Summary of Tokens
| Token | Where to Find | Format |
|-------|---------------|--------|
| SLACK_BOT_TOKEN | OAuth & Permissions → Bot User OAuth Token | xoxb-... |
| SLACK_APP_TOKEN | Basic Information → App-Level Tokens | xapp-... |
| SLACK_USER_ID | Slack Profile → Copy member ID | U0XXXXXXXX (optional) |
Requirements
- Node.js v14+
- Claude CLI or Codex CLI available on PATH
Configuration
Configuration is stored in ~/.relaybot/config.conf.
| Variable | Description |
|----------|-------------|
| SLACK_BOT_TOKEN | Slack Bot OAuth token (xoxb-...) |
| SLACK_APP_TOKEN | Slack App-level token for Socket Mode (xapp-...) |
| SLACK_USER_ID | Optional. Restricts replies to a single user (U0XXXXXXXX) |
| WORKING_DIR | Optional. Directory where the AI will operate for better context |
