gentle-dream-14103
09/12/2025, 12:23 PMtall-airline-16756
09/12/2025, 12:24 PMtall-airline-16756
09/12/2025, 12:24 PMentrypoint
function to choose which agent to run by looking at both the caller and callee phone numbers. This works by combining SIP participant attributes with dispatch rules, giving you great flexibility.
Inside the entrypoint
function, once you’ve awaited ctx.wait_for_participant()
, you can access SIP participant attributes like sip.phoneNumber
(which is the caller’s number) and sip.trunkPhoneNumber
(the callee’s number). With these, you can set up routing logic that decides how agents respond based on those numbers.
Here’s a simple example to illustrate:
participant = await ctx.wait_for_participant()
if participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP:
caller_number = participant.attributes.get('sip.phoneNumber')
callee_number = participant.attributes.get('sip.trunkPhoneNumber')
# Example routing logic based on both numbers
if caller_number == '+15105550100' and callee_number == '+18005550123':
<http://logger.info|logger.info>("Routing to premium support agent")
# Initialize premium support agent
elif callee_number == '+18005550100':
<http://logger.info|logger.info>("Routing to sales department")
# Initialize sales agent
else:
<http://logger.info|logger.info>("Routing to default agent")
# Initialize default agent
Also, don’t forget that SIP dispatch rules are super helpful—they let you route calls based on the dialed number (dispatchRuleCallee
). Plus, the sip.ruleID
attribute can show you which dispatch rule was applied, so you can make even smarter routing decisions.
Sources: SIP participant | LiveKit Docs | telephony/warm_handoff.py | SIP dispatch rule | LiveKit Docs