Overview
TheuseWebVoiceAgent hook provides a complete React integration for NAVAI voice agents. It manages the entire lifecycle of voice agent connections, including initialization, backend communication, function loading, and session management.
Import
Signature
Parameters
Configuration options for the voice agent hook.
Return Value
An object containing the voice agent state and control methods.
Example Usage
Lifecycle
- Initialization: Hook sets up memoized backend client and runtime config promise
- Start: Call
start()to begin connection sequence - Connecting: Backend secret created, functions loaded, agent built
- Connected: Realtime session established with OpenAI
- Stop: Call
stop()to gracefully close the session - Cleanup: Hook automatically calls
stop()on unmount
Error Handling
Source Reference
Defined in:packages/voice-frontend/src/useWebVoiceAgent.ts:52