Company Directory problem

I am having an issue with Directory not pulling the greet file and playing it, so it defaults to saying the letters of the name.

I am new to FreePBX, but managed to get everything else I wanted in the PBX to work with the help of this forum, but I cannot find the answer to this one.

I built the box with freepbx-2.3.1 and upgraded this morning to freepbx-2.4.0rc1 this morning hoping it would fix the issue, even though nothing about Directory was in the Changes document.

Directory correctly finds the user from voicemail.conf and will connect to the proper extension, but it spells the name instead of using the greet file. The mailbox is in default context and in my vm extension folders are my greet and unavailable files in gsm wav and WAV formats.

Here is the AGI debug from the CLI:

– Executing [[email protected]:3] AGI(“IAX2/Server2”, “directory|default|from-did-direct|be”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/directory
AGI Tx >> agi_request: directory
AGI Tx >> agi_channel: IAX2/Server2
AGI Tx >> agi_language: en
AGI Tx >> agi_type: IAX2
AGI Tx >> agi_uniqueid: 1202230883.3
AGI Tx >> agi_callerid: XXXXXX5815
AGI Tx >> agi_calleridname: XXXXXX5815
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: unknown
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: app-directory
AGI Tx >> agi_extension: 411
AGI Tx >> agi_priority: 3
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
AGI Rx << GET VARIABLE ASTETCDIR
AGI Tx >> 200 result=1 (/etc/asterisk)
AGI Rx << GET VARIABLE ASTSPOOLDIR
AGI Tx >> 200 result=1 (/var/spool/asterisk)
AGI Rx << GET VARIABLE ASTLOGDIR
AGI Tx >> 200 result=1 (/var/log/asterisk)
AGI Rx << GET DATA dir-intro-fnln 4000 3
– <IAX2/Server2User-1> Playing ‘dir-intro-fnln’ (language ‘en’)
AGI Tx >> 200 result=374
AGI Rx << VERBOSE “-- Playing ‘letters/e’ (language ‘en’)” 1
directory|default|from-did-direct|be: – Playing ‘letters/e’ (language ‘en’)
AGI Tx >> 200 result=1
AGI Rx << STREAM FILE letters/e "1
" 0
– Playing ‘letters/e’ (escape_digits=1
) (sample_offset 0)
AGI Tx >> 200 result=0 endpos=4800
AGI Rx << VERBOSE “-- Playing ‘letters/r’ (language ‘en’)” 1
directory|default|from-did-direct|be: – Playing ‘letters/r’ (language ‘en’)
AGI Tx >> 200 result=1
AGI Rx << STREAM FILE letters/r “1*” 0
– Playing ‘letters/r’ (escape_digits=1*) (sample_offset 0)
AGI Tx >> 200 result=0 endpos=4480
AGI Rx << VERBOSE “-- Playing ‘letters/i’ (language ‘en’)” 1
directory|default|from-did-direct|be: – Playing ‘letters/i’ (language ‘en’)
AGI Tx >> 200 result=1

Any help with this would be greatly appreciated.

Thanks

check ownership of the files , it should be asterisk:asterisk. If not the system can’t gain access to them to play them.

this is what I see on mine with verbose set to 3 and agi debug enabled

== CDR updated on SIP/112-084a3d48
– Executing Goto(“SIP/112-084a3d48”, “app-directory|#|1”) in new stack
– Goto (app-directory,#,1)
– Executing Answer(“SIP/112-084a3d48”, “”) in new stack
– Executing Wait(“SIP/112-084a3d48”, “1”) in new stack
– Executing AGI(“SIP/112-084a3d48”, “directory|general|from-did-direct|be”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/directory
AGI Tx >> agi_request: directory
AGI Tx >> agi_channel: SIP/112-084a3d48
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1202236857.919
AGI Tx >> agi_callerid: 112
AGI Tx >> agi_calleridname: device
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 7777
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: app-directory
AGI Tx >> agi_extension: #
AGI Tx >> agi_priority: 3
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
AGI Rx << GET VARIABLE ASTSERVERLIST
AGI Tx >> 200 result=0
AGI Rx << GET VARIABLE ASTETCDIR
AGI Tx >> 200 result=1 (/etc/asterisk)
AGI Rx << GET VARIABLE ASTSPOOLDIR
AGI Tx >> 200 result=1 (/var/spool/asterisk)
AGI Rx << GET VARIABLE ASTLOGDIR
AGI Tx >> 200 result=1 (/var/log/asterisk)
AGI Rx << VERBOSE “parsing /etc/asterisk/voicemail.conf” 1
directory|general|from-did-direct|be: parsing /etc/asterisk/voicemail.conf
AGI Tx >> 200 result=1
AGI Rx << GET DATA dir-intro-fnln 4000 3
– Playing ‘dir-intro-fnln’ (language ‘en’)
AGI Tx >> 200 result=373
AGI Rx << VERBOSE “========entered 373” 1
directory|general|from-did-direct|be: ========entered 373
AGI Tx >> 200 result=1
AGI Rx << VERBOSE “Found /var/spool/asterisk/voicemail/default/140/greet.wav” 2
== directory|general|from-did-direct|be: Found /var/spool/asterisk/voicemail/default/140/greet.wav
AGI Tx >> 200 result=1
AGI Rx << STREAM FILE /var/spool/asterisk/voicemail/default/140/greet “1*” 0
AGI Tx >> 200 result=0 endpos=10080
AGI Rx << VERBOSE “-- Playing ‘dir-instr’ (language ‘en’)” 1
directory|general|from-did-direct|be: – Playing ‘dir-instr’ (language ‘en’)
AGI Tx >> 200 result=1
AGI Rx << STREAM FILE dir-instr “1*” 0
AGI Tx >> 200 result=-1 endpos=15360
== Spawn extension (app-directory, #, 3) exited non-zero on ‘SIP/112-084a3d48’

Thank you for your quick response. That was my first thought as well when it didn’t work.

-rwxr-xr-x 1 asterisk asterisk 2673 Feb 5 11:59 greet.gsm
-rwxr-xr-x 1 asterisk asterisk 25964 Feb 5 11:59 greet.wav
-rwxr-xr-x 1 asterisk asterisk 2660 Feb 5 11:59 greet.WAV
drwxr-xr-x 2 asterisk asterisk 4096 Feb 5 11:58 INBOX
drwxr-xr-x 2 asterisk asterisk 4096 Feb 5 11:58 Old
-rwxr-xr-x 1 asterisk asterisk 3267 Feb 5 11:59 unavail.gsm
-rwxr-xr-x 1 asterisk asterisk 31724 Feb 5 11:59 unavail.wav
-rwxr-xr-x 1 asterisk asterisk 3246 Feb 5 11:59 unavail.WAV

One thing I did notice though, is that on your output there is:

AGI Tx >> 200 result=1 (/var/log/asterisk)
AGI Rx << VERBOSE “parsing /etc/asterisk/voicemail.conf” 1
directory|general|from-did-direct|be: parsing /etc/asterisk/voicemail.conf
AGI Tx >> 200 result=1

This seems to be missing on mine. So is the path incomplete on the FreePBX generated AGI file? The rights appear to be correct on my voicemail.conf file:
-rw-rw-r-- 1 asterisk asterisk 12265 Feb 5 12:00 voicemail.conf

Thanks

I spoke too soon, I did not have the verbosity of the debug set high enough. Still it is choosing the correct context, default. And if it didn’t use the correct context, it would’t find the correct user.

AGI Tx >> 200 result=1 (/var/log/asterisk)
AGI Rx << VERBOSE “Notice: vm-context not specified. Using ‘default’” 1
directory||from-did-direct|be: Notice: vm-context not specified. Using 'default’
AGI Tx >> 200 result=1

I have to watch what I post as I’ve customized mine to handle multiple asterisk servers so that we present a unified directory service from all branch servers. I could not remember if that line was supposed to be there or not (I removed it’s checking of the other servers from the output I provided).

If you edit edit the directory file (/var/lib/asterisk/agi-bin/directory) at line 32 there is a line:
define(“DEBUG”, 0);
change the 0 to a 1 and save the file. It will produce a debug file that might help you out. it will be located at /var/log/asterisk/directory.log (review this file carefully to be sure everything looks correct). Also since it is a AGI file it get’s reloaded each time the service is called so you can enable it, call a few times, edit it again to remove it and not effect any of the calls or other operations of the system.

You’ll want to take a look at the sound_file_exists function and see what it see’s. There is a example in side the function on how it is outputing information to the display that should help you get the info.

Can you provide some background info.

Asterisk version, Freepbx version, Hand built or distro install and if so who’s, etc…

I enabled debug in the AGI file and set AGI debugging in the CLI, but am unable to find the reason it is failing.
If you have time, I am including links to my directory file and directory.log for you to review, the CLI output hasn’t changed from above.

As for the box:
Asterisk 1.4.14
Asterisk-addons 1.4.4
FreePBX 2.4.0rc1.1 (started off with 2.3.1) all modules are up to date
RHEL5 x86_64

http://69.3.17.29/directory.log
http://69.3.17.29/directory

Thank you

edit the directory script.

Find the sound_file_exists function. and place this line between the for loop and the if (…

$agi->verbose(file_exists($file.".".$ext))." Found “.$file.”.".$ext, 2);

So it will look like this when done:
foreach (array(“gsm”,“GSM”,“wav”,“WAV”) as $ext) {
$agi->verbose(file_exists($file.".".$ext))." Found “.$file.”.".$ext, 2);
if (file_exists($file.".".$ext)) {

This should print out each EXACT attempt to check for a sound file to be played. that way you will know what and where it is looking for something and what it thinks the result state is.

Thank you for the posting!
It greatly helped since I don’t know programming at all.
I now have it showing up in the CLI and it no longer spells out the name, but isn’t streaming the file either:

AGI Tx >>
DMGVM01CLI> AGI Rx << GET VARIABLE ASTETCDIR
AGI Tx >> 200 result=1 (/etc/asterisk)
AGI Rx << GET VARIABLE ASTETCDIR
AGI Tx >> 200 result=1 (/etc/asterisk)
DMGVM01
CLI> AGI Rx << GET VARIABLE ASTSPOOLDIR
AGI Tx >> 200 result=1 (/var/spool/asterisk)
AGI Rx << GET VARIABLE ASTSPOOLDIR
AGI Tx >> 200 result=1 (/var/spool/asterisk)
DMGVM01CLI> AGI Rx << GET VARIABLE ASTLOGDIR
AGI Tx >> 200 result=1 (/var/log/asterisk)
AGI Rx << GET VARIABLE ASTLOGDIR
AGI Tx >> 200 result=1 (/var/log/asterisk)
DMGVM01
CLI> AGI Rx << GET DATA dir-intro-fnln 4000 3
AGI Rx << GET DATA dir-intro-fnln 4000 3
DMGVM01CLI> – <IAX2/Server2User-1> Playing ‘dir-intro-fnln’ (language ‘en’)
– <IAX2/Server2User-1> Playing ‘dir-intro-fnln’ (language ‘en’)
DMGVM01
CLI> AGI Tx >> 200 result=742
AGI Tx >> 200 result=742
DMGVM01CLI> AGI Rx << VERBOSE “” 1
directory|default|from-did-direct|be:
AGI Rx << VERBOSE “” 1
DMGVM01
CLI> AGI Tx >> 200 result=1
directory|default|from-did-direct|be:
AGI Tx >> 200 result=1
DMGVM01CLI> AGI Rx << STREAM FILE /var/spool/asterisk/voicemail/default/420/greet "1" 0
AGI Rx << STREAM FILE /var/spool/asterisk/voicemail/default/420/greet “1*” 0
DMGVM01*CLI> AGI Tx >> 200 result=0 endpos=0
AGI Tx >> 200 result=0 endpos=0

After fiddling with the code that you posted I got it to work as:

    foreach (array("gsm","GSM","wav","WAV") as $ext) {
    $agi->verbose(file_exists($file.".".$ext))." Found ".($file.".".$ext);
    if (file_exists($file.".".$ext));{
    return true;    }

If I have the line as: $agi->verbose(file_exists($file.".".$ext))." Found “.($file.”.".$ext, 2);
It goes to “goodbye” and hangs up.

Ok, I started writing this an hour ago and now it just hit me.
I am on extension 0420.
Directory agi is looking for the sound file in /420
It’s dropping the zero. I created another extension with a non zero starting number and everything works.
I can create all my extensions to be non-zero starting, but I was making extensions based on last four digits of the phone number

Question is though, why is it dropping off the zero?

Thank you again fskrozki for helping me through this.

Glad you figured it out. I’m sorry about that I did a quick copy and paste and don’t remember how the ,2 got in there.

The issue with leading 0’s is that if at any point the extension is converted to a real number instead of a string of characters you will loose the leading 0. Also most people would not type in extension 0420 with the leading 0 as it means the same thing as 420.

Thanks again for your help. I wouldn’t have figured it out without out getting the right debug information.

Not a problem you had me stumped. I didn’t think to question the leading 0 from your output above either.

So we both learned something on this deal.