Applies to VoipNow 3.X.X!
By placing automatic test calls, you can receive early alerts whenever your channel provider has issues routing calls to/from your server. This article shows how you can set Asterisk to place calls to a test number within a time interval and get an e-mail alert message whenever such calls fail.
However, this is not the only method you can apply. You can also use UnifiedAPI.
- Create a /tmp/autodial.call file.
Mind the ownership and permissions.
The autodial.call file should contain the following:
Replace 355555555 with a DID you have on your server and in a format accepted by your provider.
Then place the following lines in extensions_custom.conf.
Again, replace 35555555, the channel ID (in this example, channel ID is 2) and the IP of the channel with those you indend to use on your server.
Then run the following command to have the call placed towards the provider who will then route the call back to your server.
Register a phone terminal to the extension that receives this call.
Now make a test call like this:
At this point, your phone should ring.
If the call was successfully placed towards your server, we can now make a script to automate the process.
To create the script, follow the steps below:
- Create a log activity to alert you when calls fail.
- Make an ICR on the destination extension and set it to hang up the call. This way you won't be billed for the test calls.
- Activate a Dial-IN Call Event on the extension and point it to http://<your_server_ip>/autodial.php
Create the autodial.php file as shown below. Mind the ownership and permissions.
This is the code that will be executed once your destination receives the autodialer call. It will save the contents of the Call Event request to autodial.log.
Now create the autodial.log file as shown below. Again, mind the file ownership and permissions.
The calls will be placed by this script (replace with your email address):
Here is how it goes:
→ The script moves the autodial.call file to the "outgoing" directory.
→ Asterisk places a call towards the configured DID through the configured channel.
→ You increment the callerID value in the autodial.call file. Each call will have an incremental callerID.
→ The call comes back to the VoipNow server where it reaches the extension that hangs up and creates a Call Event request.
→ The audodial.php file inserts details about the call. Here is an example.
→ You wait for 10 seconds to make sure the call event log has time to be created and then look for the latest callerID in the log.
→ Based on the callerID, the script appends a message stating whether the call worked or not.
→ In case the call failed, you'll also receive an e-mail at the configured address.
→ If the flow is correct up to this point, you can set up the script in a cron to run every few minutes.
Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 4.0 International.