happy-mouse-590
08/18/2025, 10:00 PMtall-airline-16756
08/18/2025, 10:00 PMtall-airline-16756
08/18/2025, 10:01 PMparticipantConnected
event from LiveKit's Room API. Let me walk you through it:
1. Listen for the Participant Connected Event: Use the room.on()
method to catch the participantConnected
event. This fires every time someone new joins the room.
2. Spot if the Participant is an Agent: When this event happens, check the participant’s kind
property. If it says "AGENT"
, you’ve got yourself an agent joining.
3. Take Action When an Agent Joins: Once you know it’s an agent, you can update your UI, log the event, or trigger any other logic you need.
Here’s a quick example in JavaScript to get you started:
room.on('participantConnected', (participant) => {
if (participant.kind === 'AGENT') {
console.log('Agent has joined the room:', participant.identity);
// Feel free to update your UI or handle the agent’s presence here
}
});
This way, you’ll be in the loop right away when an agent joins, and your frontend can respond smoothly. Hope this helps!