Restrict outbound calls

Discussion in 'General' started by Nakkoush, Feb 15, 2009.

  1. Nakkoush

    Joined:
    Feb 14, 2009
    Messages:
    73
    Likes Received:
    0
    Dear Experts,

    What is the best way to restrict selective extentions from making outbound calls?
    As well what is the best way, or is there any module which I can install to help me dedicate selective outbound trunk to some specified extentions only?
    I use Elastix 1.3, the latest stable version available here as of today..

    Thanks in advance
     
  2. Chilling_Silence

    Joined:
    Sep 23, 2008
    Messages:
    488
    Likes Received:
    0
  3. Nakkoush

    Joined:
    Feb 14, 2009
    Messages:
    73
    Likes Received:
    0
    Which things the CustomContents application is known to break? I don't want to start using a module if it is known to give nightmares.. unless I misunderstand you..


    Is there any other way (or maybe module) to achieve my need being a semi-experienced admin? even if it is more sophisticated
    for my current level :)
     
  4. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Nakkoush:

    First answer, per se, the module does'nt break things, it is more the implementer that can break things.
    Second answer,Unfortunately not, but I believe you are in the right place her, please keep reading and exploring, welcome!
    (start with
    http://www.freepbx.org/support/document ... unk-access )

    Hey Chill:

    I cautioned you not to give it to newbies, now look what you did, for your penance please go and immediately write a "cheat-freepbx into thinking you are more experienced than you are" module ;)
     
  5. Nakkoush

    Joined:
    Feb 14, 2009
    Messages:
    73
    Likes Received:
    0
    dicko, no need to worry about what Chil wrote here.. I saw Custom Contexts at Elastix without tears even before posting here, but I hesitated to use it since it is still beta version and last release was maybe two years ago, then I thought of posting here maybe there is a module that I am missing concerning the extensions restriction
     
  6. wiseoldowl

    Joined:
    Aug 19, 2008
    Messages:
    251
    Likes Received:
    0
    "Best" depends on your point of view. There are no great ways to do it built into FreePBX, but there are ways. Chilling_Silence has mentioned one popular method; if you don't care for that approach (which in some ways is a pain in the neck to maintain due to the number of options and the fact that the priorities don't necessarily automatically compensate when you add new routes), then check out this page: How to give a particular extension different or restricted trunk access for outgoing calls

    Believe me, it's been requested often, there are several open tickets in the FreePBX bug tracker for some implementation of this feature (I should know, I've written at least two of them)!

    Part of the problem is that the original author of Custom Contexts shows up every now and then, says he's going to rewrite it or write a simplified version, but for whatever reason hasn't gotten around to it yet. I'm not going to make any negative comments because I really don't know what his situation is, but I just wish he'd follow through. I think part of the problem is that when he does come around, he spends too much time on the IRC channels which, to paraphrase Pat Townsend's comments about Usenet a decade or so ago, can sometimes be "a cesspool and a dungheap" of misinformation. I think perhaps he then gets discouraged and moves on to other pursuits, but that's just speculation on my part. But whatever the situation is, I wish he'd get around to writing the simplified "Custom Contexts" (which he called "Custom Contexts Lite" ).
     
  7. Nakkoush

    Joined:
    Feb 14, 2009
    Messages:
    73
    Likes Received:
    0
    @ wiseoldowl, something similar to Custom Contexts lite is what I am actually looking for.. I've just installed Custom Contexts and I understand now your point about the number of options which for me seems to be too complicated and more than needed for my purpose; I think for my case I only need to use the "Outbound Routes" section to simply create a Context to allow and another to Disallow extensions from using the Outbound Trunks..

    What I really wonder is that in this word of IT experts there is only one author (the one who wrote Custom Contexts) knowledgeable enough to write such application (module)?
    I think there is no much people requesting for it.
     
  8. wiseoldowl

    Joined:
    Aug 19, 2008
    Messages:
    251
    Likes Received:
    0
    Well, the answer to that is that when they came up with the module system, nobody felt the need to write any decent documentation so that ordinary users would have any inkling how to create a module. Those proficient enough to reverse-engineer existing modules have had some luck, and more recently the documentation has been improved (or so I've been told) but at this point in time there are still only a select few capable of writing modules without a whole lot of effort and head-scratching.

    One other problem is that you pretty much have to know PHP to write a module. FreePBX is definitely not language-agnostic software (referring to computer languages); if you don't know or don't care to use PHP you aren't going to get very far. It also helps if you understand how to interact with a MySQL database. Personally, I don't qualify on either count.
     
  9. Nakkoush

    Joined:
    Feb 14, 2009
    Messages:
    73
    Likes Received:
    0
    Then we have to be patiend and wait.. For the time being, I will use the available "Custom Contents" 0.3.4 and let you know in case it breaks anything.
     
  10. Chilling_Silence

    Joined:
    Sep 23, 2008
    Messages:
    488
    Likes Received:
    0
    Im in the same boat, I have basically no knowledge of PHP or MySQL, however I wonder how difficult it would be to look at the code, modify it so its called customcontextslite (A find / replace perhaps?) and then have the main page so it only shows you the options of which outbound route you want to give the user access to, allowing all the others or leaving them un-changed from defaults?

    Dont hold your breath for a positive outcome, but I might have a bit of a nosey at some point shortly ... :)
     
  11. Nakkoush

    Joined:
    Feb 14, 2009
    Messages:
    73
    Likes Received:
    0
    All the best!
     
  12. chrisuk1978

    Joined:
    Dec 3, 2007
    Messages:
    10
    Likes Received:
    0
    Gents,

    It strikes me that we seem to be going about this the hard way. Whats wrong with using the tools that [the elastix] god has provided for us?

    I do restricted outbound calling and a little bit of least cost routing from A2Billing, you'll find it under the Extra's tab on a tab named Calling Cards.

    With about 10 minutes customisation (I can produce the steps if you wish from my notes) you can achieve all this with A2Billing.

    I've turned off the 'enter your pin' dialog and associated each account with a number of extensions so that the experience to the user is seamless. From here I've added about a million pounds credit to my account (about 1.25 million euros) so that I never need worry about it running out. It all works rather well.

    The net result is an uber-powerful routing engine and a method of reporting on trunk usage, extension usage that is far more powerful than the native elastix interface (it wasn't really built to be a routing platform).

    If you're feeling particularly mean-spirited you could then started charging your family and friends for access to your outbound trunks. :)

    If you are interested, let me know and I should be able to guide you in the minor changes to a stock config to get this to play nicely. I am at a training conference next week, so should have some time in the evenings (without the welcome distraction of my wife :p) to help out.

    All best,
    Chris B.
     
  13. Nakkoush

    Joined:
    Feb 14, 2009
    Messages:
    73
    Likes Received:
    0
    Hi Chris,
    With a great pleasure I appreciate any help and documentation on how to customize A2billing to achieve my goal!

    Regards, N
     
  14. chrisuk1978

    Joined:
    Dec 3, 2007
    Messages:
    10
    Likes Received:
    0
    Nakkoush,

    I managed to develop this with the help of Eduardo and Stavros over at the A2Billing forum. It does involve modification of the A2Billing script and your extensions_config.conf primarily. Whilst I will do my best to support people in getting this modification working, I take no responsibility to any system munging that occurs as a result of attempting this instruction.

    Before you attempt this please back up all files that you intend to change.

    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 Dial String enter without the quotes "A2B/1"
    4: Save it and you will see a new route called 2B/1. 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/1
    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_custom.conf add the following:

    [macro-dialout-trunk-predial-hook]
    exten => s,1,GotoIf($["${OUT_${DIAL_TRUNK}:4:4}" = "A2B/"]?custom-freepbx-a2billing,${OUTNUM},1:2)
    exten => s,2,MacroExit

    [custom-freepbx-a2billing]
    exten => _X.,1,DeadAGI(a2billing.php|${OUT_${DIAL_TRUNK}:8})
    exten => _X.,n,Hangup()

    8: Save extensions_custom.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:

    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:

    ; 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: 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.
     
  15. Nakkoush

    Joined:
    Feb 14, 2009
    Messages:
    73
    Likes Received:
    0
    chris, thanks a million! much appreciated.
    I will try your method of restricting outbound calls as soon as I can as I am currently still having some issue with my initial configuration..
     

Share This Page