Skip to main content

Choose trunk for forwarded calls

Posted by jesperkjeldsen on Wed, 09/01/2010

Hi
I have implemented the changes from this post and it works just the way it should:
https://www.thirdlane.com/forum/use-different-trunks-per-extensions-and…

Except when a user has enabled forwarding. Then the scripts handling the forward (I assume that is mainly tl-userexten-base), dosn't look at the extensions tag but uses the default trunk.

When I see in tl-userexten-base I guess its around here I need to do something (first clone etc.):
;; CALL FORWARDING

exten => s,n(forwarding),Set(FORWARD=${DB(${THISEXT}/CFA)})
exten => s,n,GotoIf($["${FORWARD}" != "1"]?followmecheck)
exten => s,n,Set(__CALLFWD=1)
exten => s,n,Set(FORWARD_NUM=${DB(${THISEXT}/CFAN)})
exten => s,n,GotoIf($["${FORWARD_NUM}" = ""]?followmecheck)
exten => s,n,GotoIf($["${FORWARD_NUM}" = "${DIALED_NUMBER}"]?s-BUSY-VOICEMAIL,1)
exten => s,n,GotoIf($["${FORWARD_NUM}" = "${CALLERID(num)}"]?followmecheck)
;; dial always forwarded number
exten => s,n,Dial(Local/${FORWARD_NUM}@from-inside${TL_DASH}${tenant},${TIMEOUT},${OPTIONS}${SCREEN_FORWARD_OPTIONS})

exten => s,n,Goto(s-forw-${DIALSTATUS},1)

Even when reading about the Dial() command for Asterisk I cannot figure out how I can put a parameter that choses the trunk.

Can anybody give me a little hint (or maybe I look at the wrong way of solve it) ;-)

Regards
Jesper


Submitted by eeman on Wed, 09/01/2010 Permalink

assuming that the rest of that macro works the way you want it to work when forwarding is not set..

try changing

exten => s,n,Dial(Local/${FORWARD_NUM}@from-inside${TL_DASH}${tenant},${TIMEOUT},${OPTIONS}${SCREEN_FORWARD_OPTIONS})

to

exten => s,n,GoTo(from-inside${TL_DASH}${tenant},${FORWARD_NUM},1)

you might have to play with some new variables to pass some data along, but Dial() is going to start a new call so any stored variables get blanked out anyway. Your just going to have to keep this GoTo from re-assigning some MYEXTEN when the macro gets called. This might involve creating some new check in your outbound script so that when CALLFWD=1 it doesn't re-assign that variable you are using to dig up which trunk to use.

Submitted by jesperkjeldsen on Fri, 09/03/2010 Permalink

Hi Erik
I changed it but it didn't made the call go out via the trunk specified in the extensions custom tag.

I have changed the script for outbound route to use the trunk specified in the extensions custom tag and uses it in the script as:
${DB(TL/${tenant}${TL_DASH}${MYEXTENSION}/tag)}

I have tried to make an IVR and set a number to dial out to number@SIP/trunkname and SIP/trunkname@number, but it would be to easy if I could do that ;-)

The best solution for me would be that the outbound script used for all calls was checking if the extension has a costum tag - and then uses that trunk for all outgoing calls. All out outgoing numbers are registered as different trunks.

Regards
Jesper

Submitted by jesperkjeldsen on Fri, 09/03/2010 Permalink

I have justed figured out that I in an IVR can set Asterisk to a PBX command like Dial(SIP/number@trunk) and the the calls out via the right trunk. It can solve the most for me now, but it would be nice to have the PBX always using the extensions costum tag as trunk ;-)

Regards
Jesper

Submitted by eeman on Fri, 09/03/2010 Permalink

im not going to write the whole thing for you free of charge.. I gave you exactly how to go about passing variables over to your custom trunk script, its up to you to make your variables, check for them, and avoid a second lookup of MYEXTENSION so that the correct DB value gets pulled. Thats very close to psuedo code. If the coding part is above your skill set you should just pay me to write it for you. I am sure you understand.

Submitted by jesperkjeldsen on Fri, 09/03/2010 Permalink

Hi Erik
I completly understand it and thats okay :-)
I like to keep my systems as much to the standards as possibly, and the things I change I have to understand ;-) So I will do some thinking about we want to do this or not.
Not that I have decided anything yet, but it could be great if it could be a part of Thirdlane - of course with us paying for the development now but then maintenenced as the rest of the Thirdland scripts. Because then it is the standard :-)

Regards
Jesper