Retrieve voicemail from asterisk dialplan

Does anyone know of an easy way to retrieve an extensions voicemail email address from within the asterisk dialplan?

That would be the email stored in voicemail.conf.

xxx=, name,[email protected],,attach=no|saycid=no|envelope=no|delete=no

It doesn’t appear that FreePBX uses VM_INFO that way. The only occurrences of VM_INFO in the entire dialplan are in [app-dialvm] and [app-vmmain] which are for *98 and *97 dialing, respectively. In extensions_additional.conf:

[[email protected] ~]# asterisk -x "dialplan show" | grep VM_INFO
 [check]        8. Set(VMBOXEXISTSSTATUS=${IF(${VM_INFO(${AMPUSER}@${VMCONTEXT},exists)}?SUCCESS:FAILED)}) [extensions_additional.conf:7115]
                12. Set(VMBOXEXISTSSTATUS=${IF(${VM_INFO(${MAILBOX}@${VMCONTEXT},exists)}?SUCCESS:FAILED)}) [extensions_additional.conf:6446]

So that doesn’t necessarily reveal which email address is being used via the dialplan, unless I am reading it wrong. @shomi what’s your use case?

Where do you imagine FreePBX using VM_INFO to retrieve the email address for a voicemail box? Regular Voicemail to Email is handled by the Asterisk Voicemail App. For other stuff, FreePBX normally uses the userman email address.

I think I figured it out.

same => n,Macro(get-vmcontext,${AMPUSER})
same => n,Set(EMAIL=${VM_INFO(${EXTEN}@${VMCONTEXT},email)})
1 Like

Where is that diaplan?

Not sure what you mean. I am creating a custom dialplan in extension_custom.conf. The get-vmcontext macro is built into FreePBX.

exten => s,1,Set(VMCONTEXT=${DB(AMPUSER/${ARG1}/voicemail)})
exten => s,2,GotoIf($["foo${VMCONTEXT}" = "foo"]?200:300)
exten => s,200,Set(VMCONTEXT=default)
exten => s,300,NoOp()

And how does your custom dialplan actually get called? I dont see that.

It’s a custom external script in this case. Not really relevant.

It most certainly is. You just can’t throw dialplan into extensions_custom.conf and expect it to be used. Sure it will be loaded but nothing, so far, indicates how it will be used. If your goal is to get the email account(s) associated with a voicemail user via dialplan then asking “how does it get called?” is 100% relevant.

TBH, I am not sure what this is about. It seems to me that OP asked a simple question:

“How to obtain in the dialplan the email address which is configured in voicemail.conf?”

To which I think he has figured out already.

1 Like

Correct, they figured out how to get the email via dialplan with the dialplan they posted they put in extensions_custom.conf. I must be the only one that noticed the lack of a context, a lack of a proper extension to match, a lack of proper priorities and actual dialplan to execute after getting the email. The dialplan, alone, won’t work because it has issues. Fixing those issues will still mean it won’t work because there’s nothing here that shows how it would be called by the call logic within FreePBX.

I mean the Set() command and calling on the VM_INFO variables are correct as is the Macro call. Everything else needs to be corrected which would include how it would actually be used.

Question was asked and answered. There is no requirement that those seeking help here share with the rest of the class, but highly encouraged.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.