Great — the escalation fields are now in the database. We can now implement STEP 2, exactly as promised, keeping it simple and fully aligned with your current API style. ⸻ ✅ STEP 2 — Add /api/conversations/{id}/escalate This allows Lia (via Make.com) to pause a conversation because she needs a manager, not because the customer said “not right now”. This endpoint will: • Set status = 'paused' • Clear defer_until + defer_reason (not a scheduled defer) • Set escalation_reason (one of the 3) • Set escalation_at = NOW() • Return { status: "ok" } ⸻ ✅ Paste this into Replit Agent Copy + paste the full prompt below directly into the Replit Agent: ⸻ REPLIT AGENT PROMPT (copy/paste this) Add a new API endpoint and DB helper for conversation escalation. 1. Modify app/db.py Add this function: async def escalate_conversation(conversation_id: str, reason: str): """ Set a conversation to paused and mark escalation details. Clears defer fields because this is a manager escalation, not a scheduled pause. """ import uuid from datetime import datetime try: conv_uuid = uuid.UUID(conversation_id) except Exception: return False conn = await get_conn() try: result = await conn.execute(""" UPDATE dp_conversations SET status = 'paused', defer_until = NULL, defer_reason = NULL, escalation_reason = $2, escalation_at = NOW(), updated_at = NOW() WHERE conversation_id = $1 """, conv_uuid, reason) return result == "UPDATE 1" finally: await conn.close() ⸻ 2. Modify app/main.py After the resume endpoint, add: from app.db import escalate_conversation @app.post("/api/conversations/{conversation_id}/escalate", dependencies=[Depends(require_auth)]) async def api_escalate_conversation( conversation_id: str, payload: dict = Body(...), ): """ Mark a conversation as escalated so a manager can step in. """ reason = payload.get("reason") valid_reasons = { "unrecognised_message", "appointment_confirmation_needed", "customer_issue", } if reason not in valid_reasons: return JSONResponse( {"error": f"Invalid reason. Must be one of: {', '.join(valid_reasons)}"}, status_code=400 ) ok = await escalate_conversation(conversation_id, reason) if not ok: return JSONResponse({"error": "Conversation not found"}, status_code=404) return {"status": "ok", "conversation_id": conversation_id, "reason": reason} ⸻ 3. Confirm: Make sure imports include: from fastapi import Body If not, add it. ⸻ When complete, it will allow Make.com to do this: Example escalation: POST → /api/conversations/1234-uuid/escalate { "reason": "appointment_confirmation_needed" } Response: { "status": "ok", "conversation_id": "1234-uuid", "reason": "appointment_confirmation_needed" } ⸻ Reply “Done” once the Replit agent finishes, and we’ll move to: STEP 3 — Add escalation indicators to the T-Card UI (so managers instantly see who needs help) Ready when you are.