Using *-custom contexts overwrites dialplan

Hi Spencer:

We really need a wiki page on this, but your findings are correct, you must be very careful when using any pre-defined context for adding custom code. The two main cases for adding custom code are:

Inbound - Set the context of your trunk to a nonexistent context such as [from-trunk-knight] and then populate the context with lines like this"

[from-trunk-knight]
exten => _X.,1,Noop(Entering user defined context from-trunk-knight in extensions_custom.conf)
; add additional lines
exten => _X.,n,Goto(from-trunk,${EXTEN},1)

Outbound - There is a predial hook specifically for outbound calls called [macro-dialout-trunk-predial-hook]. As it’s a macro, use extension of s, similar to the following:

[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dialout-trunk-predial-hook in extensions_custom.conf)
; add additional lines
exten => s,n,MacroExit

edit
For purely internal calls, custom code can be added to one of the internal predial hooks, in pretty much the same manor as how it is done for the trunk predial hook. [macro-dialout-dundi-predial-hook], [macro-dial-ringall-predial-hook], [macro-dial-hunt-predial-hook], [macro-dialout-one-predial-hook].

More detail here:

2 Likes