Spaces:
Running
Running
Add GET /api/chat/pending for Chief of Staff polling
Browse files
README.md
CHANGED
|
@@ -19,16 +19,17 @@ Public FastAPI bridge for the Command Center PWA (`https://simzy420.github.io`).
|
|
| 19 |
| Method | Path | Auth | Description |
|
| 20 |
|--------|------|------|-------------|
|
| 21 |
| GET | `/health` | none | Health check `{ ok: true }` |
|
| 22 |
-
| OPTIONS | `/api/chat`, `/api/chat/reply` | none | CORS preflight |
|
| 23 |
| POST | `/api/chat` | none | Client sends a user message; forwards to Grok webhook |
|
| 24 |
| GET | `/api/chat?sessionId=` | none | Poll session messages |
|
|
|
|
| 25 |
| POST | `/api/chat/reply` | Bearer `CHAT_BRIDGE_SECRET` | Grok/agent posts assistant replies |
|
| 26 |
|
| 27 |
## Space secrets (set in Settings → Variables and secrets)
|
| 28 |
|
| 29 |
| Secret | Required | Purpose |
|
| 30 |
|--------|----------|---------|
|
| 31 |
-
| `CHAT_BRIDGE_SECRET` | **yes** | Bearer token for `POST /api/chat/reply` |
|
| 32 |
| `GROK_WEBHOOK_URL` | for live Grok | Webhook URL that receives client chat payloads |
|
| 33 |
| `GROK_WEBHOOK_SENDER_KEY` | for live Grok | Sent as `Authorization: Bearer …`, `X-Webhook-Key`, and `?key=` |
|
| 34 |
|
|
@@ -58,6 +59,10 @@ curl -s -X POST https://simzy-command-center-chat.hf.space/api/chat/reply \
|
|
| 58 |
-H 'Content-Type: application/json' \
|
| 59 |
-H 'Authorization: Bearer YOUR_CHAT_BRIDGE_SECRET' \
|
| 60 |
-d '{"sessionId":"demo","clientMsgId":"m1","botId":"grok","text":"hi back","status":"final"}'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
```
|
| 62 |
|
| 63 |
Hardware: CPU basic. Visibility: public (phone PWA must call it; secrets stay in Space secrets).
|
|
|
|
| 19 |
| Method | Path | Auth | Description |
|
| 20 |
|--------|------|------|-------------|
|
| 21 |
| GET | `/health` | none | Health check `{ ok: true }` |
|
| 22 |
+
| OPTIONS | `/api/chat`, `/api/chat/reply`, `/api/chat/pending` | none | CORS preflight |
|
| 23 |
| POST | `/api/chat` | none | Client sends a user message; forwards to Grok webhook |
|
| 24 |
| GET | `/api/chat?sessionId=` | none | Poll session messages |
|
| 25 |
+
| GET | `/api/chat/pending` | Bearer `CHAT_BRIDGE_SECRET` | Unanswered user messages (no assistant `final` yet), oldest first, max 50 |
|
| 26 |
| POST | `/api/chat/reply` | Bearer `CHAT_BRIDGE_SECRET` | Grok/agent posts assistant replies |
|
| 27 |
|
| 28 |
## Space secrets (set in Settings → Variables and secrets)
|
| 29 |
|
| 30 |
| Secret | Required | Purpose |
|
| 31 |
|--------|----------|---------|
|
| 32 |
+
| `CHAT_BRIDGE_SECRET` | **yes** | Bearer token for `POST /api/chat/reply` and `GET /api/chat/pending` |
|
| 33 |
| `GROK_WEBHOOK_URL` | for live Grok | Webhook URL that receives client chat payloads |
|
| 34 |
| `GROK_WEBHOOK_SENDER_KEY` | for live Grok | Sent as `Authorization: Bearer …`, `X-Webhook-Key`, and `?key=` |
|
| 35 |
|
|
|
|
| 59 |
-H 'Content-Type: application/json' \
|
| 60 |
-H 'Authorization: Bearer YOUR_CHAT_BRIDGE_SECRET' \
|
| 61 |
-d '{"sessionId":"demo","clientMsgId":"m1","botId":"grok","text":"hi back","status":"final"}'
|
| 62 |
+
|
| 63 |
+
# Pending unanswered (agent poll; use your CHAT_BRIDGE_SECRET)
|
| 64 |
+
curl -s https://simzy-command-center-chat.hf.space/api/chat/pending \
|
| 65 |
+
-H 'Authorization: Bearer YOUR_CHAT_BRIDGE_SECRET'
|
| 66 |
```
|
| 67 |
|
| 68 |
Hardware: CPU basic. Visibility: public (phone PWA must call it; secrets stay in Space secrets).
|