Can my locally hosted sip server communicate with ...
# ask-ai
s
Can my locally hosted sip server communicate with livekit cloud server, and has its own ruls?
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.
Absolutely! Your locally hosted SIP server can definitely chat with the LiveKit cloud server and set up its own rules. This way, you get to customize call-routing and handle SIP-based telephony just the way you want within LiveKit. Here’s how you can make it happen by setting up SIP Trunks and Dispatch Rules: • SIP Inbound Trunk: This is where you decide how incoming calls get authenticated and accepted—think allowed numbers, IPs, and credentials. • SIP Outbound Trunk: Set up your outbound calls with SIP endpoints, caller IDs, and make sure everything follows regional rules. • SIP Dispatch Rules: These help you route incoming calls into LiveKit rooms, whether that’s sending them straight to a specific room or creating unique rooms for each caller on the fly. When you’re ready to deploy, your SIP server will connect to LiveKit using API credentials, a WebSocket URL, and a shared Redis endpoint. You can also pick region-specific endpoints to stay compliant with local telephony regulations. If you’d like, I’m here to walk you through the setup or help configure these rules—just give me a shout! Sources: SIP cloud and region pinning | LiveKit Docs | Self-hosted SIP server | LiveKit Docs | test/integration/sip_test.go | protobufs/livekit_sip.proto | Accepting incoming calls | LiveKit Docs
s
I want to know how can i create the SIP Inbound Trunk and SIP Dispatch Rules on my local sip server not on the telephony configuration on the cloud server.
t
Hey there! To get your SIP Inbound Trunk and SIP Dispatch Rules set up on your local SIP server for LiveKit integration, just follow these simple steps: 1. Create a SIP Inbound Trunk This is where you define how incoming calls are authenticated and accepted. You can do this using the LiveKit CLI or SDKs: • Using CLI: Start by creating a file called
inbound-trunk.json
with the following content:
Copy code
{
  "trunk": {
    "name": "My Inbound Trunk",
    "numbers": [
      "+15105550100"
    ],
    "auth_username": "<your_sip_username>",
    "auth_password": "<your_sip_password>"
  }
}
Then just run this command:
Copy code
lk sip inbound create inbound-trunk.json
• Using SDKs: If you prefer coding, here’s how you can do it with the LiveKit Server SDK (like Node.js):
Copy code
const trunk = await sipClient.createSipInboundTrunk(
  'inbound-trunk',
  ['+15105550100'],
  {
    auth_username: 'TWILIO_SIP_USERNAME',
    auth_password: 'TWILIO_SIP_PASSWORD',
  }
);
2. Create a SIP Dispatch Rule This part decides how calls get routed to your LiveKit rooms: • Using CLI: Create a file named
dispatch-rule.json
with this content:
Copy code
{
  "dispatch_rule": {
    "rule": {
      "dispatchRuleIndividual": {
        "roomPrefix": "call-"
      }
    }
  }
}
Then run this command:
Copy code
lk sip dispatch-rule create dispatch-rule.json
• Using SDKs: Or, using the LiveKit Server SDK (Node.js example):
Copy code
await sipClient.createSipDispatchRule(
  {
    type: 'individual',
    roomPrefix: 'call',
  },
  {
    name: 'inbound-dispatch-rule',
    trunkIds: [trunk.sipTrunkId],
  }
);
3. A Few Notes for Your Local SIP Server Setup Make sure your local SIP server has: • A publicly accessible IP or domain • The SIP port open (default is 5060) and RTP port range exposed (default 10000–20000) • A
config.yaml
file configured with your LiveKit credentials and Redis settings You can run the SIP service either with Docker or natively using this configuration. If you hit any bumps or want me to walk you through any of these steps, just give me a shout—I’m here to help! Sources: src/setup-livekit.ts | Creating SIP Inbound Trunks and Dispatch Rules with Python SDK | sipclient.go | src/main/kotlin/io/livekit/server/SipServiceClient.kt | SIP Integration | livekit/livekit_composite | DeepWiki
s
Will the rules conflict with the sip server on livekit cloud?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!