I am getting error when creating dispatch rule, he...
# ask-ai
a
I am getting error when creating dispatch rule, help me to correct the configuration and create the dispatch rule properly. Command Used: lk sip dispatch create dispatch-rule.json Error: twirp error internal: Unsupported SIP Dispatch Rule: <nil> Rule configuration: { "dispatch_rule": { "rule": { "dispatchRuleIndividual": { "roomPrefix": "call-" } }, "trunk_ids": ["ST_46zZZBU8zjTs"], "name": "Sales Dispatch", "roomConfig": { "agents": [ { "agentName": "Sales-Agent", "metadata": "sales agent dispatch" } ] } } }
t
Thanks for reaching out, Lokesh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It looks like you're encountering the error "twirp error internal: Unsupported SIP Dispatch Rule: <nil>". This usually happens when the configuration doesn’t clearly specify a valid dispatch rule type. To help you fix this, please make sure the
rule
field in your configuration explicitly defines one of the supported dispatch rule types. Here are the options you can use: • Direct Dispatch Rule: This sends all callers into a specific room. For example:
Copy code
{
  "rule": {
    "dispatchRuleDirect": {
      "roomName": "open-room"
    }
  },
  "name": "My dispatch rule"
}
• Caller Dispatch Rule (Individual): This creates a new room for each caller. Here's how it looks:
Copy code
{
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "name": "My dispatch rule"
}
• Callee Dispatch Rule: This places callers into rooms based on the called number. Example:
Copy code
{
  "rule": {
    "dispatchRuleCallee": {
      "roomPrefix": "number-",
      "randomize": false
    }
  },
  "name": "My dispatch rule"
}
From what you shared, it seems like you’re using the
dispatchRuleIndividual
type correctly, which is great! Just double-check that the overall structure matches the expected format exactly. If you’re still seeing the error, it might help to review the JSON syntax carefully and make sure there aren’t any extra or conflicting rule types accidentally included. Sources: SIP dispatch rule | LiveKit Docs | cmd/lk/sip.go | protobufs/livekit_sip.proto
a
I tried all these, still same error. what could be the problem?
t
I'm sorry you're encountering the "twirp error internal: Unsupported SIP Dispatch Rule: <nil>". This can happen for a few common reasons, and I'd love to help you troubleshoot it: • Missing or Incorrect Rule Type: Please check that the
rule
field is set to one of the supported types (
DispatchRuleDirect
,
DispatchRuleIndividual
, or
DispatchRuleCallee
). • Malformed JSON or API Request: Make sure your JSON is correctly structured and includes all the necessary fields. For example,
roomName
is required when using
DispatchRuleDirect
. • Incorrect Use of SDKs or CLI: If you're using the CLI, try to avoid setting conflicting flags like both
--direct
and
--caller
at the same time. • Validation Failure: The
CreateSIPDispatchRuleRequest
needs a valid
rule
field. If it’s missing or null, this error can pop up. Could you please double-check your configuration to ensure the
rule
field is correctly defined? If the problem continues, it would be really helpful to know whether you're using the CLI, SDK, or API directly. That way, I can guide you more precisely and get this sorted out together. Sources: livekit/livekit_sip.pb.go | SIP dispatch rule | LiveKit Docs | SIP APIs | LiveKit Docs | cmd/lk/sip.go
a
what is the command i should use when using lk cli?
t
I'd be happy to help you create a SIP dispatch rule using the LiveKit CLI! You can start by using this command:
Copy code
lk sip dispatch create dispatch-rule.json
In this case,
dispatch-rule.json
is the file where you'll have your dispatch rule configuration. Just make sure the JSON file is set up correctly and includes a valid rule type, like
dispatchRuleDirect
,
dispatchRuleIndividual
, or
dispatchRuleCallee
. If you’d rather define the rule right in the command without using a JSON file, you can use these handy flags: • `--name`: To give your dispatch rule a name • `--trunks`: To list the trunk IDs • `--direct <room-name>`: For a direct dispatch rule • `--caller <prefix>`: For an individual caller dispatch rule • `--callee <prefix>`: For a callee dispatch rule (you can also add
--randomize
to add a random suffix to room names) For example, if you want to create a direct dispatch rule, you could use:
Copy code
lk sip dispatch create --name "Sales Dispatch" --trunks "ST_46zZZBU8zjTs" --direct "open-room"
If you have any questions or need a hand with this, just let me know—I'm here to help! Sources: Inbound calls with Twilio Voice | LiveKit Docs | Accepting incoming calls | LiveKit Docs | Accepting incoming calls | LiveKit Docs | autocomplete/fish_autocomplete