loud-furniture-10936
10/31/2025, 6:20 PMtall-airline-16756
10/31/2025, 6:20 PMtall-airline-16756
10/31/2025, 6:21 PMsipTrunkPhoneNumber) with LiveKit! To get started, you'll first want to create a SIP trunk. You can do this using methods like createSipInboundTrunk or createSipOutboundTrunk, where you'll define the phone number during the trunk creation process.
After your trunk is set up, you can easily initiate a SIP call using the createSipParticipant method. This connects a SIP caller to a LiveKit room, and if you don’t specify a fromNumber, it will automatically use the trunk's associated phone number.
Regarding the session.start method you mentioned, it’s not part of LiveKit’s documented SIP APIs. If this comes from a custom setup or a third-party integration, could you share a bit more about where you saw it? That way, I can better assist you and make sure we find the right solution together.
Sources: packages/sip--make-a-call/src/make-call.ts | packages/livekit-server-sdk/src/SipClient.ts | lib/livekit/sip_service_client.rb | agent.py | SIP participant | LiveKit Docsloud-furniture-10936
10/31/2025, 6:24 PMtall-airline-16756
10/31/2025, 6:25 PMsip.trunkPhoneNumber attribute, which holds the phone number linked to the SIP trunk. This attribute is accessible from the participant's attributes once the call is connected.
Here’s a simple way to get started:
1. Make sure each SIP number is connected to an inbound SIP trunk.
2. Use the sip.trunkPhoneNumber attribute to identify which number was dialed. For example:
const participants = await client.listParticipants(ctx.room.name!);
const agentPhoneNumber = participants[1]?.attributes["sipTrunkPhoneNumber"];
console.log("Dialed Number:", agentPhoneNumber);
1. Then, based on the dialed number, you can fetch the relevant data from Supabase or another database. For example:
if (agentPhoneNumber === "+1234567890") {
const data = await supabase.from('table_name').select('*').eq('phone_number', agentPhoneNumber);
// Use the fetched data to configure the AI agent
}
Additionally, you can set up dispatch rules to assign custom attributes to each SIP number, helping you tailor your agent’s behavior even more dynamically.
If you’d like, I’m here to guide you through setting up dispatch rules or help with any specific logic for fetching and using data based on the SIP number. Just let me know!
Sources: SIP participant | LiveKit Docs | pkg/service/ioservice_sip_test.go | SIP dispatch rule | LiveKit Docs | sip-refer/README.mdocloud-furniture-10936
10/31/2025, 6:26 PMtall-airline-16756
10/31/2025, 6:26 PMListSIPDispatchRule API. This handy API lets you retrieve all SIP dispatch rules, and you can even filter them by specific criteria like rule IDs or trunk IDs to suit your needs.
Here’s a friendly example in Python to get you started:
from livekit.api import LiveKitAPI
from livekit.protocol.sip import ListSIPDispatchRuleRequest
# Initialize the LiveKit API client
lk_api = LiveKitAPI(
url=<LIVEKIT_URL>,
api_key=<LIVEKIT_API_KEY>,
api_secret=<LIVEKIT_API_SECRET>,
)
# Fetch all SIP dispatch rules
response = await lk_api.sip.list_dispatch_rule(ListSIPDispatchRuleRequest())
for rule in response.items:
print(rule)
And if Ruby is more your style, here’s how you can do it:
require 'livekit'
# Initialize the SIP service client
client = LiveKit::SIPServiceClient.new(
<LIVEKIT_URL>,
api_key: <LIVEKIT_API_KEY>,
api_secret: <LIVEKIT_API_SECRET>
)
# Fetch all SIP dispatch rules
rules = client.list_sip_dispatch_rule
puts rules
If you want to narrow down the rules to specific inbound numbers, just use the inbound_numbers field in your request. This way, you’ll get only the rules that accept calls made to those numbers.
If you’d like, I’m here to help you implement this in your specific setup or answer any questions you might have. Just let me know!
Sources: SIP dispatch rule | LiveKit Docs | protobufs/livekit_phone_number.proto | livekit-api/src/services/sip.rs | livekit-api/livekit/api/sip_service.py