Uploaded image for project: 'FreePBX'
  1. FreePBX
  2. FREEPBX-3412

Adding support for the Directory to call a different extension than the mailbox



    • Type: New Feature
    • Status: Closed
    • Resolution: Duplicate
    • Affects Version/s: 2.5
    • Fix Version/s: None
    • Component/s: FreePBX Framework
    • Labels:


      Hey guys,

      So I've been asked to add the support to our directory as such that if someone looks up our CEO's name for example in the directory, he's listed, but the calls actually route to his assistant. This isnt a feature in asterisk or freepbx as of today, so I hacked in support for it (please feel free to redo the code, i put this together in about 30 minutes)

      Here's how it works. If a user has "directoryext=" set as an option in their entry in voicemail.conf, the directory will send the calls to whatever "directoryext" is set to, rather than the voicemail box number (user's normal extension).

      Things to note:

      • I've made it so that when it calls the extension specified in directoryext, it originates the call in the 'from-internal' context, so that you may use an external number in this field.
      • It sets the caller ID information to "For John Smith <5551212>"
        - where John Smith is the persons name in the directory that this call was originally intended for, and 5551212 is the actual callerid of the person calling in. I did this so that when the person receiving the calls answers the phone, they can tell at a glance that this call was "forwarded" from the directory.

      Here's the patch I made to /var/lib/asterisk/agi-bin/directory

      @@ -83,6 +83,8 @@

      function parse_voicemailconf($filename, &$vmconf, &$section) {
      + global $directoryext;
      if (is_null($vmconf)) { $vmconf = array(); }
      @@ -107,8 +109,12 @@
      foreach (explode("|",$matches[6]) as $opt) {
      $temp = explode("=",$opt);
      if (isset($temp[1])) {
      - list($key,$value) = $temp;
      - $vmconf[$section][ $matches[1] ]["options"][$key] = $value;
      + if (strtolower($temp[0])=='directoryext') { + $directoryext = $temp[1]; + } else { + list($key,$value) = $temp; + $vmconf[$section][ $matches[1] ]["options"][$key] = $value; + }
      } else if (preg_match("/^\s*(\d+)\s*=>\s*dup,(.)\s([;#].*)?/",$line,$matches)) {
      @@ -283,6 +289,7 @@
      function do_directory($type, &$directory, $dial_context, $say_exten, $operator) { global $agi; global $voicemail_dir; + global $directoryext; $escape_digits = "1*"; if ($operator) $escape_digits .= "0"; @@ -343,6 +350,16 @@ $agi->say_digits($match["ext"]); }
      + if (isset($directoryext)) { + $match["ext"] = "$directoryext"; + $dial_context = "from-internal"; + $cidnum = $agi->request['agi_callerid']; + + $agi->set_callerid("\"For ".$match["name"]." <".$cidnum.">\""); + + $agi->verbose("Directory Extension is overridden! Dialing ".$match["ext"]); + $agi->verbose("For ".$match["name"]." <".$cidnum.">"); + }
      $agi->conlog("Dial ".$match["ext"]);


        Gliffy Diagrams




              • Assignee:
                voxter voxter
              • Votes:
                0 Vote for this issue
                0 Start watching this issue


                • Created:


                  Error rendering 'slack.nextup.jira:nextup-jira-plus-status'. Please contact your Jira administrators.