bitter-appointment-81509
10/22/2025, 10:29 AMtall-airline-16756
10/22/2025, 10:29 AMtall-airline-16756
10/22/2025, 10:30 AMbitter-appointment-81509
10/22/2025, 10:30 AMtall-airline-16756
10/22/2025, 10:32 AM{
"dispatch_rule": {
"rule": {
"dispatch_rule_individual": {
"room_prefix": "call-"
}
}
}
}
5. Finally, click Create to save your rule.
2. Programmatically via SDK:
If you prefer, you can also set up dispatch rules using the Node.js or Python SDKs. Here's an example in Node.js:
const dispatchRule = await sipClient.createSipDispatchRule(
{
type: 'individual',
roomPrefix: 'call-',
},
{
name: 'inbound-dispatch-rule',
trunkIds: [trunk.sipTrunkId],
}
);
If you'd like, I’m here to help with any part of this process or provide more details on using a specific SDK. Just let me know!
Sources: SIP dispatch rule | LiveKit Docs | sip/sip.go | src/setup-livekit.ts | Community & Support | livekit/livekit_composite | DeepWikibitter-appointment-81509
10/22/2025, 10:45 AMtall-airline-16756
10/22/2025, 10:47 AMconst roomConfig = new RoomConfiguration({
agents: [
new RoomAgentDispatch({
agentName: 'unique-agent-name',
metadata: JSON.stringify({ type: 'sip-handler' })
})
]
});
const dispatchRule = await sipClient.createSipDispatchRule(
{
type: 'individual',
roomPrefix: 'call-',
},
{
name: 'Individual Agent Dispatch',
roomConfig: roomConfig
}
);
2. Start the Agent Worker:
Next, ensure your agent is running with the specified name. Here’s how you might do this in Python:
from livekit.agents import WorkerOptions, Worker
worker = Worker(
options=WorkerOptions(
agent_name="unique-agent-name"
)
)
@worker.on("agent_dispatch")
async def on_agent_dispatch(ctx):
# Handle the SIP call in the individual room
pass
await worker.run()
With this setup, each time a SIP call comes in, a new room will be created, and the specified agent will automatically join to handle the call.
If you'd like, I’m here to help you further with the setup or guide you through using a specific SDK. Just let me know!
Sources: SIP dispatch rule | LiveKit Docs | livekit/livekit_sip.pb.go | examples/agent-dispatch/index.ts | Agent dispatch | LiveKit Docs | livekit-protocol/src/livekit.rsbitter-appointment-81509
10/22/2025, 12:22 PMtall-airline-16756
10/22/2025, 12:24 PMdispatch = await lkapi.agent_dispatch.create_dispatch(
api.CreateAgentDispatchRequest(
agent_name="your-agent-name",
room="your-room-name",
metadata=json.dumps({"phone_number": "+1234567890"})
)
)
2. Create the SIP Participant:
Next, initiate the outbound call by creating a SIP participant in the same room. Here's how you can do it:
sip_participant = await lkapi.sip.create_sip_participant(
api.CreateSIPParticipantRequest(
room_name="your-room-name",
sip_trunk_id="your-outbound-trunk-id",
sip_call_to="+1234567890",
participant_identity="phone_user",
)
)
Important Notes:
• Make sure the room name is the same in both steps so the agent and SIP participant connect properly.
• The agent should be registered with the agent name you specify.
• You can also pass metadata, like a phone number or other custom info, to give the agent some helpful context.
If you'd like, I’m here to help you implement this in a specific SDK or environment—just let me know!
Sources: Agents telephony integration | LiveKit Docs | livekit-api/livekit/api/agent_dispatch_service.py | Agent dispatch | LiveKit Docs | packages/sip--make-a-call/README.md | telephony/survey_caller/make_survey_calls.pytall-airline-16756
10/24/2025, 7:58 AMvad, stt, realtime_llm, or manual to detect when the user has finished speaking. Using realtime_llm can really help reduce latency.
4. Preemptive Speech Generation:
• Enabling preemptive_generation lets the system start LLM and TTS processing as soon as partial transcription arrives, which cuts down response time.
5. Network Optimization:
• It’s beneficial to deploy agents close to AI service regions to keep network latency low.
• Also, aiming for round-trip times (RTT) under 50ms between the agent and AI endpoints can make a big difference.
6. Monitoring and Metrics:
• Tracking metrics like Time To First Token (TTFT) and Time To First Byte (TTFB) can help you spot where delays might be happening in LLM, STT, or TTS components.
7. SIP-Specific Best Practices:
• Turning on TelephonyBackgroundVoiceCancellation can improve audio clarity significantly.
• Keeping an eye on agent metrics continuously will help catch any performance issues during SIP call flows early.
If you'd like, I’d be happy to walk you through how to implement any of these optimizations or answer any questions you have. Just let me know!
Sources: livekit-agents/livekit/agents/voice/agent_session.py | Agent speech and audio | LiveKit Docs | Troubleshooting & Common Issues | livekit/livekit_composite | DeepWiki | .cursor/rules/agent-core.mdc | External data and RAG | LiveKit Docs