Get Queue
Retrieve all dispatch queue items sorted by priority
Endpoint
Description
Returns all items in the dispatch queue, sorted by risk level, status, and creation time. Items remain in the queue through their lifecycle (OPEN → IN_PROGRESS → DISPATCHED → RESOLVED).Request
No parameters required.cURL Example
Response
Returns an array of queue items.Call ID (same as
call_session_id)Risk classification:
CRITICAL, ELEVATED, NORMAL, or LOWNumeric risk score (0.0 to 1.0)
Service category:
EMS, FIRE, POLICE, or OTHERArray of semantic tags extracted from call (e.g.,
["FIRE", "SMOKE"])Caller’s emotional state (e.g.,
"DISTRESSED", "CALM")AI-generated summary of the call
Current queue status:
OPEN, IN_PROGRESS, DISPATCHED, RESOLVED, or CANCELLEDISO 8601 timestamp when call ended and queue item was created
Masked caller phone number (only last 4 digits, e.g.,
"•••1234")Emergency number called
Success Response (200 OK)
Empty Queue (200 OK)
Sorting Logic
Items are sorted by:-
Combined Weight (descending)
- Risk weight:
CRITICAL=3,ELEVATED=2,NORMAL=1,LOW=0 - Status weight:
OPEN=100,IN_PROGRESS=80,DISPATCHED=60,RESOLVED=-100,CANCELLED=-120 - Combined = Risk weight + Status weight
- Risk weight:
- Risk Score (descending) - for items with same weight
- Creation Time (ascending) - oldest first for items with same weight and score
- CRITICAL + OPEN items appear first
- Active items (OPEN, IN_PROGRESS) stay at top
- Resolved/cancelled items sink to bottom
- Within same priority, older calls come first
Implementation
Location:app/main.py:732-775
Get Live Queue
Retrieve calls currently in progress with real-time updates
Endpoint
Description
Returns calls that are currently active and streaming audio. This endpoint provides real-time updates of transcription, distress scores, and risk levels while calls are in progress.Request
No parameters required.cURL Example
Response
Call session ID
Telnyx call control ID
Masked caller number
Called number
ISO 8601 timestamp when call started
Call status:
LIVEReal-time partial transcript (updated as caller speaks)
Current distress score (0.0 to 1.0)
Maximum distress score observed during call
Seconds of voice activity detected
Current risk assessment (updates in real-time)
Current risk score
Detected emotion (may be null during active call)
Service category (may be null during active call)
Extracted tags (usually empty during active call)
Summary text (usually “Listening…” during active call)
Success Response (200 OK)
Implementation
Location:app/main.py:777-811
Usage Notes
- This endpoint is designed for polling (every 1-2 seconds)
- Used by live call monitoring dashboards
- Items appear when call is answered, removed when call ends
- Risk levels update in real-time based on audio analysis
- Final analysis happens on hangup and creates queue item
Update Queue Status
Update the status of a queue item
Endpoint
Path Parameters
The call ID (queue item ID) to update
Request
Headers
Must be
application/jsonRequest Body
New status value:
OPEN, IN_PROGRESS, DISPATCHED, RESOLVED, or CANCELLEDOptional note to record with status change
Example Request
cURL Example
Response
Returns the updated queue item.Call ID
Updated status
Risk level
Risk score
Service category
Semantic tags
Caller emotion
Call summary
Creation timestamp
Array of status change records (if notes were provided)
Success Response (200 OK)
Error Response (404 Not Found)
Implementation
Location:app/main.py:847-878
Usage Notes
- Status transitions are not enforced (can move to any status)
- Consider implementing workflow rules in production:
OPEN→IN_PROGRESS→DISPATCHED→RESOLVED- Prevent moving back to earlier states
- Log all status changes
- The
notefield is optional but recommended for audit trails - Status history is stored in memory (will be lost on restart in dev mode)