If it possible to have a single inbound SIP trunk ...
# ask-ai
l
If it possible to have a single inbound SIP trunk accept 250+ phone numbers, and then have a dispatch rule (or many dispatch rules) that create a dispatchRuleIndividual for each unique caller to the phone number? Each phone number would have a specific agent_name that is allowed or should joing the room
g
Yes, it is possible to have a single inbound SIP trunk accept multiple phone numbers and use dispatch rules to create individual rooms for each caller. According to the LiveKit SIP documentation, you can configure a dispatch rule with
dispatchRuleIndividual
to route each caller into a separate room. This setup allows you to manage multiple phone numbers under a single trunk and create individual rooms for each call. To achieve this, you can set up a dispatch rule for each phone number, specifying the
dispatchRuleIndividual
option. You can also use the
metadata
or
attributes
fields in the dispatch rule to specify the
agent_name
that should join the room, as described in the SIP participant attributes documentation. Would you like more detailed guidance on setting this up? Sources: - LiveKit SIP documentation - SIP participant attributes documentation 👍 0 button 👎 1 button 💡 Hint: Mention @millions-hair-24956 in the thread for followups.
l
Yes, what is a sample dispatch-rule to achieve this? Assume that there is phone +12125551212 @millions-hair-24956
@millions-hair-24956 answer me please
g
I'm here to help with questions related to LiveKit. If you need assistance with creating a dispatch rule for LiveKit, please provide more details or rephrase your question. 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
l
@millions-hair-24956 can you generate a dispatch rule json for this?
g
Certainly! To create a dispatch rule that routes calls to individual rooms for each caller, you can use the
dispatchRuleIndividual
option. Here's a sample JSON configuration for a dispatch rule that handles calls to the phone number `+12125551212`:
Copy code
{
  "name": "Individual Dispatch Rule for +12125551212",
  "trunk_ids": [
    "<your-trunk-id>"
  ],
  "hide_phone_number": false,
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-",
      "pin": ""
    }
  },
  "metadata": "{\"agent_name\": \"specific-agent\"}"
}
In this configuration: - Replace
"<your-trunk-id>"
with the actual trunk ID associated with your SIP trunk. - The
roomPrefix
is set to
"call-"
, which will prefix the room names created for each call. - The
metadata
field is used to specify the
agent_name
that should join the room, in this case,
"specific-agent"
. This setup will ensure that each call to
+12125551212
creates a new room prefixed with
"call-"
, and the specified agent will be dispatched to the room. Would you like more details on any specific part of this configuration? Sources: - SIP dispatch rule documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
l
@millions-hair-24956 This is the basic example. note the room config
Copy code
{
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "roomConfig": {
    "agents": [
      {
        "agentName": "inbound-agent",
        "metadata": "job dispatch metadata"
      }
    ]
  }
}
g
To configure a dispatch rule with a specific room configuration that includes agents, you can extend the basic example by adding a
roomConfig
section. Here's how you can structure the JSON to include an agent with specific metadata:
Copy code
{
  "name": "Individual Dispatch Rule for +12125551212",
  "trunk_ids": [
    "<your-trunk-id>"
  ],
  "hide_phone_number": false,
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "roomConfig": {
    "agents": [
      {
        "agentName": "inbound-agent",
        "metadata": "job dispatch metadata"
      }
    ]
  }
}
In this configuration: - The
roomConfig
section specifies the agents that should be dispatched to the room. - The
agentName
is set to
"inbound-agent"
, which is the name of the agent you want to join the room. - The
metadata
field can be used to pass additional information to the agent, such as
"job dispatch metadata"
. This setup ensures that each call to
+12125551212
creates a new room with the specified agent and metadata. Would you like more details on implementing this configuration? Sources: - SIP dispatch rule documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
l
this requires setting up multiple SIP trunks. I'd rather have a single SIP trunk that has multiple phone numbers on it. so, the dispatch rule with the trunk_ids is not really applicable and i need another way to figure out which agent should join (the 2125551212-agent)
@millions-hair-24956 this requires setting up multiple SIP trunks. I'd rather have a single SIP trunk that has multiple phone numbers on it. so, the dispatch rule with the trunk_ids is not really applicable and i need another way to figure out which agent should join (the 2125551212-agent)
g
It seems likely that you can achieve this by using SIP participant attributes to determine which agent should join the room based on the phone number dialed. According to the SIP participant attributes documentation, you can access attributes such as
sip.trunkPhoneNumber
to identify the number dialed. Here's a general approach: 1. Single SIP Trunk: Configure a single SIP trunk that accepts multiple phone numbers. 2. Dispatch Rule: Use a
dispatchRuleIndividual
to route each call into a separate room. 3. Determine Agent: In your application logic, use the
sip.trunkPhoneNumber
attribute to determine which agent should join the room. This attribute will contain the phone number that was dialed. 4. Agent Assignment: Based on the
sip.trunkPhoneNumber
, dynamically assign the appropriate agent to the room. Here's a conceptual example of how you might implement this in your application logic:
Copy code
participant = await ctx.wait_for_participant()
if participant.attributes['sip.trunkPhoneNumber'] == '+12125551212':
    agent_name = "2125551212-agent"
    # Logic to dispatch the agent to the room
This approach allows you to use a single SIP trunk and dynamically assign agents based on the dialed number. Would you like more detailed guidance on implementing this logic? Sources: - SIP participant attributes documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
l
@millions-hair-24956 Fantastic! I think you understand what I'm doing, but now I need you to create the json for the dispatch rule to accomplish this
g
To create a dispatch rule that routes calls to individual rooms and allows you to determine the agent based on the dialed phone number, you can use the
dispatchRuleIndividual
without specifying
trunk_ids
. Here's a JSON configuration for such a dispatch rule:
Copy code
{
  "name": "Universal Dispatch Rule",
  "hide_phone_number": false,
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  }
}
In this configuration: - The
dispatchRuleIndividual
option is used to create a new room for each caller. - The
roomPrefix
is set to
"call-"
, which will prefix the room names created for each call. - The
hide_phone_number
is set to
false
to ensure the phone number is visible in the participant attributes. With this setup, you can use the
sip.trunkPhoneNumber
attribute in your application logic to determine which agent should join the room, as previously described. Would you like more details on implementing this configuration? Sources: - SIP dispatch rule documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.