So I have a dispatch rule that’s automatically ass...
# ask-ai
m
So I have a dispatch rule that’s automatically assigning an agent to a room even thogh it’s outbound and I actually want to use explicit dispatch for that room in the case of outbound. How do I modify my dispatch rule to only dispatch the inbound agent to the inbound trunk?
t
Thanks for reaching out, Alexander. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you modify your dispatch rule so it only assigns agents to inbound trunks and uses explicit dispatch for outbound rooms, here’s a simple guide you can follow: 1. Restrict Dispatch Rules to Inbound Trunks: • Make sure to specify the
trunk_ids
field in your dispatch rule with only the IDs of your inbound trunks. This way, the rule will apply just to calls coming from those trunks. Example in Python:
Copy code
dispatch_rule = await lk_api.sip.create_sip_dispatch_rule(
    api.CreateSIPDispatchRuleRequest(
        trunk_ids=[inbound_trunk.sip_trunk_id],
        rule=api.SIPDispatchRule(
            dispatch_rule_individual=api.SIPDispatchRuleIndividual(
                room_prefix="call"
            )
        )
    )
)
2. Use Explicit Dispatch for Outbound Rooms: • For outbound calls, you can explicitly assign participants to specific rooms using the
CreateSIPParticipant
API. Example in Python:
Copy code
# Create outbound SIP participant with explicit room assignment
outbound_participant = await sip_client.create_sip_participant(
    api.CreateSIPParticipantRequest(
        sip_trunk_id="outbound_trunk_id",
        sip_call_to="+1234567890",
        room_name="explicit-room-name",
        participant_identity="caller-identity"
    )
)
If you run into any questions or need a hand with these steps, please don’t hesitate to reach out. I’m here to help! Sources: packages/sip--um-actually/src/setup-livekit.ts | SIP dispatch rule | LiveKit Docs | protobufs/livekit_sip.proto | Community & Support | livekit/livekit_composite | DeepWiki
m
Since i’m not supporting inbound, can I just not have a dispatch rule?
t
Just to clarify, a dispatch rule isn’t necessary if you're focusing solely on outbound calls. Dispatch rules are really designed to help route inbound calls to LiveKit rooms. For outbound calls, all you need to do is set up an outbound trunk and use the
CreateSIPParticipant
API to start the call directly through that trunk. If you have any other questions or would like a hand with setting up your outbound configuration, please don’t hesitate to reach out—I’m here to help! Sources: SIP overview | LiveKit Docs | livekit/livekit_sip.pb.go
m
Hm yeah that’s what i’m doing but for some reason when I answer the outbound call on my phone, i hear a voicemail thing and two agents seem to join- namely the wrong one.
t
I'm really sorry to hear you're experiencing this issue where the call connects to voicemail and multiple agents get involved. Let's work through this together to get it sorted out! 1. Voicemail Detection: • Sometimes, if the outbound call isn’t answered, it might go straight to voicemail. LiveKit has voicemail detection features like silence detection or LLM-based tools that can help identify and manage these situations. If these aren’t set up yet, the system might treat the voicemail as if a person answered. 2. Multiple Agents Joining: • This can happen if the logic for assigning agents unintentionally adds more than one agent to the same call room. To avoid this, make sure your outbound call setup uses the
CreateSIPParticipant
API to assign only the specific agent you want to the room. Here are a few steps that might help: 1. Double-check that your outbound call logic is assigning the right participant and not triggering extra dispatch rules. 2. Confirm that voicemail detection is enabled and properly configured to handle voicemail calls, like disconnecting when voicemail is detected. 3. Review your agent dispatch settings to make sure no extra agents are being assigned by mistake. If you’d like, I’m here to help you review your setup or guide you through making these changes. Just let me know! Sources: Agents telephony integration | LiveKit Docs | agent.py | How to detect and handle silence during calls | examples/warm-transfer/warm_transfer.py | App templates | LiveKit docs