Running in to an issue with my outbound-only telep...
# ask-ai
m
Running in to an issue with my outbound-only telephony agent where it seems like two agents end up connecting to the room I create. I have two agents in LK cloud where only one is explicit dispatch. I dispatch the agent to the room after creating the SIP Participant, but there are two agents on the line when the user answers the call. Has anyone ran into this or could recommend a way to debug?
t
Thanks for reaching out, Alexander. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Let's work together to debug the issue of two agents connecting to the same room. Here are some helpful steps you can follow: 1. Check RoomInputOptions: Make sure the RoomInputOptions are set up to allow agent-to-agent communication. Typically, agents listen only to participants of kind
STANDARD
and
SIP
, so you might want to override the RoomInputOptions to include the identity of the target agent. 2. Verify Room and Participant States: Try using the LiveKit API to list the participants in the room. This way, you can confirm that both agents and the SIP participant are present, which helps spot if one agent is missing or disconnected. 3. Monitor SIP Call Status: Keep an eye on the SIP participant's call status (such as "dialing," "active," or "hangup") to ensure the call is moving along as expected. Logging these status changes can be really useful for debugging. 4. Review Dispatch Logic: Double-check that only one agent is dispatched to the room. Sometimes, if multiple agents are dispatched, it can cause conflicts or race conditions. 5. Disable Console Mode: If you’re running in console mode, certain actions like room deletion or adding SIP participants might be ignored. Make sure the job context is properly initialized for production to avoid this. 6. Validate SIP Trunk Configuration: Confirm that your outbound SIP trunk is set up correctly and that the API key has all the permissions it needs. 7. Debug Outbound Calls: Use the
wait_until_answered
option when creating the SIP participant, and check the SIP logs for any errors like "invite-failed" or "media-failed." I hope these steps help you identify and resolve the issue. Please feel free to reach out if you'd like any further guidance or support with any of these steps—I’m here to help! Sources: livekit-agents/livekit/agents/job.py | telephony/make_call/make_call.py | test/lktest/livekit.go | Make outbound calls | LiveKit Docs
m
how do I list the participants in a room when I’m hosting locally?
t
To help you list participants in a room while hosting LiveKit locally, you can use the ListParticipants API from the LiveKit server SDKs. I’ve put together some examples in different programming languages to make it easier for you: • Node.js:
Copy code
import { RoomServiceClient } from 'livekit-server-sdk';

const client = new RoomServiceClient('ws://localhost:7880', 'API_KEY', 'API_SECRET');
const participants = await client.listParticipants('room_name');
console.log(participants);
• Python:
Copy code
from livekit.api import LiveKitAPI

api = LiveKitAPI("http://localhost:7880", "API_KEY", "API_SECRET")
response = await api.room.list_participants(list=ListParticipantsRequest(room="room_name"))
print(response.participants)
• Go:
Copy code
client := lksdk.NewRoomServiceClient("ws://localhost:7880", "API_KEY", "API_SECRET")
resp, err := client.ListParticipants(context.Background(), &livekit.ListParticipantsRequest{Room: "room_name"})
if err != nil {
    log.Fatal(err)
}
fmt.Println(resp.Participants)
• CLI:
lk room participants list --room room_name
Just a quick reminder to make sure your API key includes the roomAdmin permission, and don’t forget to replace
'room_name'
with the actual name of your room. If you have any questions or need a hand with anything else, please feel free to reach out—I’m here to help! Sources: cmd/lk/room.go | Managing participants | LiveKit docs | packages/livekit-server-sdk/src/RoomServiceClient.ts | livekit-api/livekit/api/room_service.py | test/lktest/livekit.go