[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1716
  • Last Modified:

Asterisk scheduled calls?

Hello all

is it possible to scheduled calls in Asterisk?

we are currently running 1.4.7.1 an would love to have the ability to run (internal) calls at specific times

the idea is to use the calls as factory break notifications

thanks
0
mudcow007
Asked:
mudcow007
  • 7
  • 5
  • 2
  • +1
2 Solutions
 
tigermattCommented:
You can use call files for that. These are text files with the extension ".call" which contain simple line-by-line directives for Asterisk to open a session on a particular channel and bridge that with a particular extension in the dialplan.

See http://www.the-asterisk-book.com/unstable/call-file.html for details.

There is a good example at the bottom of the above link which details how to make a call file "wait" for processing in the future, but the concept is very simple. You essentially have to set the date and time of modification on the file to the exact date and time that Asterisk should make the call; any call file whose time is in the future will be held until that time passes.

You'll want to build the files outside of the /var/spool/asterisk/outgoing directory structure and then use the move (mv) command to copy the file into that directory once all the directives are in place and the correct modification date is set. Asterisk performs very eager checking of the spool directory, and you could get yourself into a situation where an incomplete call file is processed if you try to build the files directly in that directory.

For your example, if the files are to be the same time(s) each day, then you can simply keep a master file in some other directory, and run a shell script via a cron job at the appropriate time(s) of day to copy that master file and then move the copy into the outgoing directory. (Again, check the note at the top of the link above - you don't want to copy (cp) the master file direct to /outgoing as an incomplete call file might end up being processed.)

-Matt
0
 
José MéndezCommented:
So, you want the system to automatically open up a broadcast notification type of call to several IP Phones at scheduled times? Or just generate individual calls to a list of phones playing the notification message?
0
 
mudcow007Author Commented:
thanks for the info guys,

what im after is a call at say 10:00am which plays a wav/ gsm

then call at 10:15 plays wav

i have the play command worked out, but its the timing that is throwing me
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
tigermattCommented:
This really depends on how you want it to work. Same time every day will be easier; different times will mean you need to write custom scripts to produce the call files on demand.

You can "delay" the call being placed by two methods. The first is to set the modify time on the .call file (created as per the format in the link above). Move the call file into the outgoing directory for Asterisk under /var/spool. Asterisk won't read the file and place the call until the time you set the modify date to be.

So, if I wanted to place a call file which doesn't do anything until tomorrow at 10am, I'd create the appropriate file in my home directory, then "touch" it and set the date and time thus:

touch -t 201209041000 ~/mycallfile.call

Finally, use "mv" to move the file into the outgoing directory:

mv ~/mycallfile.call /var/spool/asterisk/outgoing

The file will sit in there until tomorrow at 10am. At that time, Asterisk picks up the call file, will parse it and place the call.

You would need to devise a scripted or manual method to produce call files with the appropriate date and time and move them all into that directory. In theory you could produce the next year's worth of call files and just let them sit there; Asterisk won't do anything with them until the date on the file.

The other way is to have a stack of call files which you fire a cron job at the appropriate time to copy into the /var/spool/asterisk/outgoing directory. This means you don't need to change the modification time; just use cron to make a copy of the pre-existing file and then move it into the directory. Since your modification time would be in the past, Asterisk will pick the file up and place the call straight away. You control the time the call(s) are made by using the cron scheduler. A simple shell script can be written to make the copy and move it into the directory very easily.

-Matt
0
 
PhonebuffCommented:
Use Cron in conjunction with the Call File Technique mentioned above to schedule the announcements..

crontab -e

; Run Warehouse announcement scripts 
0     10     *     *     1-6     /home/mudcow/tenNotice 
15   10     *     *     1-6     /home.mudcow/ten15Notice

Open in new window


The first one is Monday-Friday at 10am The second at 10:15.  Then just put your logic in the two scripts to do the Call file..  NOTE: Be sure the call file is Created in /tmp and MOVED (mv) to the  /var/spool/asterisk/outgoing/ directory for Executing ..

========================================
0
 
mudcow007Author Commented:
great stuff, so its "do-able"?

question i would like this to be a permanent alarm so could it be set just to run every day at X o'clock?


my idea is to call our paging agi (*96 on our pbx) this sets all handsets to autoanswer an would then hopefully playback a recording etc....

if possible
0
 
PhonebuffCommented:
Can it run every day ?  Yes, just replace the 1-6 (Day of Week) with a *.

You need to read the information on the Call File provided.  An built a context to do what you want.
0
 
mudcow007Author Commented:
Fantastic, really appreciate you help guys.

just been looking at cron on my server i looked in

Var > Spool > Cron

i have three folders "atjobs" "atspool" "crontabs"

im presuming i need to make a text file within "crontabs" with something like

# Minute   Hour   Day of Month       Month          Day of Week        Command    
#   (0-59)  (0-23)      (1-31)           (1-12 or Jan-Dec)  (0-6 or Sun-Sat)                
         0        2              12                        *                    0,6                       /usr/bin/find

at the moment the crontabs folder is empty

thanks
0
 
PhonebuffCommented:
im presuming i need to make a text file within "crontabs"?


NO !   su to root / asterisk/ who ever you want it to run as and  and Use the Command "crontab -e"  You can get in trouble doing it manually.
0
 
mudcow007Author Commented:
ah i log on as root, i have find its easy messing around with ext's etc

so tried contab -e

which opened up the creation page

fantastic i now have access to use crontab



(thanks for all the help i have done anything like this with * before)
0
 
mudcow007Author Commented:
update

i created a .call file with the following

channel: SIP/777@Internal
callerID: "alarm"
maxretries: 1
retrytime: 300
waittime: 45
context: alarm
extension: s
Priority: 1

within my extensions conf

i have added
[alarm]
Exten => s, 1,SIPAddHeader (Call-Info:\; answer-after=0)
Exten => s, n,Dial(SIP/901,,A(hello-world)gS(1))


This worked!! :)

this is now performing the tannoy announcement but dials an extension (777) before it does the call out. when the extension is answered the tannoy announcement is played

is there a way of removing "dial" from the call file?

i have tried commenting the dial string but the call fails

if i could award more than 500 points i would!!
0
 
PhonebuffCommented:
You might want to look at this code sample from John M. over at PBXinaFlash..  

It's got most of the parts you need for the dial plan..

http://www.pbxinaflash.com/community/index.php?threads/delayed-paging.2654/
0
 
mudcow007Author Commented:
hi phonebuff, i appreciate the link but i dont really know what part of the code to use?

basically, i have playback/ tannoy part working. But when the message is played, an extensions rings.

the message only rings once that extension is answered

i then need to figure out how to use cron!
0
 
PhonebuffCommented:
I am sorry, best I can for you here is point you the answers.  

You could register and post on the PIF Forum.  

=========================
0
 
mudcow007Author Commented:
Fantastic help<br /><br />i changed my extensions around an got the call out to work without calling the extension <br /><br />thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now