kind-iron-94532
08/04/2025, 3:17 AMtall-airline-16756
08/04/2025, 3:17 AMtall-airline-16756
08/04/2025, 3:18 AMmax_call_duration field in the SIP call request. This field is part of the CreateSIPParticipantRequest and allows you to specify the duration in seconds or using the protobuf Duration type.
2. Automatic Disconnection: LiveKit will automatically disconnect the call once the specified max_call_duration is reached.
3. Provide Max Call Duration to the Agent: Use the headers_to_attributes mapping to pass the max call duration as a custom attribute in the SIP participant request. For example, you can map a custom header like X-Max-Call-Duration to an attribute accessible by the agent.
Here’s an example of how the CreateSIPParticipantRequest might look:
message CreateSIPParticipantRequest {
// ...
map<string, string> headers = 16;
map<string, string> headers_to_attributes = 17;
google.protobuf.Duration max_call_duration = 12;
// ...
}
Let me know if you need further assistance or specific examples!
Sources: pkg/sip/participant.go | rpc/sip.pb.gokind-iron-94532
08/04/2025, 3:22 AMlk_api = livekit_api.LiveKitAPI()
# create a Dispatch Rule on livekit for the phone number
agent_name = settings.AGENT_WORKER_AGENT_NAME
dispatch_rule = livekit_api.SIPDispatchRule(
dispatch_rule_individual=livekit_api.SIPDispatchRuleIndividual(
room_prefix="assistant-",
)
)
dispatch_rule_name = f"Inbound Agent Calling Dispatch Rule for {phone_num}"
agent_to_dispatch = livekit_api.RoomAgentDispatch(
agent_name=agent_name,
metadata=str(assistant_id),
)
room_config = livekit_api.RoomConfiguration(agents=[agent_to_dispatch])
sip_dispatch_rule_info = livekit_api.SIPDispatchRuleInfo(
rule=dispatch_rule,
room_config=room_config,
name=dispatch_rule_name,
trunk_ids=[sip_trunk_id],
)
dispatch_rule_request = livekit_api.CreateSIPDispatchRuleRequest(dispatch_rule=sip_dispatch_rule_info)tall-airline-16756
08/04/2025, 3:24 AMmax_call_duration field. This makes sure all calls going through that trunk stick to the time limit you set.
2. Dispatch Rule Evaluation: While SIP dispatch rules don’t have a max_call_duration field themselves, they can actually inherit this limit from the trunk they’re linked to. So, by connecting dispatch rules with trunks that have a max_call_duration, you’re in control of call lengths.
3. Global Maximum: Just a heads up, LiveKit has a hard cap of 24 hours for call duration — that one can’t be changed.
In your code, just make sure the trunk tied to your dispatch rule has the max_call_duration set, and you’re good to go! Calls routed through that dispatch rule will follow the duration limit automatically.
If you want me to walk you through it more or share some examples, just let me know—I’m here to help!
Sources: rpc/io.pb.go | livekit-protocol/src/livekit.rs | packages/livekit-server-sdk/src/SipClient.ts | lib/livekit/sip_service_client.rb | pkg/sip/participant.gokind-iron-94532
08/04/2025, 3:27 AMtall-airline-16756
08/04/2025, 3:28 AM