When receiving an inbound call, is there a way to ...
# ask-ai
a
When receiving an inbound call, is there a way to execute a hook before the Dispatch rule is executed?
t
Thanks for reaching out, Arnau. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely, you can execute a hook before a Dispatch rule runs for inbound calls. Using the
WithDispatchRuleReplace
function, you’re able to set a callback that tweaks or even replaces dispatch rules before the matching process kicks in. This is a great way to dynamically adjust dispatch rules based on what’s happening at runtime or by pulling in external data. For instance, you might want to change room names, update PIN requirements, or shift rule priorities on the fly. If you'd like, I’m here to help with more details or walk you through the implementation—just let me know! Sources: protobufs/livekit_sip.proto
a
I haven't found any documentation on this WithDispatchRuleReplace
t
The
WithDispatchRuleReplace
function is a handy tool that lets you dynamically modify or replace dispatch rules before they get matched against incoming SIP calls. I understand the documentation might feel a bit light on examples or detailed steps, so I’m here to help! To get started, you would create a
DispatchRuleReplaceFunc
callback. This callback takes a
*livekit.SIPDispatchRuleInfo
object and returns a modified version of it. Then, you pass this callback to
WithDispatchRuleReplace
, which works together with the
MatchDispatchRuleIter
function. If you’d like, I’m more than happy to walk you through the implementation or discuss any specific needs you have. Just let me know how I can assist you further! Sources: sip/sip_test.go | SIP dispatch rule | LiveKit Docs
a
can i do this in python?
t
I wanted to share that the
WithDispatchRuleReplace
function isn’t explicitly documented as available in the Python SDK for LiveKit. It seems to be mainly implemented in the Go SDK. If you’re working with Python, this feature might not be directly accessible right now. Please feel free to reach out if you’d like some help exploring other options or double-checking compatibility—I’m here to support you!