TIPS MWI with externnotify and User Panel

Phillip

New Member
Joined
May 23, 2013
Messages
11
Reaction score
0
I have a dedicated remote Asterisk voicemail server setup and working. The MWI works perfectly with the externnotify.... with one little catch. If a user logs in through the user panel (http://voicemailserver/recordings) and moves or deletes their voicemail from there, nothing triggers the MWI. Is there any way to have the User Panel call the externnotify so voicemails managed through it will successfully clear MWI?
 

Phillip

New Member
Joined
May 23, 2013
Messages
11
Reaction score
0
That thought occurred to me, but my knowledge level is not high enough to pass the extension variables. The script I use grabs the extension variables from asterisk (my understanding is asterisk sends it in the externnotify event). I would be ok with doing a chron job, I would just need some help with the scripting for it.
 

randy7376

Guru
Joined
Sep 29, 2010
Messages
807
Reaction score
91
Location
Fort Worth, Texas
Maybe I'm missing something here, but this sounds a lot like the old problem with MWI and not having pollmailboxes= defined.

In /etc/asterisk/voicemail.conf, is pollmailboxes= and pollfreq= uncommented? If not, try setting that up and see if it resolves your problem with MWI. You should probably edit through the FreePBX GUI. FYI, If you don't see those values as an option from within FreePBX, you may have to uncomment them in the file manually.
 

Phillip

New Member
Joined
May 23, 2013
Messages
11
Reaction score
0
I'm using the pollmailboxes, but keep in mind, my voicemail is on a separate box from the phones. The MWI works because I have externnotify set on my voicemail server which creates the file needed on my registration server, which polls it's mailbox folders for the txt files. That is all working. If you leave a message or check your voicemail with the phone (i.e. call *97 from the phone) the MWI goes on and off accordingly. My problem is only when the voicemail is managed from the User Panel.
 

Phillip

New Member
Joined
May 23, 2013
Messages
11
Reaction score
0
Okay, got it doing what I needed. It now runs the externnotify script when the voicemail portal page is loaded (which happens after every delete or move of a message).

For anyone that might find it useful, here's what I did:

I edited /var/www/html/recordings/modules/voicemail.module

I chose the code that pertains to deleting messages and reloading the page as this is what I was most concerned about (but it also works when moving to another folder)

The code I added:

PHP:
if ($folder=="INBOX") {
                shell_exec("/usr/local/bin/notify_vmail_extern.sh  $context $extension $record_count");

Example of where I put it:


PHP:
  * Deletes selected voicemails and updates page
  *
  * @param $args
  *  Common arguments
  */
  function navSubMenu($args) {
 
    global $ASTERISK_VOICEMAIL_PATH;
    global $ASTERISK_VOICEMAIL_FOLDERS;
 
    // args
    $m = getArgument($args,'m');
    $q = getArgument($args,'q');
    $current_folder = getArgument($args,'folder');
 
    $context = $_SESSION['ari_user']['context'];
    $extension = $_SESSION['ari_user']['extension'];
 
    // check for voicemail enabled or admin
    if ($_SESSION['ari_user']['voicemail_enabled']!=1 ||
          $extension=='admin') {
      return;
    }
 
    // make folder list
    $paths = preg_split('/;/',$ASTERISK_VOICEMAIL_PATH);
    $i = 0;
    while ($ASTERISK_VOICEMAIL_FOLDERS[$i]) {
 
      $f = $ASTERISK_VOICEMAIL_FOLDERS[$i]['folder'];
      $fn = $ASTERISK_VOICEMAIL_FOLDERS[$i]['name'];
 
      foreach($paths as $key => $path) {
 
        $path = appendPath($path,$context);
        $path = appendPath($path,$extension);
 
        if (is_dir($path) && is_readable($path)) {
          $dh = opendir($path);
          while (false!== ($folder = readdir($dh))) {
 
            $folder_path = AppendPath($path,$folder);
 
            if($folder!="." && $folder!=".." &&
                filetype($folder_path)=='dir') {
 
              if ($f==$folder) {
 
                // get message count
                $indexes = $this->getVoicemailIndex($folder_path,$q,$order,$sort);
                $record_count = 0;
                $record_count += $this->getVoicemailCount($indexes);
 
                // set current folder color
                $class='';
                if ($current_folder==$folder ||
                    ($current_folder=='' && $ASTERISK_VOICEMAIL_FOLDERS[0]['folder']==$folder)) {
                  $class = "class='current'";
                }
 
                // add folder to list
                $ret .= "<p><small><small>
                          <a " . $class . " href='" . $_SESSION['ARI_ROOT'] . "?m=Voicemail&q=" . urlencode($q) . "&folder=" . $f. "'>
                          " . $fn . " (" . $record_count . ")" . "
                          </a>
                        </small></small></p>";
            if ($folder=="INBOX") {
                shell_exec("/usr/local/bin/notify_vmail_extern.sh  $context $extension $record_count");
            } 
              }
            }
          }
        }
      }
      $i++;
    }
 
    return $ret;
the if ($folder=="INBOX") statement was because I only cared about the inbox messages for the MWI.

Also make sure to edit the "/usr/local/bin/notify_vmail_extern.sh" to your actual path and file of your externnotify script.
 

Members online

PIAF 5 - Powered by 3CX

Forum statistics

Threads
22,441
Messages
137,941
Members
14,611
Latest member
rampageai