is there any webhook/callback for event like "sip_...
# ask-ai
b
is there any webhook/callback for event like "sip_call_incoming"?
t
Thanks for reaching out, Jura. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely, LiveKit does support webhooks for the
sip_call_incoming
event. This event is part of the SIP analytics system and gets triggered whenever an inbound SIP call comes in. To get this set up smoothly, here’s what you can do: • First, set up your webhook endpoint to handle SIP-related events. • Then, configure your LiveKit server to send webhooks to your endpoint. • Finally, make sure to handle the incoming webhook payload, which follows the
sip:<call_id>
pattern. If you’d like, I’m here to help with any more details or walk you through the setup. Just let me know! Sources: livekit/livekit_analytics.pb.go | Webhook & Event System | livekit/livekit_composite | DeepWiki | Accepting inbound calls | LiveKit Docs | livekit-protocol/livekit/protocol/sip.py
b
Copy code
same => n,Set(PJSIP_HEADER(add,X-SIP-Call-Received)=${NOW})
i have this line on my asterisk server before dialing to livekit. on livekit how can i access this header?
t
I'm happy to help you access the
X-SIP-Call-Received
header in LiveKit! You can do this by mapping it to a participant attribute. Here’s a simple way to get started: 1. Explicit Header Mapping: Set up your SIP trunk to map the header like this:
Copy code
{
  "headers_to_attributes": {
    "X-SIP-Call-Received": "call_received_timestamp"
  }
}
1. Automatic Header Mapping: Alternatively, you can use the
include_headers
option to automatically map all
X-*
headers. This will make the header available as
sip.h.x-sip-call-received
. 2. Then, you can access the mapped attribute directly through the participant’s attributes in your application. If you’d like, I’m here to guide you through configuring this or help you access these attributes in your SDK—just let me know! Sources: protobufs/livekit_sip.proto | SIP participant | LiveKit Docs | SIP APIs | LiveKit Docs
b
where does Explicit Header Mapping appear on docs?
t
I'm glad you asked about explicit header mapping! You'll find it nicely detailed in the SIP APIs section of the LiveKit documentation. There, the
headers_to_attributes
parameter is explained—it lets you map custom SIP headers (such as
X-SIP-Call-Received
) to participant attributes. This can be super helpful for routing calls or grabbing custom data. If you'd like, I’m here to help you find the exact part or walk you through how to set it up. Just let me know! Sources: SIP APIs | LiveKit Docs | livekit-protocol/src/livekit.rs | SIP overview | LiveKit Docs
b
so these are hidden feature that does not appear on dashboard
t
Absolutely, features like explicit header mapping are usually set up programmatically and aren't directly available in the LiveKit dashboard. These configurations are often done through API settings or SIP trunk setup files. If you'd like, I’m here to help guide you through the process—just let me know!
b
can this be done via livekit cli? if yes, give me the update command
t
Absolutely! You can set up explicit header mapping using the LiveKit CLI, and it’s pretty straightforward with a JSON file. Here’s a simple way to get you started: 1. First, create a JSON file (let’s call it
trunk-config.json
) where you’ll put your header mapping. For example:
Copy code
{
  "name": "trunk-with-header-mapping",
  "headers_to_attributes": {
    "X-SIP-Call-Received": "call_received_timestamp"
  }
}
1. Next, run the CLI command to update your SIP trunk like this:
Copy code
# For inbound trunk
lk sip inbound update --id your-trunk-id trunk-config.json

# For outbound trunk
lk sip outbound update --id your-trunk-id trunk-config.json
If you’d like, I’m here to help you create that JSON file or walk you through the command—just let me know! Sources: cmd/lk/examples/rtmp-ingress.json | SIP APIs | LiveKit Docs | livekit-protocol/src/livekit.rs