Outbound route by extension?

etang

Joined
Apr 21, 2008
Messages
15
Likes
0
Points
0
#1
Is there a way to setup outbound route by extensions?
Say I have 2 companies sharing the same box. Each has their own SIP accounts. So company A has extension 5000-5010 using SIP trunk #1 to dial out on. Company B has extension 6000-6010 using SIP trunk #2 to dial out on?

Thanks

Edwin Tang
 

dingoland

Joined
Jan 16, 2008
Messages
220
Likes
0
Points
0
#2
Hi,

By extensions, i don't know, but by prefix in the outbound rules yes.
You have to setup 2 outbound routes with differents prefix in the outbound dial paterns.
For users A, tell them to use 5 for example to go out and for users B, tell them to use 6 to go out.

Maybe, you can filter by context but i cannot tell you more, i m not a freepbx expert.
Wait for a freepbx expert ;)

Regards
 

zeus

Joined
Oct 25, 2007
Messages
60
Likes
0
Points
0
#3
You can do that with different prefix in the outbound dial paterns, as dingoland describe above. Now if you want ext 1 not to dial from outbound route from ext 2 you must control the context of the extension. This can be done with custom contexts module from freepbx http://freepbx.org/trac/browser/contributed_modules/release/customcontexts-0.3.4.tgz

This module is officially untested but i use it for a long time now without any problems.

I think this can work for you.

Regards ;)
 

chrisuk1978

Joined
Dec 3, 2007
Messages
10
Likes
0
Points
0
#4
Edwin,

The most flexible way to achieve this is to use the A2Billing module already installed with the Elastix distro.

Using A2Billing, you can set up the trunks in A2Billing and then use ratecards to differentiate between company A and company B (or for more granularity, individual users).

See my post from the FreePBX forums to describe the setup of this:

Here is the step by step procedure:

1: Go to FreePBX, Setup, Trunks, Create Custom Trunk.
2: Create whatever dial rules you need to translate the dialed number before passing it to a2billing.
3: In the Custom Trunk String enter without the quotes "A2B/$OUTNUM$"
4: Save it and you will see a new route called 2B/$OUTNUM$. It is fine, is just a glitch with FreePBX.
5: Go to Outbound Routes, Create or Modify your Long Distance route and point it to AMP:A2B/$OUTNUM$
6: Important: be sure to check the Intra Company Route option. This ensures that you preserve the original extension ID when dialing out.
7: Now Edit extensions_additional.conf and look for macro-dialout-trunk and find the line that contains:

Code:
exten => s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})

Replace that line with the code below (which will preserve the original line so you know what you changed)

; Modified to support outbound calling for A2B while keeping trunk Dial Rules working
; original line: exten => s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})
; added function:
exten => s,n(skipoutnum),GotoIf($["${pre_num}" = "AMP:A2B/"]?a2bdial:«»skipoutnumnormal) ; Checks for A2B custom trunk and dials it.
exten => s,n(a2bdial),DeadAGI(a2billing.php|1|${OUTNUM}) ; Dials out via the a2billing.php script. Note the ${OUTNUM} parameter.  The number between a2billing.php and ${OUTNUM} must indicate a valid agi context in a2billing.conf!  If using default configs this should always be 1.
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(skipoutnumnormal),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})
; end of modified additions
8: Save extensions_additional.conf
9: Go to your Asterisk CLI and issue a reload request. Now we are done with FreePBX.
10: Go to /var/lib/asterisk/agi-bin and edit a2billing.php
11: There are two modifications to introduce here. First look for the lines that contains the following code:

Code:
if ($argc > 1 && is_numeric($argv[1]) && $argv[1] >= 0){
   $idconfig = $argv[1];
}else{
   $idconfig = 1;
}

Then add the following three lines right below that:

if ($argc > 2 && is_numeric($argv[2]) && $argv[2] >= 0){   //NEW NEW NEW
   $the_num = $argv[2];         //NEW NEW NEW
}                              //NEW NEW NEW

Now locate the line that contains the following code:

$A2B->dnid = $agi->request['agi_dnid'];

and replace it with the following code:

// Original line replaced was: $A2B->dnid = $agi->request['agi_dnid'];
// Here we test if the call comes from the macro-dialout-trunk context in freePBX
// and set the dnid to be the parameter passed to a2billing
if($agi->request['agi_context'] == "macro-dialout-trunk"«»)   //NEW NEW NEW
   $A2B->dnid = $the_num;            //NEW NEW NEW
else                        //NEW NEW NEW
$A2B->dnid = $agi->request['agi_dnid'];   //NEW NEW NEW
// End of modifications            //NEW NEW NEW
12: Save a2billing.php
13: Go to /etc/asterisk and edit a2billing.config. Look for the line:

Code:
; Find
use_dnid = NO
; and change to
use_dnid = YES

; Find
number_try = 3
; and change to
number_try = 1

; Find
cid_enable = NO
; and change to
cid_enable = YES

;At your preference, you may also wish to change the following

; Find
say_balance_after_auth = YES
; and change to
say_balance_after_auth = NO

; Find
say_timetocall = YES
; and change to
say_timetocall = NO
14: Restart asterisk by entering 'asterisk -r' and 'reload' at the command prompt.
15: That's it!

Now you should be able to manage your extensions from freePBX and whenever the A2B route is seized, the calls pass over the control of a2billing rating engine, reporting, and so on.
The only downside of this procedure is that extensions_additional.conf is rewritten by FreePBX each time you save and apply extension changes from the Elastix interface. So far, I have been remodifying extensions_additional.conf each time I need to do this (step 7 followed by step 14 only). For a relatively stable production system, this should not create a significant headache.

It is worthwhile setting accurate billing costs up for each trunk, which may involve many time related entries. This is a little tedious but yields rewards in that you can then accurately use this to account for each companies call costs, and should you wish to add additional trunks in the future you could use the system to do the least cost routing. You may decide to use this as your billing solution.

Once the trunks and ratecards are configured adding users is a cinch! The complete process should take you no more than a couple of hours to implement and test.

I use a similar configuration at home to do the least cost routing for the house.

Hope this is helpful.

Best regards,
Chris.<br><br>Post edited by: chrisuk1978, at: 2008/06/08 23:09
 

johnryan

Joined
Feb 3, 2008
Messages
15
Likes
0
Points
0
#5
In my phones I setup a Dial Plan that adds the number 3 to the beginning of every number. Then In my outbound routes I told it to look for anything starting with 3 and route them to specific trunk. Then went to the trunk and told it to remove the 3. This allows me to setup specific extensions to use specific outbound routes.
If anyone needs specific instructions just ask and I'll post them...
 

JohnC

Joined
Jun 23, 2018
Messages
1
Likes
0
Points
1
#6
@johnryan,
Could you post the specific instructions? Most grateful..
 

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,902
Messages
130,887
Members
17,565
Latest member
omarmenichetti
Top