Macro-dialout-trunk-custom not included

I need to make some adjustments to the context macro-dialout-trunk for outbound calls. It includes the context macro-dialout-trunk-custom.
So I modified the custom context, but it does not get called. Is there something I’ve missed?
For now the custom context just contains a noop, so I can see that it gets called, but it does not.

It is often difficult to use the *-custom contexts and if they do work, there may be unintended consequences. There is a context reserved specifically for adding dialplan to an outgoing call, try using:


Hey Lorne!

Thanks for responding…I work with Charles and was able to write a custom context that we called using custom destinations and misc apps.

We actually only want the custom dialplan calls to happen for a particular trunk; could this be specified somewhere else rather than using case statements? We COULD send them through all trunks but it could potentially be counter-productive and is more of a work-around than a solution.

Also, we haven’t set up module signing so changing this file causes a security warning…going to need to fix that >.>

There may well be a dozen ways of doing this, but simplest way is to add to extensions_custom.conf to the macro context noted above with a line like:

exten => s,n,Gotoif($["${custom}" = "SIP/trunk_name_from_GUI"]?<context>,<exten>,<priority>)

Thanks man :slight_smile: Once we get the module signing down we’ll probably do something like this.

If all you are doing is editing extensions_custom.conf there is no warning about module signatures.

That context is in extensions.conf on our server (running latest FreePBX v12 + Asterisk v11.14.2):

[[email protected] asterisk]# grep -n “macro-dialout-trunk-predial-hook” *.conf
extensions.conf:15:; If you need to use [macro-dialout-trunk-predial-hook], [ext-did-custom], or
extensions.conf:324:; macro-dialout-trunk-predial-hook:

technically yes it is, but grep doesn’t give you the whole story:

; macro-dialout-trunk-predial-hook:
; this macro intentionally left blank so it may be safely overwritten for any custom
; requirements that an installation may have.
; the macro is called by macro-dialout-trunk just prior to making a Dial() attempt
; to a trunk.
; if set to “BYPASS” then this trunk will be skipped
exten => s,1,MacroExit()

Right; should I add the context to the custom file as well, then, and it will use that instead of this one?
If I overwrite anything in that file, it will trigger the warnings…that’s where my confusion is coming from.

I’ve already written some test code into the extensions.conf :stuck_out_tongue: works great!

Add these lines to extensions_custom.conf

exten => s,1,Noop(This line will appear in the log for all outbound calls)

In its simplest, that is all you do.

Okay, thanks again Lorne! I’ll play with this some more :smiley:

Hi Lorne

Sorry to drag up an old tread; I have found that ${custom} returns different results depending if it is a SIP or PJSIP trunk.

For example, SIP, returns as you said SIP/trunk_name_from_GUI, where if PJSIP it returns PJSIP.


There is a better way to apply a block of custom code to calls over a specific trunk. See this post:

The post talks about pjsip trunks, but the same technique will work on chan_sip. You define a subroutine with a new context name, then add the sub as a dial option to the trunk in question using the b option:


Hi Lorne

I tried that; however I couldn’t get it to work. as required. Part of my requirement was to check the outbound CLID that was going to be used, and change it if required, however it seemed too late to change it by the time it going to the subroutine above…

exten => dditest,1,NoOp(Debug: CALLERID(number): ${CALLERID(number)})
exten => dditest,n,Set(DDIALLOW=12345678|87654321)

; Check the Proposed DDI to see if it matches the allowed range, it it does, move to ddimatch
exten => dditest,n,GotoIf($[${CALLERID(number)}:"${DDIALLOW}"]?ddimatch)

; This runs if the DDI number was not matched
exten => dditest,n,NoOp(Debug: ${CALLERID(number)} is a invalid DDI - set to 12345678)
exten => dditest,n,Set(CALLERID(number)=12345678)
exten => dditest,n,Return

; This runs if the DDI number was matched
exten => dditest,n(ddimatch),NoOp(Debug: ${CALLERID(number)} is a valid DDI)
exten => dditest,n,Return

This does work in [macro-dialout-trunk-predial-hook] without any issues - however as I only want to apply it to certain trunks, I was keen on using ${custom} - the best I can currently find is ${OUT_${DIAL_TRUNK}_SUFFIX}

Would be much tidier if I could do it all within the b(context^exten^priority), as I also need to add a header, which the only method to do so was to use the b(context^exten^priority), then I have the code above to address the outbound clid

I would explicitly define didmatch,1 et al in your context the n thing will likely confuse a reference

1 Like