<@U07FRRZH2GN> In my self-hosted livekit and SIP s...
# ask-ai
m
@icy-policeman-64898 In my self-hosted livekit and SIP server I configured inbound and dispatch rule correctly with explicit agent-name but all calls directed to default agentname "" why it happedn and how to debug this
t
Thanks for reaching out, Rajadurai. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Could you please share a few details to help us figure this out together? • The dispatch rule configuration JSON • The agent configuration code showing the
agent_name
• The SIP trunk configuration details With this info, we can make sure everything’s set up just right for explicit dispatch. Thanks so much! Sources: SIP troubleshooting guide | LiveKit Docs | protobufs/livekit_sip.proto | Accepting inbound calls | LiveKit Docs | Agents telephony integration | LiveKit Docs | Agents telephony integration | LiveKit Docs
m
• Inbound rule.json
Copy code
{
  "trunk": {
    "name": "trunk",
    "numbers": [
      "+12345678"
    ],
    "krisp_enabled": true
  }
}
dispatch rule.json •
Copy code
{
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "name": "self-hosted-dispatch",
  "trunk_ids": [
    "ST_ZkH4MQdybanR"
  ],
  "roomConfig": {
    "agents": [
      {
        "agentName": "self-hosted-agent",
        "metadata": "job dispatch metadata"
      }
    ]
  }
}
t
The issue where calls are routed to the default agent instead of the intended one might be due to some configuration mismatches or conflicts. No worries though—let’s walk through some steps together to help you debug and fix this: 1. Verify Agent Name Configuration: Double-check that the agentName in your dispatch rule exactly matches the agent_name in your agent's setup. For example, in your agent code:
Copy code
agents.cli.run_app(agents.WorkerOptions(
    agent_name="self-hosted-agent"
))
2. Review Dispatch Rule Configuration: Make sure your dispatch rule is specific enough to catch the incoming call. For instance, confirm that the number +12345678 is properly set up in the rule. 3. Check for Dispatch Rule Conflicts: Sometimes, conflicting dispatch rules can override what you want. It’s worth checking for any overlaps and using conflict resolution if needed. 4. Verify Explicit Dispatch Configuration: For telephony integrations, explicit dispatch is key. Ensure the agentName is set in your dispatch rule so calls don’t automatically go to the default agent. 5. Test with Specific Dispatch Rules: Try creating a dispatch rule that clearly routes calls to your intended agent. For example:
Copy code
{
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "roomConfig": {
    "agents": [
      {
        "agentName": "self-hosted-agent"
      }
    ]
  }
}
You can create this rule using the LiveKit CLI:
Copy code
lk sip dispatch create dispatch-rule.json
6. Review Logs: Take a peek at the logs for any errors or warnings related to dispatch rule matching or how agents are being routed. 7. Ensure Agent Availability: Lastly, double-check that your self-hosted-agent is actually running and ready to take calls. If you hit any bumps or want me to walk through this with you, just let me know—I’m here to help! Sources: SIP troubleshooting guide | LiveKit Docs | Agents telephony integration | LiveKit Docs | sip/sip.go
m
2025-08-18T040121.615Z INFO livekit.api service/twirp.go:124 API SIP.CreateSIPInboundTrunk {"service": "SIP", "method": "CreateSIPInboundTrunk", "trunk": {"sipTrunkId": "ST_KqPtGG58gfEy", "name": "trunk", "numbers": ["+918035739517"]}, "duration": "424.807µs", "status": "200"} I created dispatch rule with your example but my log created this
t
The log entry shows that a SIP inbound trunk was successfully created — great job on this important step for your telephony setup! To make sure your dispatch rule works smoothly, here are a few things to double-check: 1. Trunk Association: Make sure your dispatch rule is linked to the right SIP trunk by using the sipTrunkId. For you, that’s ST_KqPtGG58gfEy. 2. Dispatch Rule Configuration: Confirm that your dispatch rule includes the correct room prefix and agent name. Here’s an example to guide you:
Copy code
{
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "roomConfig": {
    "agents": [
      {
        "agentName": "self-hosted-agent"
      }
    ]
  },
  "trunk_ids": [
    "ST_KqPtGG58gfEy"
  ]
}
3. SIP Provider Settings: Double-check that your SIP provider’s settings line up with your trunk configuration, including allowed IP addresses and authentication details. If you’re still running into issues, take a peek at the logs for any errors about dispatch rule matching or agent routing. And of course, feel free to reach out if you want me to help troubleshoot further!
m
I checked all correct but while receiving call It dispatch my call to default agent
t
If calls are still being sent to the default agent even though everything seems set up correctly, no worries! Here are a few extra things you can check to help sort it out: 1. Verify Agent Name: Make sure the agentName in your dispatch rule exactly matches the agent_name in the worker configuration. Even a tiny difference can cause this hiccup. 2. Check Room Configuration: Double-check that the dispatch rule includes the right agentName inside the roomConfig.agents field. For example:
Copy code
{
  "roomConfig": {
    "agents": [
      {
        "agentName": "self-hosted-agent"
      }
    ]
  }
}
3. Disable Automatic Dispatch: Make sure explicit dispatch is turned on by setting the agent_name in the worker options. This helps avoid calls going automatically to the default agent. 4. Review Dispatch Rules: Take a look to see if there are multiple or conflicting dispatch rules that might be overriding what you want. 5. Confirm Agent Availability: Check that the agent self-hosted-agent is up and running, ready to take calls. It’s also a good idea to peek at the agent’s logs for any errors. 6. SIP Trunk Matching: Make sure the SIP trunk’s inbound numbers or IP addresses are set up correctly to match the calls you expect. If you’re still stuck after these checks, feel free to share the agent’s logs or any other details about your setup. I’m here to help you get this sorted out! Sources: Agents telephony integration | LiveKit Docs | sip/sip_test.go | SIP troubleshooting guide | LiveKit Docs | SIP dispatch rule | LiveKit Docs