best-jackal-86104
11/16/2025, 2:34 PMtall-airline-16756
11/16/2025, 2:34 PMtall-airline-16756
11/16/2025, 2:34 PMbest-jackal-86104
11/16/2025, 2:36 PMtall-airline-16756
11/16/2025, 2:36 PMhide_phone_number setting is turned off when you create SIP participants. This way, the phone number gets included in the participant attributes.
2. Make sure to explicitly pass the called phone number in the job.metadata field when dispatching the agent. This is the most dependable way to have the number available in the worker session.
3. Take a look at the participant’s identity field—by default, LiveKit uses the phone number there unless a custom identity is set or hide_phone_number is enabled.
If you’d like, I’m here to help you walk through these steps or answer any questions you might have. Just let me know!
Sources: livekit-api/src/services/sip.rs | SIP APIs | LiveKit docs | Preserving Caller ID During SIP Transfers in LiveKit Agents | Agents telephony integration | LiveKit Docs | Job lifecycle | LiveKit Docsbest-jackal-86104
11/16/2025, 2:37 PMtall-airline-16756
11/16/2025, 2:37 PMmetadata field of your dispatch rule. Since the metadata field is a string, using JSON is a great way to keep your data organized.
For instance, when you're creating a dispatch rule, you might include the phone number like this:
{
"dispatch_rule": {
"rule": {
"dispatchRuleIndividual": {
"roomPrefix": "customer1-"
}
},
"metadata": "{\"phone_number\": \"+1234567890\", \"customer_id\": \"customer1\"}"
}
}
Then, in your agent's entrypoint function, you can easily parse this metadata to get the phone number:
import json
async def entrypoint(ctx: JobContext):
dial_info = json.loads(ctx.job.metadata)
phone_number = dial_info["phone_number"]
# Use the phone_number as needed
If you have any questions or need a hand with this setup, please don't hesitate to reach out. I'm here to help!
Sources: Agent dispatch | LiveKit Docs | agent.pybest-jackal-86104
11/16/2025, 2:39 PMtall-airline-16756
11/16/2025, 2:40 PMinbound_numbers field. Here’s a quick example:
{
"dispatch_rule": {
"rule": {
"dispatchRuleCallee": {
"inbound_numbers": [
"+15105550123",
"+12025550198"
]
}
},
"metadata": "{\"customer_id\": \"shared_config\"}"
}
}
This makes it easier to manage multiple clients or numbers all in one place. If you’d like, I’m here to help you set this up step-by-step—just let me know!
Sources: SIP dispatch rule | LiveKit docs | livekit-protocol/src/livekit.rs | Accepting inbound calls | LiveKit docsbest-jackal-86104
11/16/2025, 2:40 PMtall-airline-16756
11/16/2025, 2:40 PMroomPrefix like "number-", the room name will show the called number, making it super easy to identify.
2. Participant Attributes: During call processing, LiveKit adds a participant attribute called livekit.AttrSIPTrunkNumber that holds the called number (from the SIP "To" header). Agents can check this attribute to programmatically find out which number was dialed.
If you'd like, I’m here to help you set up either of these methods—just let me know!
Sources: SIP dispatch rule | LiveKit docs | sip/sip.gobest-jackal-86104
11/16/2025, 2:42 PMtall-airline-16756
11/16/2025, 2:42 PM{
"dispatch_rule": {
"rule": {
"dispatchRuleCallee": {
"roomPrefix": "number-",
"randomize": false
}
},
"name": "My dispatch rule"
}
}
This approach will create room names like number-+15105550123, so the called number becomes part of the room name, making it easier to identify.
1. Access Participant Attributes: You can also find the called number included in participant attributes, such as sip.trunkPhoneNumber, which you can access programmatically.
If you'd like, I’m here to help you set this up or answer any questions you have!
Sources: SIP dispatch rule | LiveKit docs | test/integration/sip_test.go | Make outbound calls | LiveKit docsbest-jackal-86104
11/16/2025, 2:54 PMtall-airline-16756
11/16/2025, 2:55 PMsip.trunkPhoneNumber from the attributes field of a SIP participant once they join a room. Here's a simple way to do it:
1. Listen for Participant Events: Use the SDK to listen for when participants connect and then check their attributes. For example, in Node.js:
room.on('participantConnected', (participant) => {
if (participant.kind === 'SIP') {
const trunkPhoneNumber = participant.attributes['sip.trunkPhoneNumber'];
console.log('Trunk Phone Number:', trunkPhoneNumber);
}
});
1. Query Existing Participants: You can also get all participants in a room and look at their attributes like this:
const participants = room.getParticipants();
participants.forEach((participant) => {
if (participant.kind === 'SIP') {
const trunkPhoneNumber = participant.attributes['sip.trunkPhoneNumber'];
console.log('Trunk Phone Number:', trunkPhoneNumber);
}
});
One important thing to double-check is that hide_phone_number is not enabled in your dispatch rules because that would stop the phone number from showing up in the attributes. If you have any questions or want me to walk you through this further, just let me know—I’m here to help!
Sources: livekit-protocol/livekit/protocol/sip.pyi | lib/livekit/proto/livekit_sip_pb.rb | SIP inbound trunk | LiveKit docs | SIP participant | LiveKit docs | livekit/attrs.gobest-jackal-86104
11/16/2025, 2:56 PMtall-airline-16756
11/16/2025, 2:56 PMsip.trunkPhoneNumber programmatically in your current code, you can retrieve it from the participant attributes right after connecting to the room. Here's a little update to your code that should do the trick:
async def entrypoint(ctx: JobContext):
# Connect to the room
room2 = await ctx.connect()
# Access remote participants
for participant in ctx.room.remote_participants:
if participant.kind == "SIP":
trunk_phone_number = participant.attributes.get("sip.trunkPhoneNumber")
logger.info(f"Trunk Phone Number: {trunk_phone_number}")
# Continue with your existing logic
...
This way, you'll be able to log or use the sip.trunkPhoneNumber for whatever comes next. If you run into any bumps or want to explore this further, just let me know—I’m here to help!best-jackal-86104
11/16/2025, 2:58 PMtall-airline-16756
11/16/2025, 2:58 PMparticipant object is being treated as a string instead of a full participant object. This sometimes happens if the ctx.room.remote_participants list contains string representations rather than the actual participant objects.
To help fix this, please make sure you're accessing the correct participant objects. You can update your code to log the type of each participant, which is a great way to debug:
for participant in ctx.room.remote_participants:
logger.info(f"Participant: {participant}, Type: {type(participant)}")
if hasattr(participant, "kind") and participant.kind == "SIP":
trunk_phone_number = participant.attributes.get("sip.trunkPhoneNumber")
logger.info(f"Trunk Phone Number: {trunk_phone_number}")
If you find that the participants are strings, it might mean there’s an issue with how the room or participants are being set up. Please don’t hesitate to reach out if this keeps happening—I’m here to help you sort it out!