what all behaviours can be controlled via SIP trun...
# ask-ai
r
what all behaviours can be controlled via SIP trunk and dispatch rules?
t
Thanks for reaching out, Saurabh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about what behaviors you can control with SIP trunks and dispatch rules. Below is a concise list of the main behaviors you can manage and how each is controlled. SIP trunks (controls telephony-level behaviors) • Call direction: designate trunks for inbound vs outbound calls. • Phone-number handling: assign which E.164 numbers a trunk accepts (multiple numbers per trunk). • Provider authentication: outbound trunks use SIP provider credentials for call origination. • Audio processing: enable noise/echo cancellation (Krisp) on inbound trunks to improve caller audio for agents and STT. • Trunk-to-rule mapping: trunks are tied to dispatch rules so calls arriving on a particular trunk follow the associated routing logic. Dispatch rules (controls routing into LiveKit rooms and room behavior) • Room assignment strategy: ◦ Individual rooms per call (e.g.,
room_prefix
creates unique room names). ◦ Direct routing to a specific
room_name
(optionally protected by a
pin
). • Agent dispatch automation: ◦ Automatically dispatch named agents into the room when the call connects (via
room_config.agents
). • Room configuration applied at connect: ◦ Set limits such as
max_participants
. ◦ Attach metadata and other room-level settings. • Automatic egress / recording: ◦ Enable automatic egress to record the session without manual steps (
room_config.egress
/ AutoEgress). • Call routing logic and segmentation: ◦ Match rules by
trunk_ids
and other criteria so different trunks (sales, support, etc.) route to different rooms/workflows. How these work together (typical flows) • A call arrives on a configured inbound trunk → trunk settings (numbers, Krisp) apply → dispatch rule matched for that trunk → dispatch rule creates or selects a room and applies
room_config
(agents, egress, limits) → agents join and the session behaves per the rule’s configuration. If you’d like, I can: • Show an example dispatch rule for individual-per-call rooms vs direct-room routing. • Explain how to configure automatic agent dispatch or AutoEgress in more detail. • Help map your use case (sales vs support flows, recordings, agent automation) to specific trunk + dispatch rule settings. Which of those would be most helpful right now? Sources: sip | livekit/livekit_composite | DeepWiki | Agents telephony integration | LiveKit Documentation | server-sdk-kotlin | livekit/livekit_composite | DeepWiki | Python SDKs | livekit/livekit_composite | DeepWiki
r
dispatch rule, egress config ?
t
Thanks — I’m addressing your follow-up asking specifically about dispatch rules and egress configuration. Below I’ll cover: • What parts of a dispatch rule control call routing and room behavior • How to configure AutoEgress inside a dispatch rule • Short examples you can adapt Dispatch rule — key fields and effects • rule type ◦ SIPDispatchRuleIndividual: creates a unique room per call using
room_prefix
(e.g.,
call-123
). ◦ SIPDispatchRuleDirect: routes the call directly into a named
room_name
(can require a
pin
). • trunk matching ◦
trunk_ids
ties the rule to specific inbound trunks so different numbers/trunks use different routing. • room_config ◦ `agents`: list of agents to automatically dispatch into the room when the call connects. ◦
max_participants
, metadata, and other room-level settings applied at room creation. • behavior flow ◦ Incoming call hits an inbound trunk → matching dispatch rule runs → rule creates or selects a room and applies
room_config
→ agents and egress behave as configured. Egress (AutoEgress) — what it does and where to configure it • Purpose: Automatically export audio/video from the room for recording or streaming without manual start/stop. • Where to set it: inside the dispatch rule’s
room_config.egress
so every call routed by that rule uses the egress settings automatically. • Common outputs: ◦ File recording to cloud storage (S3/GCS) or local path. ◦ RTMP streaming (stream to a live destination). ◦ Callback/webhook notifications when egress jobs start/finish. Example patterns 1) Individual room per call + automatic file recording
Copy code
# illustrative example (adapt to your SDK)
CreateSIPDispatchRuleRequest(
  trunk_ids=[inbound_trunk_id],
  rule=SIPDispatchRule(
    dispatch_rule_individual=SIPDispatchRuleIndividual(
      room_prefix="call-"
    )
  ),
  room_config=RoomConfiguration(
    max_participants=5,
    agents=[ {"agentName":"inbound-agent","metadata":"sales"} ],
    egress=AutoEgressConfiguration(
      file_output="<s3://your-bucket/recordings/{room_name}.mp4>"
    )
  )
)
2) Direct routing to a named room + RTMP stream
Copy code
CreateSIPDispatchRuleRequest(
  trunk_ids=[support_trunk_id],
  rule=SIPDispatchRule(
    dispatch_rule_direct=SIPDispatchRuleDirect(
      room_name="support-room-1",
      pin="1234"   # optional
    )
  ),
  room_config=RoomConfiguration(
    agents=[ {"agentName":"support-agent"} ],
    egress=AutoEgressConfiguration(
      rtmp_url="<rtmp://live.example.com/live/streamkey>"
    )
  )
)
Notes and best practices • Prefer explicit
room_config.agents
for predictable agent dispatch instead of relying on implicit behaviors. • Use trunk-specific dispatch rules to separate flows (sales, support, IVR). • Ensure your egress destinations (S3 bucket, RTMP endpoint) are reachable and credentials are configured where required. • Keep
max_participants
aligned with expected call scenarios to prevent unexpected join failures. Would you like: • a full copy-paste example in the language/SDK you use (Node, Python, or REST JSON)? • help mapping your specific numbers/trunks to rule examples for sales vs support? Sources: Why do jobs stop after agent rejection? | LiveKit | Agents telephony integration | LiveKit Documentation | sip | livekit/livekit_composite | DeepWiki | examples/bank-ivr | livekit/livekit_composite | DeepWiki | Python SDKs | livekit/livekit_composite | DeepWiki