How do you set the participant when initiating out...
# ask-ai
c
How do you set the participant when initiating outbound calls?
t
Thanks for reaching out, Rithvik. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To set the participant when initiating outbound calls with LiveKit SIP, you need to specify the participant identity during the creation of a SIP participant. Here is an example of how to do this:
Copy code
sip_participant_identity = phone_number
await ctx.api.sip.create_sip_participant(api.CreateSIPParticipantRequest(
    room_name=ctx.room.name,
    sip_trunk_id='ST_xxxx',
    sip_call_to=phone_number,
    participant_identity=sip_participant_identity,
    wait_until_answered=True,
))
In this example, the
participant_identity
parameter is set to the phone number, but you can use any identifier you prefer. This identity will be used to identify the participant in the LiveKit room once the call is connected. Sources: Agents telephony integration | LiveKit Docs | Making outbound calls | LiveKit Docs
c
How do i use the set_participant method?
t
The
set_participant
method is like your personal communication navigator in a RoomIO instance. Think of it as a friendly way to point out exactly who you want to interact with. Let me break it down in a super simple way: 1. You can tell the method which participant you want to chat with - either by giving it a specific identity or just letting it default to whoever's calling. 2. It's got a handy logging feature that keeps track of who's asking and who they want to talk to (like a helpful friend taking notes). 3. Behind the scenes, it sets up the RoomIO to focus on the participant you've chosen by using
room_io.set_participant(target_identity)
. Cool part? This method is set up as an RPC, which means clients can basically reach out and say, "Hey, I want the voice agent to talk to this specific person!" It's like having a communication concierge that makes sure you're connected to the right participant, every single time. Sources: GitHub::livekit::agents | examples/voice_agents/toggle_io.py