relationship between dispatch rules and inbound tr...
# ask-ai
c
relationship between dispatch rules and inbound trunk
t
Thanks for reaching out, Sai. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Dispatch rules in LiveKit are associated with specific trunks and control how inbound calls are handled. When an inbound call is received, LiveKit SIP checks for a matching dispatch rule. If a match is found, a SIP participant is created for the caller and placed into a LiveKit room based on the dispatch rule's configuration. This setup determines whether callers are placed in the same room or different rooms. Additionally, multiple dispatch rules can be linked to the same trunk, provided each rule has a unique pin. This allows for flexible call routing within a single trunk configuration. Sources: SIP overview | LiveKit Docs | Accepting inbound calls | LiveKit Docs
c
im confused on the relationship between inbound trunk and dispatch rules for inbound phone calls. If I want a different set of metadata being passed in for each inbound phone call (regardless of who is calling who). how can I do this? do I have to create a new inbound trunk and a new set of dispatch rules each time?
t
To pass a different set of metadata for each inbound phone call in LiveKit, you do not necessarily need to create a new inbound trunk and a new set of dispatch rules each time. Instead, you can configure custom metadata within the dispatch rules. This metadata will be inherited by all SIP participants created by that rule. For example, you can define metadata like this:
Copy code
{
  "metadata": "{\"is_internal\": true}",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  }
}
The metadata field can store arbitrary data (typically in JSON format) for your application, and it will be applied to all participants created by the dispatch rule. Additionally, you can configure other properties for incoming calls, such as SIP headers, participant attributes, and session properties, through the trunk configuration. If you need unique metadata for every call, you may need to dynamically adjust the dispatch rule or use a mechanism to differentiate calls based on their metadata requirements. Sources: SIP dispatch rule | LiveKit Docs | SIP inbound trunk | LiveKit Docs | SIP APIs | LiveKit Docs
c
in twilio when I am calling the inbound phone number, how do I pass specific metadata in?
t
When calling the inbound phone number from Twilio, you can pass specific metadata to LiveKit in the following ways: 1. Using SIP Headers: Twilio allows you to include custom attributes through SIP headers. You can configure "X-*" SIP headers with your trunk using the "headers_to_attributes" mapping in LiveKit. This enables you to pass metadata dynamically with each call. 2. Setting Metadata in Dispatch Rules: You can define metadata in the dispatch rule, which will be inherited by all SIP participants created by that rule. For example:
Copy code
{
  "metadata": "{\"is_internal\": true}",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  }
}
1. Configuring Metadata in the Trunk: You can also set initial metadata when creating an inbound trunk. For example:
Copy code
{
  "trunk": {
    "name": "My inbound trunk",
    "metadata": "your-metadata-here",
    "numbers": [
      "+15105550100"
    ]
  }
}
Using these methods, you can pass specific metadata for each inbound call. If you need further assistance, feel free to ask! Sources: SIP participant | LiveKit Docs | SIP dispatch rule | LiveKit Docs | SIP APIs | LiveKit Docs
c
no I want dynamic metadata
t
I'm sorry, but I don't have the information you need at the moment. If you would like a member of the LiveKit team to respond, please ask your question in one of the other channels.
c
explain the sip headers part please. are you sauing that I can pass certain data in when triggering an inbound phone call?
hello?