Slack
Deploy a Slack bot that answers database questions in natural language via Socket Mode.
RDST can run as a Slack bot that answers natural-language database questions. The bot uses Socket Mode, so you do not need a public URL, the bot connects outbound to Slack from wherever RDST is running.
Common usage
# One-time Slack app setup (interactive wizard)
rdst slack setup
# Start the bot for a specific agent
rdst slack start --agent sales-bot
# List configured agents
rdst slack list
# Check bot status
rdst slack status --agent sales-botHow it works
The bot:
- Reads messages directed at it (mentions, DMs) in channels it has access to
- Routes each message through the underlying data agent
- Generates SQL with
rdst ask, runs the agent's guard - Returns the result as a threaded reply with the SQL and data
No part of the flow requires a public URL or reverse proxy.
Setup
Create a Slack app. Run rdst slack setup: it walks you through creating
a Slack app with the right scopes and enabling Socket Mode.
rdst slack setupThe wizard prints the OAuth scopes and event subscriptions you need, then asks for the App-Level Token and Bot User OAuth Token your Slack app issues.
Create a data agent if you haven't already. This is what the bot will serve.
rdst guard create --name pii-safe \
--mask "*.email:email" \
--require-where \
--no-select-star
rdst agent create --name sales-bot \
--target prod-orders \
--guard pii-safe \
--description "Read-only sales data"See Data Agents for guard and agent patterns.
Start the bot. This is a foreground process, keep it running in a terminal, a tmux pane, or a systemd service.
rdst slack start --agent sales-bot✓ Connected to Slack as @sales-bot
✓ Socket Mode active
✓ Guard: pii-safe (7 rules)
✓ Target: prod-orders (PostgreSQL 15.4)
Listening for messages ...Invite the bot to the channels where it should respond, then @mention
or DM it with a question:
@sales-bot How many orders did we process last week?
For a production deployment, run rdst slack start under a process supervisor
(systemd, pm2, Docker, Kubernetes) so it restarts on failure. The bot is
stateless. You can restart it without losing any Slack state.
What the bot replies look like
ellen: @sales-bot top 5 customers by revenue this month
sales-bot:
Generated SQL (ran via guard pii-safe ✓):
```sql
SELECT c.id, c.name, SUM(o.total_cents) AS revenue_cents
FROM customers c
JOIN orders o ON o.customer_id = c.id
WHERE o.created_at >= DATE_TRUNC('month', NOW())
AND o.status = 'paid'
AND o.tenant_id = $1
GROUP BY c.id, c.name
ORDER BY revenue_cents DESC
LIMIT 5;| id | name | revenue_cents |
|---|---|---|
| 42 | Acme Manufacturing | 4,820,135 |
| 118 | Blue Orchid Foods | 3,914,200 |
| 745 | Hendricks Retail | 3,120,980 |
| ... |
5 rows, 84 ms
Every reply shows the SQL, the guard that was applied, and the results. Users
never see raw upstream errors.
## Managing multiple agents
You can run **one Slack bot per agent**. Typical pattern:
```bash
# Customer-support team
rdst slack start --agent support-bot &
# Sales team
rdst slack start --agent sales-bot &
# Engineering dashboard
rdst slack start --agent eng-dashboard &Each bot has its own app token and operates independently. List what's configured:
rdst slack list
rdst slack status --agent sales-botSecurity considerations
- Every question runs through the agent's guard before SQL is generated and again before execution. Output masking applies automatically.
- Slack Socket Mode never exposes an inbound port. All traffic is outbound from the host running RDST.
- The Slack app tokens are managed by you. If a token leaks, revoke it in the Slack admin panel; the bot stops working immediately.
- Every question and its SQL are logged locally (for audit), but result rows are not logged: only the row count.
Flags reference
| Command | Flag | Purpose |
|---|---|---|
rdst slack setup | : | Interactive setup wizard |
rdst slack start | -a, --agent <name> | Agent to serve |
rdst slack list | : | List configured agents |
rdst slack status | -a, --agent <name> | Show connection status for one agent |
See also
- Data Agents: what the Slack bot is serving
- Guards: the safety policies that protect what users in Slack can see
rdst ask: the underlying NL-to-SQL engine the bot uses