In this post, we will explain how to install and run FreePBX (GPL), a Web-based GUI to control and manage Asterisk PBX, and control incoming phone calls using Java and the Asterisk FastAGI with a custom IVR. We will explain how to configure the system to run with its basic features. For further management, read FreePBX user manuals. First, let’s install FreePBX.
Congratulations! You have now Asterisk PBX up and running.
In order to receive incoming calls you should configure your SIP trunk into Asterisk:
Test your Asterisk calling from your phone to your SIP number. You should listen to a machine asking for a phonebook number.
To control the incoming call using custom programming, you should use the Asterisk FastAGI. In our case, we will create an AGI script using Java and Asterisk-Java library:
svn co http://svn.reucon.net/repos/asterisk-java/trunk asterisk-java |
make install |
import org.asteriskjava.fastagi.AgiChannel; import org.asteriskjava.fastagi.AgiException; import org.asteriskjava.fastagi.AgiRequest; import org.asteriskjava.fastagi.BaseAgiScript; public class HelloAgiScript extends BaseAgiScript { public void service(AgiRequest request, AgiChannel channel) throws AgiException { //Answer the channel… answer(); //Play speed-enternumber sound while waiting for the user //to enter 4 digits. We wait for a 20 seconds timeout //in case digits are not dialed. String numbers = getData("speed-enternumber", 20000L, 4); //Work with dialed digits //If the user pressed 2-0-0-1, ask for another number and store it //If the user pressed 1-0-0-1, let the user leave a voice message if(numbers.equal("2001")){ String finalNumbers = getData("vqplus-enter-number", 20000L, 2); //Store finalNumbers into your database or do something else //… }else if(numbers.equal("1001")){ //Record the voice for 10 seconds or until the user press 2 recordFile("voiceRecord","wav","2",10000); } //Terminate the phone call hangup(); } |
/var/lib/asterisk/sounds |
javac -cp asterisk-java.jar HelloIVRScript.java |
hello.agi = HelloIVRScript |
[helloivr]exten => 1000, 1, Agi(agi://localhost/hello.agi) |
Save and apply changes.
Let’s start with the definition given by the official page. “Mockito is a mocking framework that tastes really good. It […]
Continue readingWhen the great idea and background just isn’t enough […]
Continue readingDo you have problems with the space on your disk? You are in the right place! This post is for […]
Continue readingHave you ever wanted to be one step ahead, and be notified of any unwanted exception before your users have […]
Continue reading
COMMENTS