Skip to content
The free Java library for Asterisk PBX integration.
Java Other
Latest commit ec8a9f8 @bsutton bsutton Merge pull request #82 from elara-leitstellentechnik/master
String encoding configurable, where UTF-8 is default

README for Asterisk-Java


The Asterisk-Java package consists of a set of Java classes that allow you to easily build Java applications that interact with an Asterisk PBX Server. Asterisk-Java supports both interfaces that Asterisk provides for this scenario: The FastAGI protocol and the Manager API.

The FastAGI implementation supports all commands currently available from Asterisk.

The Manager API implementation supports receiving events from the Asterisk server (e.g. call progess, registered peers, channel state) and sending actions to Asterisk (e.g. originate call, agent login/logoff, start/stop voice recording).

A complete list of the available events and actions is available in the javadocs.

See docs/tutorial.html for examples.


Asterisk-Java is available from


git clone
cd asterisk-java
mvn install

After the build is complete, the jar will then be built as target/asterisk-java.jar in the asterisk-java directory.


The file 'examples/' will answer the call and playback the audio file 'tt-monkeys'.

import org.asteriskjava.fastagi.AgiChannel;
import org.asteriskjava.fastagi.AgiException;
import org.asteriskjava.fastagi.AgiRequest;
import org.asteriskjava.fastagi.BaseAgiScript;
/* Example incoming call handler
Answer call, speak message */
public class ExampleCallIn extends BaseAgiScript {
  public void service(AgiRequest request, AgiChannel channel) throws AgiException {
    exec("Playback", "tt-monkeys"); 

The file 'examples/' maps your Asterisk diaplan context to the class you would like to invoke above.

callin.agi = ExampleCallIn

To compile and run do:

javac -cp asterisk-java.jar
java -cp asterisk-java.jar org.asteriskjavafastagi.DefaultAgiServer


Asterisk-Java needs a Java Virtual Machine of at least version 1.6 (Java SE 6.0). If you want to build the jar from source, you will also need Maven.


Asterisk-Java is subject to the terms detailed in the license agreement accompanying it.

Something went wrong with that request. Please try again.