Internal DID Reroute and predial hook help


(Itzik) #1

Hi guys,

I know this potion can be done with an outbound route and a loop back Trunk. But it’s hard to have the techs remember to keep on adding DIDs to the outbound route as well every time they add an inbound route, so I was thinking of the following:

[macro-dialout-trunk-predial-hook]
exten => s,1,Noop()
exten => s,n,Gotoif($["${DIALPLAN_EXISTS(ext-did-XXXX,${OUTNUM:-10},1)}" = "1"]?ext-did-XXXX,${OUTNUM:-10},1)
exten => s,n,MacroExit

But this does not work. It only works if I specify the DID context, like:

exten => s,n,Gotoif($["${DIALPLAN_EXISTS(ext-did-0012,${OUTNUM:-10},1)}" = "1"]?ext-did-0012,${OUTNUM:-10},1)

Is there a way to make this work, or I need to specify the context for each DID?

Another question:
When using a predial hook with something like

exten => s,n,System(/tmp/script.sh)

And lets say the script tries to reach a server, or sends an email. Is there a possibility for the call to continue in case the script gets stuck? I don’t want calls to get stuck because of that script…
(Running System() asynchronous ?)

Thanks


(Lorne Gaetz) #2

I wrote this years ago which solves this issue: https://gist.github.com/lgaetz/8633920

Testing now to see if it still works in 15.

edit - I fixed some typos in the sample dialplan and added some notes but it still works!


(Itzik) #3

Sorry about the delayed response, Lorne.

I have some trouble getting this to work.

See log: https://pastebin.com/LyvQDJJB

Thank you


(Lorne Gaetz) #4
-- Executing [s@macro-dialout-trunk-predial-hook:2] AGI("SIP/64066-00000041", "lgaetz-didloopback.php,2121234567[,verbose]") in new stack

Remove the square brackets around ,verbose and reload.


(Itzik) #5

We’re getting there…

The provider said client is using sends the DIDs as 10 digits, but requires outgoing calls as 11 digits.
For now I did the following:

[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dialout-trunk-predial-hook in extensions_custom.conf)
exten => s,n,agi(lgaetz-didloopback.php,${DIAL_NUMBER:-10},verbose)  
exten => s,n,GotoIf($["${didloop}" != ""]?redirect)
exten => s,n,MacroExit
exten => s,n(redirect),goto(from-trunk,${DIAL_NUMBER:-10},1)

It works… But is there a better way to get this done?

Another question: this PBX has around 150 users and a ton of DIDs, they are constantly placing outgoing calls. Is there any risk? should I implement it as a FastAGI?

Final question: what happens if that script get’s stuck, what will happen to the call?

Thanks again.


(Lorne Gaetz) #6

There is support in the script for doing this as well, but it’s no better than what you’re doing in dialplan.

As for you question about how it scales, I can’t answer. It may be in use on larger systems, but if so, I have no knowledge of it. I would not expect major issues, but you’ll have to keep an eye on things in the near term to be sure. FastAGI is generally recommended now for all systems, and particularly so for very busy ones.


(Itzik) #7

Sorry for not being responsive.

This is working fine so far. Thank you so much, Lorne!


(system) closed #8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.