From the react hooks, when joining a room, which o...
# ask-ai
q
From the react hooks, when joining a room, which one can I use to determine if the audio session was bootstrapped and the agent is ready to speak ?
t
Thanks for reaching out, Andrei. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I’m here to help you understand how to check if the audio session has been bootstrapped and if the agent is ready to speak when joining a room. You can use the
useAgent
React hook for this. It offers some really useful properties and methods to manage audio session readiness: •
isAvailable
: This tells you if the agent is ready to interact with users. It returns
true
when the agent is in states like
'listening'
,
'thinking'
, or
'speaking'
. •
isBufferingSpeech
: This helps you track the audio session bootstrapping by indicating if the audio preconnect buffer is active, meaning the agent hasn’t connected just yet. •
state
: This gives you the current state of the agent, such as
'initializing'
,
'idle'
,
'listening'
,
'thinking'
, or
'speaking'
. Additionally, you can use the
waitUntilAvailable(signal?: AbortSignal)
method to patiently wait until the agent is ready for interaction. This hook is thoughtfully designed to help with audio session readiness and managing the agent’s state in LiveKit React applications. If you have any questions or need further guidance, feel free to ask—I’m here to support you! Sources: packages/react/src/context/session-context.ts