creamy-tiger-14805
09/12/2025, 12:15 PMtall-airline-16756
09/12/2025, 12:15 PMtall-airline-16756
09/12/2025, 12:15 PMsip_trunk_id
dynamically in dispatch rules instead of setting it as an environment variable. This is done by associating one or more `sip_trunk_id`s with a SIP dispatch rule when you create or update it.
For instance, if you're using the Python SDK, you can dynamically assign a sip_trunk_id
while creating a dispatch rule like this:
dispatch_rule = await lkapi.sip.create_dispatch_rule(
api.CreateSIPDispatchRuleRequest(
dispatch_rule=api.SIPDispatchRuleInfo(
name="my-dynamic-rule",
rule=api.SIPDispatchRule(
dispatch_rule_direct=api.SIPDispatchRuleDirect(room_name="meeting-room")
)
),
trunk_ids=[trunk_id] # Dynamic assignment of Trunk ID
)
)
And if you ever need to update the trunk ID association later on, you can easily do that using the UpdateSIPDispatchRuleRequest
API, allowing you to modify the associated trunks dynamically.
Please don’t hesitate to reach out if you’d like me to walk you through any part of this or if you need more details. I’m here to help!
Sources: telephony/survey_caller/make_survey_calls.py | SIP APIs | LiveKit Docs | livekit/livekit_sip.pb.go | livekit-protocol/livekit/protocol/sip.pycreamy-tiger-14805
09/13/2025, 9:15 AMtall-airline-16756
09/13/2025, 9:16 AMsip_trunk_id
works in dispatch rules! Typically, you can leave the trunk_ids
field empty. When it’s empty, the dispatch rule will match all SIP trunks, so it applies to incoming calls from any trunk.
If you do provide specific trunk_ids
, the rule will then only apply to those particular trunks, which overrides the default behavior.
Please feel free to reach out if you’d like me to walk you through this further or if you have any other questions!
Sources: SIP APIs | LiveKit Docs | sip/sip.gocreamy-tiger-14805
09/13/2025, 9:18 AMtall-airline-16756
09/13/2025, 9:19 AMtrunk_id
in the dispatch function. When the trunk_ids
field is left out in a SIP dispatch rule, it means the rule will match calls from all inbound trunks, so it applies universally.
As long as your agent is set up correctly in the dispatch rule, it will handle incoming SIP calls just as you’d expect, no matter which trunk is used.
If you have any more questions or need a bit more help, feel free to reach out—I’m here for you!
Sources: SIP dispatch rule | LiveKit Docs | pkg/service/ioservice_sip.go | Accepting incoming calls | LiveKit Docscreamy-tiger-14805
09/13/2025, 9:24 AMtall-airline-16756
09/13/2025, 9:24 AMtrunk_id
isn’t provided, LiveKit kindly looks for dispatch rules that don’t specify any `trunk_ids`—these are what we call wildcard rules. These rules are designed to match calls from all inbound trunks, so the system can still manage calls smoothly even if there isn’t a specific trunk association.
If there isn’t a matching wildcard rule, the call will unfortunately be rejected. To avoid this, it’s a good idea to have at least one dispatch rule set up without trunk_ids
for your inbound calls.
Please feel free to reach out if you’d like me to explain anything further or if you need a hand with this!
Sources: sip/sip.go | SIP dispatch rule | LiveKit Docs | pkg/service/ioservice_sip.gocreamy-tiger-14805
09/13/2025, 9:30 AMlk dispatch
for an outbound call , do I need trunk id in my env during that time?tall-airline-16756
09/13/2025, 9:30 AMlk dispatch
, it's important to include the trunk_id
in your environment. This helps because the sip_trunk_id
is a required parameter when creating a SIP participant for outbound calls, and it tells the system which SIP provider and credentials to use.
If you have any questions or need a hand with setting this up, please don’t hesitate to reach out—I’m here to help!
Sources: telephony/survey_caller/make_survey_calls.py | examples/warm-transfer/README.md | protobufs/livekit_sip.protocreamy-tiger-14805
09/13/2025, 9:33 AMtall-airline-16756
09/13/2025, 9:34 AMagent_name
.
2. Next, create or update a SIP dispatch rule to include your agent in the room_config.agents
list.
3. Then, link the dispatch rule to the specific SIP trunks by setting the trunk_ids
field in the rule configuration.
4. Finally, apply the updated rule using the CLI command (lk sip dispatch update
) or through the API.
If you’re working with outbound calls, just remember that the agent needs to specify the sip_trunk_id
dynamically when creating a SIP participant for the call.
Please feel free to reach out if you’d like me to walk you through detailed steps or provide examples tailored to your situation—I’m here to help!
Sources: livekit/livekit_sip.pb.go | Accepting incoming calls | LiveKit Docs | cmd/lk/sip.go | packages/livekit-server-sdk/src/SipClient.ts | SIP APIs | LiveKit Docscreamy-tiger-14805
09/13/2025, 9:36 AMtall-airline-16756
09/13/2025, 9:36 AMlk dispatch
and using an agent name. By default, the SIP trunk isn’t dynamically changeable because the trunk ID is taken from an environment variable (like SIP_OUTBOUND_TRUNK_ID
) and applied to all calls.
But here’s some good news—you can actually enable dynamic trunk selection! This involves tweaking the agent so it reads the sip_trunk_id
from the dispatch metadata. Doing this lets you choose a different trunk for each dispatch. The agent would parse this metadata in its entrypoint function and use the trunk ID you provide when setting up the SIP participant.
If you’d like, I’m more than happy to walk you through the detailed steps or clarify anything further. Just let me know!
Sources: telephony/survey_caller/make_survey_calls.py | agent.py | Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs | cmd/lk/sip.gocreamy-tiger-14805
09/13/2025, 9:37 AMtall-airline-16756
09/13/2025, 9:37 AM