Using *-custom contexts overwrites dialplan

Why is it that putting dialplan code into *-custom contexts in extensions_custom.conf overwrites the next dialplan rule(s)? I had specified from-pstn-custom, thinking that it would simply insert this in the call flow since from-pstn includes it, but it overwrote the call to the user-callerid macro and so caller ID was not being passed. Why does this happen? And is there any way to stop it from happening? I have a few custom lines I need to be processed for certain calls.


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"

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:

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

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:


That seems to be working well! I’m glad that macro is there. I don’t know what I would do without it.

I had tried to put all extensions into a new context and then had Goto(from-internal..., similar to what you suggested above on the from-pstn side, but that approach broke directed call pickups because the extensions were no longer in from-internal.

But the macro seems to be working fine.

Thanks for the info.


1 Like