What would be the best way to add a Loading "Diali...
# ask-ai
f
What would be the best way to add a Loading "Dialing" screen that dissapears just when the agent has joined the call
t
Thanks for reaching out, Carlos. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd be happy to help you add a loading or "Dialing" screen that disappears when the agent joins the call. Here’s a friendly step-by-step approach you can follow: • Monitor Connection State and Agent Tracks: Keep an eye on the room's connection state and check if the agent’s video or audio track is available. This helps you know exactly when the agent has joined. • Implement Loading States: While waiting for the agent to connect, show a loading spinner or a friendly message. For example, if you’re using React, you can conditionally render this based on the connection state and track presence. • Use Animated Transitions: To make the experience smooth and pleasant, consider using animation libraries like Framer Motion to transition from the loading screen to the active call. This way, users won’t feel any abrupt changes. • Handle Connection Failures: It’s always good to be prepared! Provide a fallback UI and retry options if the agent can’t connect, so your users don’t end up stuck in an empty room. If you’d like, I can also provide detailed code examples or guide you through this on a specific platform like React or Android. Just let me know what works best for you! Sources: src/components/playground/Playground.tsx | telephony/sip_lifecycle.py | app/src/main/java/io/livekit/android/example/voiceassistant/screen/ConnectS... | Web and mobile frontends | LiveKit docs
f
Which events would be the right ones to attach ?
t
I'm glad you asked! The best event to keep an eye on when an agent joins a call in LiveKit is the
participantConnected
event. This event fires every time a new participant enters the room, so it’s a great way to detect agents joining. To pinpoint the agent specifically, you can look at the
kind
property of the participant object. For instance, an agent participant will have
participant.kind === ParticipantKind.AGENT
. If you'd like, I’d be happy to walk you through more details or provide some examples on how to set this up. Just let me know! Sources: agent-console/lib/event-types.ts | telephony/sip_lifecycle.py | Web and mobile frontends | LiveKit docs
f
So the approach would be to join the call, and listen to those events from the frontend and show/hide the screens ?
t
Yes, that's absolutely right! Here's how you can approach it: 1. Join the call from the frontend. 2. Keep an eye out for the
participantConnected
event, which tells you when the agent has joined the room. 3. Use that event to manage your loading or dialing screen—like hiding the loading screen and showing the active session view once the agent is there. This way, your users will enjoy a smooth and seamless experience. If you’d like, I’m here to help you with any part of the implementation—just let me know!