Link to home
Start Free TrialLog in
Avatar of netrxinc
netrxinc

asked on

How do I tell an Asterisk dialplan to use any available trunk when dialing out using the dialout-trunk macro

I am trying to get my extensions_custom.conf file configured to make an outbound call on any available SIP trunk using [macro-dialout-trunk].

The following line works:
exten=> 2001,1,Macro(dialout-trunk,2,915551212)

I would llke to replace the ,2, with something that reflects any open trunk.  Currently I have 2 trunks, but I will soon be getting several more.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of netrxinc
netrxinc

ASKER

Thanks for the help.  I'm using Asterisk with FreePBX, so I don't want to modify the [macro-dialout-trunk] macro.  What I did was call it [macro-sip-dialout-trunk] and added it to my extensions_custom.conf file.  I reloaded Asterisk and invoke the macro and it hungup. I've attached the appropriate lines from extensions_custom.conf and an error listing from the log.

Appreciate your assistance.

extensions-custom.txt
errorlog.txt
The 1st argument passed to [macro-dialout-trunk] is not identical to the first parameter used in the Asterisk Dial command. Looking at the source of [macro-dialout-trunk] on my FreePBX box, it looks like you would need to change the Dial command in your new macro to this:
exten => s,n,Dial(${OUT_${TRUNK}}/${ARG1})

Or perhaps a better alternative would be to call the FreePBX macro from your macro  - i.e. replace your Dial command with this:
exten => s,n,Macro(dialout-trunk,${TRUNK},${ARG1})

Taking a wider look at your question, I wonder why you consider it necessary to cycle through different trunks and what you mean by an "open trunk". SIP trunks can normally carry more than 1 call at a time. Also, FreePBX does already have functionality in "Outbound Routes" to attempt to call using one trunk and, if that fails, to attempt the same call on a different one. Is it just that you want an inbound call from a particular DDI to redial immediately as an outbound call on another? If so, please look at this previous question:
https://www.experts-exchange.com/questions/24917262/Route-calls-to-Trunk.html
Thanks for your help.  My main problem is that I've been using this software for about a week :)  I rethought what I was doing and took a completely different approach, and am now using the Recording Panel in FreePBX to set an extension to Call Forward to an outside line, thereby letting the existing code and macros handle everything...AND IT WORKS!!!