Voice Assistant API (Binary Input & Portal Messaging)

Processes raw binary audio or text. Handles commands (Call/SMS enriched via Contact & Portal APIs) and general AI queries.

Auth: Authentication: header required for /assistant, /api/text.
Logic: 1. Hardcoded commands (Call/SMS try contact lookup). 2. AI fallback for Nav/Call/SMS (tries contact lookup). 3. Message to "PORTAL" uses dedicated API. 4. General AI. Commands always return JSON.

POST /assistant

Body: Raw PCM audio (e.g., Content-Type: audio/l16; rate=16000)

Response: Command JSON (Result:0, X-Response-Type:command) or AI Text (Result:0, X-Response-Type:ai_text) or AI Audio Stream (Result:1, X-Response-Type:ai_audio with X-Response-Text header).

// Example Command Response (Call Mom)
{
  "feature": 7,
  "parameters": { "who": "Mom", "to": "+123...", "contact_name": "Mom (Mobile)" }
}
// Example Command Response (Message Portal Success - Handled by Server, User gets Confirmation via AI Text/Audio)
// The direct response from /assistant would be the confirmation text/audio.
// If you need ESP32 to know portal message was attempted, server would need to send command JSON like:
// { "feature": 9, "parameters": { "recipient": "PORTAL", "status": "sent_to_portal", "api_response": { ...portal_api_json_response... } } }
// Current logic: if portal send succeeds/fails, it returns (user_message, False) to trigger AI text/audio response.

POST /api/text

Body: JSON {"text": "user query"}

Response: Command JSON or AI Text JSON {"response": "...", "is_command": false}.

GET /health

Service status.