if i pass in header to sip when making call, how d...
# ask-ai
n
if i pass in header to sip when making call, how do i retrieve it in livekit
t
Thanks for reaching out, Hwuiwon. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to help you retrieve SIP headers passed during a call in LiveKit! You can easily map these headers to participant attributes using the
headers_to_attributes
configuration. This way, specific SIP
X-*
headers from the SIP INVITE or 200 OK response will be automatically converted into participant attributes, which you can then access through the LiveKit participant APIs. Here’s a simple way to do it: 1. Set up your SIP trunk or dispatch rule with a
headers_to_attributes
map that links SIP header names to participant attribute names. For example:
{"headers_to_attributes": {"X-Custom-Header": "caller_type"}}
2. Once mapped, you can retrieve the attribute from the participant data using server SDKs or APIs. For instance, in JavaScript:
Copy code
const participant = room.getParticipantByIdentity('sip_...');
console.log(participant.attributes['caller_type']);
Alternatively, you might consider using the
include_headers
field to map SIP headers to the
sip.h.*
namespace, but I usually recommend
headers_to_attributes
for headers you know in advance. If you have any questions or need a hand with this, please don’t hesitate to ask—I’m here to support you! Sources: SIP participant | LiveKit Docs | protobufs/rpc/sip.proto | livekit-protocol/src/livekit.rs | SIP APIs | LiveKit Docs