For dispatch rule on inbound calls, how do I make ...
# ask-ai
g
For dispatch rule on inbound calls, how do I make it so the participant identity and room name are random
t
Thanks for reaching out, Aumesh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Let me help you with setting random participant identities and room names for dispatch rules on inbound calls: • Random Participant Identity: You can enable the
hide_phone_number
option in your dispatch rule. This will assign a random identity to the inbound SIP participant and keep the phone number hidden from participant attributes, giving you more privacy. • Random Room Names: Try using the
SIPDispatchRuleIndividual
type to create a new room for each caller. By setting a
room_prefix
, you’ll get unique room names that include a random suffix, making everything nicely organized. If you’d like, I’m here to provide specific implementation details or examples tailored to your SDK or environment—just let me know! Sources: SIP APIs | LiveKit Docs | lib/livekit/sip_service_client.rb | livekit/livekit_sip.pb.go | SIP dispatch rule | LiveKit Docs | SIP trunk setup | LiveKit Docs
g
I do not want to hide the phone number, I need it in the attributes setting. Also the prefix just adds a prefix to the start, but the room_name still contains the phone number.
t
I completely understand your need to have fully random room names without phone numbers included. To achieve this, the current setup requires turning on
hide_phone_number
, which helps keep phone numbers out of both the room name and its attributes. However, since you want to keep the phone number in the attributes but still have a random room name, this particular combination isn’t directly supported right now. The way room names are generated usually includes the phone number unless
hide_phone_number
is enabled. If you’d like, I’m here to help explore other options or assist with any other questions you might have—just let me know! Sources: SIP APIs | LiveKit Docs | SIP dispatch rule | LiveKit Docs
g
In which repo is the room created, I want to be able to set the room name to be randomized when a user joins
t
Creating a room in LiveKit is nicely managed by the RoomService, either directly through the
CreateRoom
API or automatically when the very first participant joins a room. If you'd like to randomize room names when a user joins, here’s a simple approach: 1. Generate a unique suffix, like a timestamp, a random string, or a UUID. 2. Attach this suffix to a base room name. 3. Use this combined name when you create the room with
createRoom()
or when you generate an access token that allows joining that room. For example:
Copy code
const baseName = "user_room";
const uniqueName = `${baseName}_${Date.now()}`; // or use a UUID
await roomService.createRoom({ name: uniqueName });
If you have any questions or want a hand with the implementation, just let me know—I’m here to help! Sources: packages/livekit-server-sdk/src/RoomServiceClient.ts | Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name | Authentication | LiveKit Docs
g
This is for outbound -- what about for inbound calls
t
For inbound SIP calls, you can easily randomize room names by using specific SIP dispatch rules: • Caller Dispatch (Individual Rooms): Try using
SIPDispatchRuleIndividual
. This will create a new room for each caller, with the room name including a random suffix. You also have the option to set a
roomPrefix
to personalize the name. • Callee Dispatch (Called Number-Based Rooms): Use
SIPDispatchRuleCallee
with
randomize: true
. This adds a random suffix to the room name for each caller, making sure each room is unique. You can also define a
roomPrefix
here. If you'd like, I'm here to help you set up these rules or explain anything in more detail—just let me know! Sources: SIP dispatch rule | LiveKit Docs | protobufs/livekit_sip.proto | livekit-protocol/livekit/protocol/sip.pyi | SIP trunk setup | LiveKit Docs | Inbound calls with Twilio Voice | LiveKit Docs