# SendBlue Wiring for Chairman
Full two-way iMessage loop. No Mac Mini FDA required.
## 1. Add credentials to `.env`
Append to `/Users/19keys/sovereign-empire-sweep/content-os/config/.env`:
```
SENDBLUE_API_KEY_ID=<your key id from Sendblue dashboard>
SENDBLUE_API_SECRET_KEY=<your secret>
SENDBLUE_FROM_NUMBER=+1<your assigned Sendblue number>
SENDBLUE_WEBHOOK_SECRET=<webhook secret from Sendblue dashboard>
SENDBLUE_AUTHORIZED_NUMBERS=+1<your iPhone number>
KEYS_IMESSAGE_NUMBER=+1<your iPhone number>
```
Sendblue uses TWO keys: `sb-api-key-id` and `sb-api-secret-key`. Both are required on every call. Get them from the Sendblue dashboard โ API Keys.
## 2. Test outbound
```
cd /Users/19keys/sovereign-empire-sweep/chairman-agent
python3 sendblue.py send +1YOURNUMBER "Chairman online."
```
You should get an iMessage on your phone within seconds.
## 3. Start the inbound webhook locally
```
python3 webhook.py
```
Exposes `http://0.0.0.0:8787/webhook`. Health check at `/health`.
## 4. Expose to the public internet
Pick one:
**Option A โ Cloudflare Tunnel (free, persistent, recommended)**
```
brew install cloudflared
cloudflared tunnel --url http://localhost:8787
```
Copy the `https://<random>.trycloudflare.com` URL it prints.
**Option B โ ngrok**
```
brew install ngrok
ngrok http 8787
```
## 5. Configure SendBlue dashboard
Dashboard โ Webhooks โ Create:
- URL: `https://<your-public-url>/webhook`
- Events: `receive` (inbound messages)
- Secret: the same value you put in `SENDBLUE_WEBHOOK_SECRET`
Save. SendBlue will POST every inbound iMessage to that URL.
## 6. Install as a LaunchAgent (always-on)
```
cp com.chairman.webhook.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.chairman.webhook.plist
```
Check status:
```
launchctl list | grep chairman
tail -f logs/webhook.log
```
## 7. Test round-trip
Text your Sendblue number from your iPhone: `chairman status`
Within ~10-20 seconds you should get a reply generated by the Chairman agent loop (includes bash, file, memory access).
## What this gives you
- **Outbound**: Chairman can text you proactively from heartbeat cycles (alerts, milestones, completed tasks). Tool `text_19keys` is now in his toolkit.
- **Inbound**: You text the Sendblue number, webhook fires Chairman agent, reply comes back. Full execution (bash, files, memory, web search).
- **No AppleScript, no FDA, no Mac Mini dependency.** Works from anywhere as long as the webhook server is reachable.
## Troubleshooting
- **401 bad signature**: the secret in `.env` must match the secret in the SendBlue webhook config exactly.
- **No reply received**: check `logs/webhook.log` for the inbound POST, check `logs/chat.log` for the agent run. SendBlue send errors land in the same log.
- **Unauthorized sender**: add your number to `SENDBLUE_AUTHORIZED_NUMBERS` (comma-separated E.164).