Extension based Outbound calling

Hi,

I was not able to get this logic working. Below is my requirement.

I have 2 PRI Links on my asterisk box.

PRI#1 for US Incoming & Outgoing
PRI#2 for UK Incoming & Outgoing

I have 2 asterisk servers one at US and other at India connected over IAX2 trunking. (Private Leased lines - WAN).

All extensions are getting registered at India Asterisk server. How do i make sure UK Extensions outgoing calls go thru UK PRI? is there any extensions (did) number based outgoing logic that can be prepared?

thanks.
LDP.

  1. Set up either an script that checks a database to see what trunk to use.
  2. Set up the extensions based on where they should call out of. So you can set up that any extension starting with 1 to go out through the UK, any extension starting with 2 go through the PRI in the US etc.
  3. Set up the phones in separate contexts so you can set via the context what trunk they should use for outgoing.

Hi Dovid,

thanks for your reply. how do i do the option#2.

my extensions start with 77xx series. Please help.

thanks
ldp

This is a perfect case for the custom-contexts module for FreePBX. You can google for the current release. It allows you to create specific routes in a context and apply that context on a per extension basis.

I have one server with phones in 3 locations. I use custom-contexts to choose the outbound route for each extension to make sure that they use local facilities first for local calls, route 911 calls correctly, etc.

Here’s some info on it: aussievoip.com/wiki/freePBX-CustomContexts

If you’re not using FreePBX as the GUI to your Asterisk, my condolences.

Good luck!

Second copy of double-post deleted.

[quote=“kenn10”]

If you’re not using FreePBX as the GUI to your Asterisk, my condolences.

Good luck![/quote]

I say the opposite. While FreePBX is good to use it gets things very complicated and real hard to debug. I would stay away from it. You can use a gotoif based on the first digit using ${CALLERID(num):0:1}.

Hi

The easiest way is to define in the extensions sip.conf a variable for example
"location" so for the UK sets this variable is set to UK and india IN then use this variable to decide which route to route out over.

I do this for multi tenant sites and it works well.

Ian

Hi ianplain & Dovid,

thanks for your reply

ianplain: can you please share the logic that i need to use to check the location parameter & use zaptel?

Dovid: i need more help in writing the IF logic. can you please help me…

thanks
ldp

The logic below goes as follows. If the first digit of the callers CID is a 1 then send the call out to UK else send to India. (Writing this from memory and didn’t write it in a while - forgive me if I am wrong).

Exten => _X.,1,GotoIf($["${CALLERID(num):0:1}" = "1"]?2:4)
Exten => _X.,2,Dial(SIP/${EXTEN}@UK)
Exten => _X.,4,Dial(SIP/${EXTEN}@India)

Hi Dovid,

Thanks for your response. I will try this logic & update you.

Does my below dialplan work for Outgoing calls? Please suggest
;
;International DialPlan
;
;UK Outgoing Only for Extensions starting with 77XX Only
;
Exten => _01144.,1,GotoIf($["${CALLERID(num):0:2}" = “77”]?2:3)
exten => _01144.,2,Dial(ZAP/g4/${EXTEN},r)
exten => _01144.,3,Hangup()
;
;All Other ISD Calls use ZAP 2
;
exten => _011.,1,Dial(ZAP/g2/${EXTEN},r)
exten => _011.,2,Hangup()

Thanks again for your time.

ldp.

Your dial plan logic is incorrect. In the first part you have it set that if their caller ID starts with 77 to send the call out throughtg4 and if not to go to prioroty 3 which just hangs up the call. The second part just says anything with 011 should go out through g2 (except when its 01144 because asterisk always uses the more “specific string”. Again what are you trying to accomplish set all users whose extension starts with 77 to go out through g4 and all others to go out via g2 or you want to split it up based on where they are calling ?

Hi Dovid,

I want all international calls (UK in specific example) from extensons 77XX should use ZAP/g4.

all other extensions uses ZAP/g2.

please suggest.

thanks
ldp.

Hi Dovid,

I changed the logic to below. Is this correct?

;International DialPlan
;
;UK Outgoing Only for Extensions starting with 77XX Only
;
Exten => _01144.,1,GotoIf($["${CALLERID(num):0:2}" = “77”]?2:4)
exten => _01144.,2,Dial(ZAP/g4/${EXTEN},r)
exten => _01144.,3,Hangup()
exten => _01144.,4,Dial(ZAP/g2/${EXTEN},r)
exten => _01144.,5,Hangup()

Please let me know.
thanks
ldp