Friday, May 4, 2018

Asterisk - Automatic call

I wanted the asterisk box to make some test calls to me to make sure things were working.
Here's what I did.

This system will place a call out my IAX trunk to a number, and upon answering will play "HELLO WORLD" voice and hangup.

How it works
A shell script is made that the chron job will run (our example, everyday at 3:45 PM)

In that shell script contains the destination number we want asterisk to call, and the sound we want it to play.

Everyday at 3:45 PM the script is run by LINUX which causes asterisk to call  the number and play the sound "Hello world".  then it hangs up.

1> goto /etc/asterisk

2> type in

vi testcall.sh

3> press " " (go into insert mode)
copy and paste the following into that file.  Change "Trunkname" to be the name of your outgoing trunk for external calls.  Change IAX2 to SIP if you use sip trunking.  Put your number in that you want dialed.

#!/bin/bash
echo Channel: IAX2/TRUNKNAME/15552229876 > /tmp/testcall.call
echo Application: Playback >> /tmp/testcall.call
echo Data: hello-world >> /tmp/testcall.call
mv /tmp/testcall.call /var/spool/asterisk/outgoing

4> Press ESC key

5> type:
:wq!
This will save/quit from the app

6> Now type in
chmod 755 testcall.sh

7> Now type in 
crontab -e

8> In your crontab put this in:  (this will run the command at 3:45pm)

45     15     *     *     *         . /etc/asterisk/testcall.sh

9> save / quit  (CTRL X,  Y, then ENTER)


10> You can test the call with this command
./testcall.sh

Within 10 seconds you should get a call.

No comments:

Post a Comment