astonishing-camera-14040
02/17/2026, 4:07 PMtall-airline-16756
02/17/2026, 4:07 PMtall-airline-16756
02/17/2026, 4:08 PM<http://sip.your-domain.com|sip.your-domain.com>).
• Enable SIP REFER / PSTN transfer options if you plan to transfer calls between IVRs or other SIP endpoints.
1. Configure an inbound SIP trunk in LiveKit
• Use the LiveKit CLI or API to create an inbound trunk that lists your Twilio phone number(s). Example CLI (adjust to your environment):
lk sip inbound create --name "Twilio-Inbound" --numbers "+1234567890"
Replace the phone number with your Twilio number.
• Ensure LiveKit’s SIP service is listening on the correct ports and protocol (UDP/TCP/TLS) and that any firewall/NAT forwards those ports.
1. Create a dispatch rule to route calls into a room and start your agent
• Create a dispatch rule JSON that routes calls to rooms with a prefix (for example call-) and specifies the agent name to start. Example structure:
{ "dispatch_rule": { "rule": { "dispatchRuleIndividual": { "roomPrefix": "call-" } }, "roomConfig": { "agents": [ { "agentName": "my-agent" } ] } } }
• Apply the rule with the LiveKit CLI or API:
lk sip dispatch create dispatch-rule.json
1. Ensure your agent’s name matches the dispatch rule
• In your agent code, name the agent so LiveKit can dispatch it by name:
@server.rtc_session(agent_name="my-agent")
async def my_agent(ctx: JobContext):
# agent logic
This ensures the dispatch rule will start this agent for incoming calls.
1. (Optional) Outbound calling from agent via Twilio
• Create an outbound trunk in LiveKit pointing to Twilio’s SIP URI and use the agent API to create a SIP participant to place outbound calls:
◦ Use LiveKit’s create_sip_participant with the outbound trunk ID and the phone number to dial.
1. Security & PCI considerations
• Don’t collect card numbers directly in call recordings or logs. If you need payment, either transfer the call to a PCI-compliant IVR or use secure payment links.
• If you need to avoid recording, start the agent or room with record=False.
1. Test
• Run your agent in dev mode:
python agent.py dev
• Call your Twilio number. The call should be routed via Twilio → SIP → LiveKit inbound trunk → dispatch rule → room → your agent should answer.
If you want, I can:
• Provide exact CLI/API commands for your environment once you tell me whether your server is publicly reachable and whether you want SIP over TLS or plain SIP.
• Walk you through creating the Twilio SIP domain step-by-step.
• Show a complete example dispatch-rule.json tailored to your agent name.
Which option would you like next? Also please confirm whether your LiveKit server is publicly reachable or behind NAT so I give the correct commands.
Sources: Agents telephony integration | LiveKit Documentation | Handling payments with PCI compliance | LiveKit | Creating SIP Inbound Trunks and Dispatch Rules with Python SDK | Outbound Calling Script | LiveKit Documentation | Simple Call Answering Agent | LiveKit Documentation