Voicemail with time condition


We have disabled our voicemail for the switchboard during business hours. The voicemail is switched on during non-business hours with an unavailable message. To make it works we created a time condition with a time group.

I’d like to ask if it is possible with an automated way to disable the time condition when someone is recording the temporary message for the switchboard number. The idea is when a temporary message is on the voicemail should be activated regardless of business hours or non-business hours. As soon as the temporary message is deleted, the time condition should kick in again.

I thought to create another time condition that comes first. However, for destination match, there are no criteria for voicemail temporary messages.

Any thoughts, please?

Fun exercise for this morning. The Dynamic Routes module’s primary purpose is to branch call flow based on a dynamic condition. We just need to figure out what changes when there is a temp message set for a mailbox.

When you have a temp greeting enabled for a mailbox, the file temp.wav will exist in the voicemail file structure. You need to test for the existence of this file. The following Asterisk expression will return true if mailbox 6006 is set with a temporary message, otherwise it returns null:

${SHELL([[ -f /var/spool/asterisk/voicemail/default/6006/temp.wav ]] && echo -n 'true')}

If you use that as an Asterisk Variable condition in a dynroute, update it for the vm box in question, then you can set the default destination to where the normal operation, and a match condition set to true when it’s enabled.

See this post for a similar situation using a different asterisk expression: Using Dynamic Routes to branch call flow based on extension state


Thank you yes it is an interesting situation and I think you just provided me the solution by checking the existence of the temp.wav file.

I will test that


1 Like

@igaetz - Could you please check if the setting and expression are correct? The temp.wav is present, however, it didn’t work sorry for the delay.

dynamic route


What happens if you run this command from the CLI?

CLI returns bad substitution - This is the command I run - is there a typo?

${SHELL([[ -f /var/spool/asterisk/voicemail/default/00/temp.wav ]] && echo -n ‘true’)}


If you run it at the Asterisk CLI, you mustn’t include the dialplan function, and you must prefix it with an exclamation martk

Not sure what you mean with the dialplan fuction.

In the end the function should work in the dynamic route module and not the CLI. I just tested what the CLI returns since @PitzKey asked @lgaetz

Get to the Asterisk CLI:

 asterisk -r

run the command inside the SHELL parentheses with a ! prefix, i.e.:

![[ -f /var/spool/asterisk/voicemail/default/00/temp.wav ]] && echo -n ‘true’

If 00 VM has a temp message you should see the word true displayed, otherwise nothing. My example with ext 6007

*CLI> ![[ -f /var/spool/asterisk/voicemail/default/6007/temp.wav ]] && echo -n true

*CLI> ![[ -f /var/spool/asterisk/voicemail/default/6007/temp.wav ]] && echo -n true

@lgaetz yes I’m getting a true-n displayed when the temp.wav exists and nothing when I delete it.

I copied then the same statement

[[ -f /var/spool/asterisk/voicemail/default/00/temp.wav ]] && echo -n ‘true’

without the ! as the prefix to the dynamic route and it also works. Great :slight_smile:

Looks like all is fine - I want to test it on Monday when the time condition is active and the voicemail is switched off. But I guess the dynamic route always comes first.

@lgaetz - Hello, i was too fast with my assumption that the asterisk variable is working. I’m using this asterisk variable in the dynamic route

${SHELL([[ -f /var/spool/asterisk/voicemail/default/00/temp.wav ]] && echo -n ‘true’)}

please see also the screenshot.

Using this command in the CLI it returns a true

[[ -f /var/spool/asterisk/voicemail/default/00/temp.wav ]] && echo -n ‘true’

I guess there is a syntax error in the dynamic route for the Asterisk variable.

Could you please help?



It doesn’t return a ‘true’, it returns a string with the value of “true” which is not the same thing , if you want the obverse, i.e. a string of “false” you would need to add the || (or) condition which would be returned if the && (and) failed on the ‘test’ ( here within the [[…]] construct )

I think you could also have an unconditional " ; echo -n $?", although the truth sense may be inverted, and I don’t know if FreePBX can cope with quoting the ;.

without the echo statement, it WOULD return a boolean but you need to either assign to a variable for further process or do the asterisk ?here,. . :there,.. (and,or) dialplan test construct immediately inline, if you omit either ‘? or :’ then the dialplan will just ‘continue’ without branching for that test

Thanks - I’m not good with Asterisk statements and what it returns.

Could you please tell me the Asterisk variable to enter in the GUI and the match statement?

When it returns a string with the value “true”, which placeholder could I enter in the match statement to fetch it?

I would appreciate it.


Sorry I still need help with this statement @lgaetz

${SHELL([[ -f /var/spool/asterisk/voicemail/default/100/temp.wav ]] && echo -n ‘true’)}

It does not work when I enter the statement in dynamic variables in the FreePBX GUI.

I assume any rule set in the dynamic variable will process first then set in time conditions.

It’s working in my testing. What you have shared appears to be correct, so at this point perhaps sharing a call trace via pastbin will pinpoint an issue. Providing Great Debug - Support Services - Documentation

Thanks @lgaetz - I shared a call trace via pastebin

The name is: name: [email protected]

Edit your post with a URL link to the resource.

1 Like