Skip to content

Instantly share code, notes, and snippets.

@ruhnet
Forked from backslash7/extensions_custom.conf
Created December 18, 2020 21:00
Show Gist options
  • Save ruhnet/edff8dba7990a4890d6bc47219117bd4 to your computer and use it in GitHub Desktop.
Save ruhnet/edff8dba7990a4890d6bc47219117bd4 to your computer and use it in GitHub Desktop.
How to strip destination number from SIP To: header and use it as DID
; Assign this context to your incoming SIP trunk settings
[custom-get-did-from-sip]
exten => _X.,1,Noop(Fixing DID using information from SIP TO header)
exten => _X.,n,NOOP(Header is: ${SIP_HEADER(TO)})
exten => _X.,n,Set(pseudodid=${SIP_HEADER(TO)})
exten => _X.,n,Set(pseudodid=${CUT(pseudodid,@,1)})
exten => _X.,n,Set(pseudodid=${CUT(pseudodid,:,2)})
exten => _X.,n,Noop(Pseudo DID is: ${pseudodid})
exten => _X.,n,Goto(from-trunk,${pseudodid},1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment