Using voicemail application variables

I have a problem that I cannot seem to find any information on. I desire to turn on and off the voice mail icon on our handsets based on voice mails. I can do this with the compiled c program called smsicon. My problem is this. How can I turn on and off the voice mail icon using my compiled program within the asterisk dialplan?

The key variable to me is the Voicemail application variable VM_MSGNUM to get the desired results? If VM_MSGNUM = 0 I will turn off the icon. If it is > 0 I will turn it on!

voip-info.org/wiki/view/Aste … iable+List
The VoiceMail() application uses the following variables:
${VM_CATEGORY} Sets voicemail category
${VM_NAME} * Full name in voicemail
${VM_DUR} * Voicemail duration
${VM_MSGNUM} * Number of voicemail message in mailbox
${VM_CALLERID} * Voicemail Caller ID (Person leaving vm)
${VM_CIDNAME} * Voicemail Caller ID Name
${VM_CIDNUM} * Voicemail Caller ID Number
${VM_DATE} * Voicemail Date
${VM_MESSAGEFILE} * Path to message left by caller

I dont know they syntax on how to read the value of VM_MSGNUM using NoOp for instance and for that matter using the Voicemail application. How would I do this?

My second problem is when a user terminates the voicemail application and the VMSTATUS (which is available to me in the dial plan) result is USEREXIT and NOT SUCCESS, my dial plan exits without the icon being turned on. How can I ensure that if there was a voice mail left, that the icon gets turned on based on the VMSTATUS or is there a better way? See my dialplan below:

exten => 1222,1,VoiceMail(${CALLERID(rdnis)}@default,b)
exten => 1222,n,NoOp(${VMSTATUS})
exten => 1222,n,GotoIf($[${VMSTATUS}=SUCCESS]?success:other
exten => 1222,n(success),AGI(smsicon,-m${CALLERID(rdnis)})
exten => 1222,n,Hangup

I have tried to use the AGI and the AGIDead applications but I cannot seem to get this to work if the caller exits via USEREXIT. My dial plan terminates before it gets to this line.

exten => 1222,n(other),DeadAGI(smsicon,-m${CALLERID(rdnis)}

Below is perhaps some good information on what to do but I don’t know how to create an AGI script to call exec. Some help here would be helpful too.

voip-info.org/wiki/view/Aste … email.conf
When executing Voicemail from an AGI script (using “exec Voicemail”), the control is then reverted back to the AGI script where you can check these using the “get variable” AGI command. The variables for the current context, extension and priority are ${CONTEXT}, ${EXTEN} and ${PRIORITY} respectively, so you can use, for example “get variable EXTEN” to retrieve the extension.

I discovered two very important items to solve my problem.

The first thing I discovered was to use the function VMCOUNT that was available to my dialplan to determine if a user had a voice mail or not.

The second item that I was unaware of was the special extension “h”. If a user terminated the Voicemail application, the dial plan would then move to the “h” extension in the current context. Then it would run the following line to determine if a voice mail message exists in the mail box.

exten => h,n,Set(msgs=${VMCOUNT(${CALLERID(rdnis)})})

I could then do some logic such as the next line whether or not to turn on the MWI on our handsets.

exten => h,n(turnoff),DeadAGI(smsicon,-m${CALLERID(rdnis)})

I hope this helps somebody else in the future.

1 Like