Hi, I'm receiving a voice calls that were forward ...
# ask-ai
n
Hi, I'm receiving a voice calls that were forward to my telnyx number When the call get to livekit the caller is the original caller, not the forwarder - for example caller is X - calling to number Y, Y is forwarding the number to my telnyx number, in the call - the caller is X and Y not exists how can I know the forwarder number - Y in the example ?
t
Thanks for reaching out, Niv. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks so much for reaching out! To help you in the best way possible, could you please clarify a few things for me? • Are you looking to identify the original caller's number after a call has been forwarded, or are you trying to see the intermediate number (the forwarder) that redirected the call to your Telnyx number? • Are you currently using LiveKit Agents? If yes, are you managing cold transfers or warm transfers? • Do you happen to know if Telnyx is including headers like
From
,
P-Asserted-Identity
, or
Diversion
in the forwarded call? Getting these details will really help us figure out if the existing SIP participant attributes or transfer methods can support what you’re aiming to do. I’m here to assist every step of the way! Sources: SIP participant | LiveKit Docs | Preserving Caller ID During SIP Transfers in LiveKit Agents
n
1. looking for the intermediate number 2. LiveKit Agent indeed, not sure about the transfer 3. Don't know
t
I understand you're looking to extract the intermediate forwarding number in SIP calls when using LiveKit Agents. While LiveKit doesn’t offer a direct way to get this information, it might still be accessible through SIP headers like
From
,
P-Asserted-Identity
, or
Diversion
, depending on how Telnyx handles forwarded calls. Here’s what I suggest you try next: • Reach out to Telnyx to see if they include these headers in forwarded calls. • Set up your SIP trunk in LiveKit to capture headers by using
headers_to_attributes
or
include_headers
. This can help you map the relevant SIP headers to participant attributes for easier tracking. If you’d like, I’m here to help you with configuring these SIP headers or if you have any other details to share, just let me know. We’ll work through this together! Sources: Preserving Caller ID During SIP Transfers in LiveKit Agents | sip-refer/agent.py | protobufs/livekit_sip.proto
n
Can you give me a code example of how to use the
headers_to_attributes or include_headers ?
t
I'd love to help you get comfortable with using
headers_to_attributes
and
include_headers
in your LiveKit SIP trunk configuration. Here’s a friendly walkthrough: 1. Using
headers_to_attributes
This lets you map specific SIP X-* headers to LiveKit participant attributes. For example:
Copy code
{
  "headers_to_attributes": {
    "X-Custom-Id": "caller_id",
    "X-Tenant": "tenant_name",
    "X-Queue": "queue_id"
  }
}
With this setup, the
X-Custom-Id
header from the SIP INVITE is captured and added as a participant attribute called
caller_id
. Pretty neat, right? 2. Using
include_headers
This feature automatically maps SIP headers to
sip.h.*
participant attributes. Here’s how you can use it: • To auto-map all
X-*
headers:
Copy code
{
  "include_headers": 1
}
• Or, to include all SIP headers:
Copy code
{
  "include_headers": 2
}
3. Example API Request Here’s a sample Create SIP Inbound Trunk request to illustrate everything:
Copy code
curl -X POST <https://your-livekit-url/twirp/livekit.SIP/CreateSIPInboundTrunk> \
-H "Authorization: Bearer <token>" \
-H 'Content-Type: application/json' \
-d '{
  "name": "My Inbound Trunk",
  "numbers": ["+15551234567"],
  "headers_to_attributes": {
    "X-User-ID": "user_id",
    "X-Dept": "department"
  },
  "include_headers": 1
}'
If you have any questions or want to explore this further, please don’t hesitate to reach out. I’m here to help you every step of the way! Sources: SIP APIs | LiveKit Docs | protobufs/livekit_sip.proto
n
Great, thanks, it works I added the headers to the sip trunk in the dashboard and it shows in the headers
t
You're very welcome! I'm so happy to hear that everything is working and the headers are showing up just as you wanted. If you ever have more questions or need a hand with anything else, please don't hesitate to get in touch. I'm here to help!