# Dobby Tenant Onboarding

## What You Get

- **Dashboard**: `https://tN.dobby-orchestrator.uk/dashboard`
- **Slack bot**: submit tasks, check status, get results
- **Spoke agents**: run on your machines, execute tasks via Claude Code

---

## 1. Slack Setup (2 min)

1. Open [api.slack.com/apps](https://api.slack.com/apps) -> **Create New App** -> **From an app manifest**
2. Select your workspace, switch to **YAML**, paste contents of [`slack-app-manifest.yml`](slack-app-manifest.yml) -> **Create**
3. **Basic Information** -> **App-Level Tokens** -> **Generate Token** (name: `dobby`, scope: `connections:write`) -> copy the `xapp-...` token
4. **Install App** -> **Install to Workspace** -> copy the `xoxb-...` token
5. Create `#dobby` and `#dobby-report` channels, type `/invite @Dobby` in each
6. Right-click each channel -> **View channel details** -> copy Channel ID from the bottom

Send these to the admin:
```
SLACK_BOT_TOKEN=xoxb-...
SLACK_APP_TOKEN=xapp-...
SLACK_CHANNEL=C...
SLACK_REPORT_CHANNEL=C...
```

---

## 2. Install Spoke (Your Machine)

```bash
pip install dobby-orchestrator
npm install -g @anthropic-ai/claude-code
claude  # authenticate in browser
```

Start the spoke:
```bash
dobby agent --hub https://tN.dobby-orchestrator.uk --id my-mac
```

That's it. The spoke registers with the hub and starts polling for tasks.

> **Background mode:** `nohup dobby agent --hub https://tN.dobby-orchestrator.uk --id my-mac > spoke.log 2>&1 &`

---

## 3. Add a Remote Spoke (Optional)

Same steps on any remote machine (EC2, GPU server):

```bash
ssh user@server
pip install dobby-orchestrator && npm install -g @anthropic-ai/claude-code && claude
dobby agent --hub https://tN.dobby-orchestrator.uk --id my-gpu
```

---

## 4. Usage

**Slack:**
```
@Dobby fix the login bug in myproject     # submit task
@Dobby status                              # queue overview
@Dobby cancel t-xxx                        # cancel a task
```

**Dashboard:** `https://tN.dobby-orchestrator.uk/dashboard`

**API:**
```bash
curl https://tN.dobby-orchestrator.uk/tasks                    # list tasks
curl -X POST https://tN.dobby-orchestrator.uk/tasks \
  -H "Content-Type: application/json" \
  -d '{"description": "fix login bug", "project": "myproject"}'  # add task
```

---

## Troubleshooting

| Problem | Fix |
|---------|-----|
| Spoke can't connect | `curl https://tN.dobby-orchestrator.uk/health` |
| Bot not responding | `/invite @Dobby` in the channel |
| Claude auth expired | Run `claude` to re-authenticate |

Replace **N** with your tenant number everywhere.
