Dialout time intervals

I need to automatically place outgoing calls to my Asterisk PBX (a Digium AA50).
I put a call file to /var/spool/asterisk/outgoing/ directory.
My call file looks like this one:

Channel: ZAP/1/0111234567 MaxRetries: 10 RetryTime: 3600 WaitTime: 45 Context: myContext Extension: s Priority: 1 Archive: No
Before putting the file I change it’s timestamp to choose when to start dialing.
I would like to be able to tell asterisk to avoid retrying at night (say from 20:00 to 09:00…).
Is it possible? Ho can it be done?
Thanks in advance!

Marco

AFAIK thats impossible within Asterisk, as the call-files doens’t support a concept of “social-times” for call-retries.
What You could do is establishing a cron-job, running once a day (at beginning). This job should look for all files within /var/spool/asterisk/outgoing and update their timestamps to the next possible calltime.

[quote=“abw1oim”]AFAIK thats impossible within Asterisk, as the call-files doens’t support a concept of “social-times” for call-retries.
What You could do is establishing a cron-job, running once a day (at beginning). This job should look for all files within /var/spool/asterisk/outgoing and update their timestamps to the next possible calltime.[/quote]
Hi,
Thanks for yor answer.
Though, I do not understand your advise (sorry… :wink:). My problem is for calls whose call-recall job is already active, and being run by asterisk: once the first call is placed (since the timestamp matches current date-time), asterisk immediately deletes the file from outgoing directory…
The only solution I see would be to completely handle the call-recall jobs myself, always setting “MaxRetries” to 0 … Do you see any drawbacks with this approach?

Marco

Asterisk should not delete the call-files until they are a) fullfilled (calls where placed successfully) or b) call attempts are terminated as maxretries exceeded.
What I’m not certain about is wheter the retry-timer is internal (thus the file will not be re-readen for the next call attempt) or external in the file. Unfortunately I can’t check this at the moment. However, should the first assumption be correct (callfile is only readed once at first call attempt) than the approch should be in an other way:

MayRetries should be 0

and You should check the succesfull call within the dialplan and take the actions there according to Your requirements. To achieve this, the callfile should be a bit modified:

Channel: Local/0111234567@cfout/n MaxRetries: 0 WaitTime: 45 Context: myContext Extension: s Priority: 1 SetVar: OpenAttempts=10 Archive: No

with these additional extensions (untested, just draft based on Your first posting):

[cfout] exten => 0111234567,1,GotoIfTime(20:00-09:00|*|*|*?next) exten => 0111234567,n,Set(RetryDelay=3600) exten => 0111234567,n,Dial(ZAP/1/0111234567) exten => 0111234567,n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?end) exten => 0111234567,n(next),Set(OpenAttempts=$[${OpenAttempts}-1]) exten => 0111234567,n,GotoIf($["${OpenAttempts}" = "0"]?end) exten => 0111234567,n,system(echo -e "Channel: Local/${EXTEN}@cfout/n\\nMaxRetries: 0\\nWaitTime: 45\\nContext: myContext\\nExtension: s\\nPriority: 1\\nSetvar: OpenAttempts=${OpenAttempts}\\nArchive:No" > /var/spool/asterisk/${EXTEN}); exten => 0111234567,n,GotoIf($["${RetryDelay}" = "3600"]?nretry) exten => 0111234567,n,Set(day=${STRFTIME(${EPOCH},GMT,%Y%m%d)}) ; get actual date (without time) exten => 0111234567,n,GotoIfTime(00:00-09:00|*|*|*?sameday) ; do we need to add one day ? exten => 0111234567,n,Set(day=$[${STRPTIME(${day},GMT,%Y%m%d)+86400]} ; add one day exten => 0111234567,n,system(touch -t ${STRFTIME($[${day}+32400],GMT,%Y%m%d%H%M.%S)} /var/spool/asterisk/${EXTEN}); add 9:00 hours exten => 0111234567,n,Goto moveit exten => 0111234567,n(sameday),Set(day=${STRPTIME(${day},GMT,%Y%m%d)} ; same day exten => 0111234567,n,system(touch -t ${STRFTIME($[${day}+32400],GMT,%Y%m%d%H%M.%S)} /var/spool/asterisk/${EXTEN}); add 9:00 hours exten => 0111234567,n,Goto moveit exten => 0111234567,n,system(touch -t ${STRFTIME($[${EPOCH}+${RetryDelay}],%Y%m%d%H%M.%S)} /var/spool/asterisk/${EXTEN}); exten => 0111234567,n(nretry),system(touch -t ${STRFTIME($[${EPOCH}+${RetryDelay}],%Y%m%d%H%M.%S)} /var/spool/asterisk/${EXTEN}); exten => 0111234567,n(moveit),system(mv /var/spool/asterisk/${EXTEN} /var/spool/asterisk/outgoing/); exten => 0111234567,n(end),Hangup

Hi, Olaf,
thanks a lot for your detailed answer!
Yes, you are right about outgoing dir (sorry…).
I did just try, and really manually deleting the call file from the outgoing directory at any time, causes the retries to terminate! Thanks! So I can keep the logic outside the dialplan syntax, which I (being quite a newbe with Asterisk) feel quite “recondite” :wink:
Thanks again!

Hi, Olaf,
I’m trying to use your dialplan suggestion…
I used to put a call file (with Channel and RetryTime inside) in “/var/spool/asterisk/outgoing/” directory, and I am not using the “Dial” command. But probably your approach is more flexible, and you have ${DIALSTATUS} and other variables available.
I only do not understand how to let a single extension to perform calls to different numbers (in your example the phone number is constant…)