wonderful-account-72949
09/11/2025, 9:00 AMlivekit-client
sdktall-airline-16756
09/11/2025, 9:01 AMtall-airline-16756
09/11/2025, 9:02 AMlivekit-client
SDK in your React frontend, a great way is to use the useVoiceAssistant
hook from the @livekit/components-react
package. This handy hook gives you access to the agent participant object along with its current state.
Here’s a simple example of how you can set it up:
import { useVoiceAssistant } from '@livekit/components-react';
function MyComponent() {
const { agent } = useVoiceAssistant();
const isAgentInRoom = !!agent; // true if agent is present
return Agent is {isAgentInRoom ? "in" : "not in"} the room.;
}
Now, if you want to see whether the agent is available for interaction, you can check the state
property from the hook. Here’s how you might do that:
import { useVoiceAssistant } from '@livekit/components-react';
function isAgentAvailable(agentState) {
return agentState === 'listening' || agentState === 'thinking' || agentState === 'speaking';
}
function MyComponent() {
const { state: agentState, agent } = useVoiceAssistant();
const isAgentAvailableNow = isAgentAvailable(agentState);
return Agent is currently {agentState}.;
}
This way, you can easily keep track of the agent’s presence and whether it’s ready to interact with you. If you have any questions or want to dive deeper, feel free to ask—I’m here to help!
Sources: packages/react/src/hooks/useVoiceAssistant.ts | Web and mobile frontends | LiveKit Docs | complex-agents/shopify-voice-shopper/shopify-voice-frontend/components/NoAg...