loud-furniture-10936
11/01/2025, 2:29 PMtall-airline-16756
11/01/2025, 2:29 PMtall-airline-16756
11/01/2025, 2:30 PMsip.phoneNumber attribute of the SIP participant. This attribute holds the caller's phone number for inbound calls and the dialed number for outbound calls.
Here’s a simple way to access it:
1. When a participant joins the room, check their attributes. For example, in Python:
async def async_on_participant_connected(participant):
if participant.kind == 'PARTICIPANT_KIND_SIP':
phone_number = participant.attributes.get('sip.phoneNumber', 'Unknown')
print(f"Caller's phone number: {phone_number}")
1. Make sure the hide_phone_number setting is set to false in the SIP dispatch rule or when creating the SIP participant. For example:
create_request = api.CreateSIPParticipantRequest(
sip_trunk_id=sip_trunk_id,
sip_call_to=phone_number,
room_name=room_name,
participant_identity=identity,
hide_phone_number=False
)
Also, please double-check that your SIP trunk and dispatch rules are set up to expose the phone number. If you run into any issues or have more questions, feel free to reach out—I’m here to help!
Sources: Create and configure a Plivo SIP trunk | LiveKit Docs | SIP participant | LiveKit Docs | telephony/sip_lifecycle.py | protobufs/livekit_sip.proto | Preserving Caller ID During SIP Transfers in LiveKit Agentsloud-furniture-10936
11/01/2025, 2:30 PMtall-airline-16756
11/01/2025, 2:31 PMsip.phoneNumber attribute from the participant's attributes when the participant is of kind SIP. Here's a simple example to guide you:
import { RoomServiceClient } from 'livekit-server-sdk';
const roomService = new RoomServiceClient(
process.env.LIVEKIT_URL!,
process.env.LIVEKIT_API_KEY!,
process.env.LIVEKIT_API_SECRET!
);
// List participants in a room
const participants = await roomService.listParticipants('your-room-name');
for (const participant of participants) {
if (participant.kind === 'SIP') {
const phoneNumber = participant.attributes?.['sip.phoneNumber'];
console.log('Caller phone number:', phoneNumber);
}
}
Just a quick tip: please make sure the HidePhoneNumber option isn’t enabled in your dispatch rule, as that would hide the sip.phoneNumber attribute. If you have any questions or need more help, feel free to reach out—I’m here for you!
Sources: SIP participant | LiveKit Docs | src/setup-livekit.tsloud-furniture-10936
11/01/2025, 2:32 PMtall-airline-16756
11/01/2025, 2:33 PMvoice.Agent even after session.start in LiveKit. It’s quite straightforward—you just use the updateAgent method from the AgentSession class to swap out the current agent for a new one. Here’s a little example to help you visualize it:
session.updateAgent(new voice.Agent({
instructions: "You are a new helpful assistant."
}));
This approach makes sure everything transitions smoothly by creating a new activity for the updated agent, gently draining the current activity, and reconnecting the audio streams—all without interrupting your session.
If you’d like, I’m here to help with more examples or any other questions you might have!
Sources: agents/src/voice/agent_activity.ts | Workflows | LiveKit Docs | basics/say_in_voice.py | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki | agent/main.py