*RESOLVED* Unified Voicemail and Company Directory: Almost There!!!
I've been working on making a unified voicemail and company directory for our two offices. There's some manual entries that must be made, but here's what I have so far (I'll tell you what I lack and need help with at the end!):
1. Trixbox 2.2.4 running at each location.
2. IAX2 trunks named Inter-Office
3. 1XX extensions in Houston, 2XX extensions in Dallas
4. Modified extensions_custom.conf to add this (for Houston, 1XX for Dallas):
[ext-local-custom]
exten => _2XX,1,dial(iax2/Inter-Office/${EXTEN})
5. Modified voicemail.conf in each office so the entries are the same (this gets the directory working)
So here's what works:
1. A person can call into either office and access a unified company directory.
2. Selecting a foreign user in the directory routes the call to the other PBX properly.
3. All users can dial *97 to access their direct voicemail box.
Here's what doesn't work (and I need help with)
Dialing *98 and putting in a foreign voicemail box (i.e. *98 212 from Houston) takes me to the mailbox entry for 212 on the Houston server instead of accessing the remote box.
I think I know what I need to do, but am having a hard time implementing it. In extensions_additional.conf under [app-dialvm] there is the entry include => app-dialvm-custom. I know that I can create that context in the extensions_custom.conf and override the settings here. I know that I need to play the "Asterisk Mail" sound and "Mailbox?" sound, and then route the call based on the input to either Houston or Dallas, but I don't know how to use a trunk to access VoiceMailMain() on a remote box.
I know this is a small thing, but it would really put the finishing touches on the unified directory if my *98 worked for getting their voicemail regardless of what office they are currently in.
-Chris

Got It!!!
Okay, here's the final piece, I've managed to get it all working. Thanks for all your help, I couldn't have done it without you all.
1. Change the feature code of "dial voicemail" to something that you don't use, we can't use it here because the -custom include file only gets evaluated AFTER the original app (screws our pattern matching)
2. Make sure you have the dial rules set up properly (i.e. route *982XX to the Dallas IAX2 trunk).
3. Add this to extensions_custom.conf
[app-dialvm-custom]
exten => *98,1,Answer
exten => *98,2,Wait(1)
exten => *98,3,Read(ex|vm-login|||2|2)
exten => *98,4,GotoIf($[$["${ex:0:1}" = "1"]]?vm-houston,1:5)
exten => *98,5,GotoIf($[$["${ex:0:1}" = "2"]]?vm-dallas,1:hang,1)
exten => _*98.,1,Set(ex=${EXTEN:3})
exten => _*98.,2,GotoIf($[$["${ex:0:1}" = "1"]]?vm-houston,1:3)
exten => _*98.,3,GotoIf($[$["${ex:0:1}" = "2"]]?vm-dallas,1:hang,1)
exten => vm-houston,1,Macro(get-vmcontext,${ex})
exten => vm-houston,2,VoiceMailMain(${ex}@${VMCONTEXT})
exten => vm-houston,3,Goto(hang,1)
exten => vm-dallas,1,Dial(IAX2/Inter-Office/*98${ex})
exten => vm-dallas,2,Goto(hang,1)
exten => hang,1,Macro(hangupcall,)
; end of [app-dialvm-custom]
Obviously, make sure you make your contexts meaningful to you. One note is that "Inter-Office" is the name of my IAX2 trunk, make sure you replace it with whatever you have.
I think I've posted everything necessary now for a fully unified VoiceMail and Company Directory application. Let me know if you need any more details.
-Chris