cuddly-vr-85751
12/11/2025, 6:46 PMtall-airline-16756
12/11/2025, 6:46 PMtall-airline-16756
12/11/2025, 6:46 PMcuddly-vr-85751
12/11/2025, 6:47 PMtall-airline-16756
12/11/2025, 6:47 PMdocker pull livekit/generate
docker run --rm -it -v $PWD:/output livekit/generate
• Deploy using the produced docker-compose.yaml and caddy.yaml (or use the init_script.sh / cloud‑init).
• Open required ports: TCP 22, 443, 7880, 7881 and UDP 7882. Ensure DNS for your domain points to the VM and TLS is active so clients can use wss://your-domain.
2) Deploy LiveKit SIP server (telephony bridge)
• Quick Docker Compose:
wget https://raw.githubusercontent.com/livekit/sip/main/docker-compose.yaml
docker compose up -d
• Or run natively with a `config.yaml`:
api_key: <your-livekit-api-key>
api_secret: <your-livekit-api-secret>
ws_url: ws://localhost:7880
redis:
address: localhost:6379
sip_port: 5060
rtp_port: 10000-20000
use_external_ip: true
logging:
level: debug
then livekit-sip --config=config.yaml.
• Open SIP signaling port 5060 and RTP port range (10000–20000) on your firewall.
3) Configure Twilio SIP trunk
• Purchase a Twilio phone number.
• Create a SIP Trunk in Twilio and set origination (inbound) to your LiveKit SIP endpoint (e.g., sip:your-server.com:5060 or the Twilio trunk domain if using Twilio-managed SIP).
• For outbound, add credential lists (username/password) and configure your SIP trunk’s termination settings.
• Associate the Twilio phone number with the trunk.
4) Create inbound trunk & dispatch rule with LiveKit Python SDK
• Use the SIP API (requires JWT with sip.admin permission). Example:
import asyncio
from livekit import api
from livekit.protocol.sip import (
CreateSIPInboundTrunkRequest, SIPInboundTrunkInfo,
CreateSIPDispatchRuleRequest, SIPDispatchRule, SIPDispatchRuleIndividual
)
async def setup_sip():
lkapi = api.LiveKitAPI(url="http://localhost:7880", api_key="API_KEY", api_secret="API_SECRET")
inbound_trunk = await lkapi.sip.create_sip_inbound_trunk(
CreateSIPInboundTrunkRequest(
trunk=SIPInboundTrunkInfo(
name="Twilio Inbound",
numbers=["+15105550100"],
auth_username="twilio_user",
auth_password="twilio_pass"
)
)
)
await lkapi.sip.create_sip_dispatch_rule(
CreateSIPDispatchRuleRequest(
trunk_ids=[inbound_trunk.sip_trunk_id],
rule=SIPDispatchRule(
dispatch_rule_individual=SIPDispatchRuleIndividual(room_prefix="call-")
)
)
)
await lkapi.aclose()
asyncio.run(setup_sip())
5) Build/deploy your Python agent to answer calls
• Use LiveKit agents (MultimodalAgent / AgentSession). Minimal example:
from livekit.agents import AgentContext, JobContext, WorkerOptions, cli
from livekit.plugins.openai import RealtimeModel
import asyncio
async def entrypoint(ctx: JobContext):
await ctx.connect()
agent = MultimodalAgent(model=RealtimeModel(instructions="Help the caller."))
agent.start(ctx.room)
await agent.say("Hello! How can I assist you?")
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
• Run the agent where it can reach your LiveKit server. The agent will join rooms created by dispatch rules and can speak/save audio.
6) Test flows
• Inbound: call the Twilio number — Twilio forwards to your SIP endpoint → LiveKit SIP server creates a room → dispatch rule maps to room prefix → your agent joins and answers.
• Outbound: configure an outbound trunk and use create_sip_participant() to place calls.
Notes & tips
• SIP API calls require a JWT with sip.admin.
• Enable krisp noise cancellation by setting krisp_enabled=True if needed.
• Ensure NAT/external IP settings are correct for RTP media.
Would you like:
• the exact LiveKit SIP config.yaml filled with your values,
• a ready-to-run Docker Compose + agent example,
• or help creating the JWT with sip.admin permission? Sources: Deploy to a VM | LiveKit docs | Running LiveKit on AWS | Create and configure a Twilio SIP trunk | LiveKit docs | Self-hosted SIP server | LiveKit docs | Creating SIP Inbound Trunks and Dispatch Rules with Python SDKcuddly-vr-85751
12/11/2025, 7:06 PMtall-airline-16756
12/11/2025, 7:06 PMconfig.yaml) when running the SIP server (e.g., redis: address: localhost:6379).
Do you want a Docker Compose snippet showing LiveKit SIP + Redis?cuddly-vr-85751
12/11/2025, 7:06 PMtall-airline-16756
12/11/2025, 7:07 PM