how to dispatch an outbound call to a certain agen...
# ask-ai
s
how to dispatch an outbound call to a certain agent:
Copy code
request = CreateSIPParticipantRequest(
        sip_trunk_id = "<trunk_id>",
        sip_call_to = "<phone_number>",
        room_name = "my-sip-room",
        participant_identity = "sip-test",
        participant_name = "Test Caller",
        krisp_enabled = True,
        wait_until_answered = True
    )
t
Thanks for reaching out, Youssef. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You’re asking how to ensure an outbound SIP call (your CreateSIPParticipantRequest) is handled by a specific agent. Short answer: the SIP request connects the phone to a LiveKit room, but you must dispatch the agent into that same room so the agent receives the call. Steps to do that: 1. Ensure the agent is configured for explicit dispatch (agent waits for manual assignment). Example: use
agent_name
in your server agent definition so it will only join rooms when explicitly dispatched. 1. Dispatch the agent to the room you’ll use for the call (e.g., "my-sip-room"). Two options: ◦ Agent Dispatch API:
Copy code
dispatch = await lkapi.agent_dispatch.create_dispatch(
       api.CreateAgentDispatchRequest(
         agent_name="my-telephony-agent",
         room="my-sip-room",
         metadata='{"call_reason":"outbound_campaign"}'
       )
     )
• Or include the target agent in a participant access token / room config so the room is created with that agent assigned:
Copy code
token = (
       AccessToken()
       .with_identity("outbound-initiator")
       .with_grants(VideoGrants(room_join=True, room="my-sip-room"))
       .with_room_config(
         RoomConfiguration(
           agents=[RoomAgentDispatch(agent_name="my-telephony-agent")]
         )
       )
       .to_jwt()
     )
1. Initiate the outbound SIP call (your snippet). When the SIP participant joins
room_name="my-sip-room"
, the dispatched agent will be in that room to handle the call:
Copy code
request = CreateSIPParticipantRequest(
     sip_trunk_id="<trunk_id>",
     sip_call_to="<phone_number>",
     room_name="my-sip-room",
     participant_identity="sip-test",
     participant_name="Test Caller",
     krisp_enabled=True,
     wait_until_answered=True
   )
   participant = await lk_api.sip.create_sip_participant(request)
1. (Optional) Pass metadata in the dispatch to give the agent context (customer info, phone number). That metadata is available in the agent’s JobContext. Would you like example code for dispatching then creating the SIP participant in one flow, or do you want help verifying your agent’s explicit-dispatch configuration? Sources: Agents telephony integration | LiveKit docs | Agent dispatch | LiveKit docs | Make outbound calls | LiveKit docs | livekit/livekit_composite | DeepWiki