Asterisk-Java 1.0.0-m2 Released
On the way to the final 1.0.0 release
As most of the users already make use of many new features in 1.0.0-SNAPSHOT it is time to push the final release out of the door. As a first step I've released milestone 2 of 1.0.0 called 1.0.0-m2. Have a look at the changelog to see which bugs have been fixed and which new features are included.
Most notably milestone 2 includes support for the 1.6 series of Asterisk as well as support for using scripting languages with the FastAGI server.
The new release is available as a plain jar and a zip distribution at http://asterisk-java.org/download/1.0.0-m2. You can also browse the documentation and javadocs online.
Please report back any issues you encounter while using milestone 2 through our issue tracker. If you like to have a certain feature or bug fix included vote for it.
References
Scripting Support for FastAGI
Writing AGI scripts in Groovy, JavaScript, JRuby or PHP
Asterisk-Java 1.0.0 includes support for implementing AGI scripts in the scripting language of your choice. You still have the benefit of running on the JVM but for the implementation of your script you can now choose your favorite language.
I've prepared a small demo script that counts down from ten to zero. Then it plays a beep and waits for DTMF input to read the digit you've pressed back to you. You can exit by pressing star (*) or pound (#). To show you how this script looks like in the different languages it is implemented three times: In Groovy, JavaScript and PHP.
To get started just download the binary distribution of Asterisk-Java. Unpack it and run the asterisk-java.jar file from the unpacked directory.
$ cd asterisk-java-1.0.0-SNAPSHOT $ java -jar asterisk-java.jar May 13, 2009 1:26:16 AM org.asteriskjava.fastagi.DefaultAgiServer startup INFO: Listening on *:4573.
The AGI scripts are put into the agi directory. There you'll also find the demo.groovy, demo.js and demo.php files. The lib directory contains additional libraries required to execute the scripts.
In addition to the functions provided by the scripting language Asterisk-Java adds two variables:
- request
- the request data including the dialed extension, the caller id, channel name, parameters and more
- channel
- for interacting with Asterisk, e.g. to stream files, receive DTMF digits or execute dialplan applications
Modify your dialplan and add extensions for the demo scripts:
exten => 2000,1,Agi(agi://localhost/demo.groovy) exten => 2001,1,Agi(agi://localhost/demo.js) exten => 2002,1,Agi(agi://localhost/demo.php)
If you are not running Asterisk-Java on the same server as Asterisk replace localhost by the hostname of the machine running Asterisk-Java.
Note that you will need at least Java 6 to make use of the new scripting support.
Asterisk-Java Lightning Talk @ JUGC
May, 29th 2009
I will give a short presentation of Asterisk-Java (in German) at the Java User Group Cologne (JUGC) on May 29th.
It will be a short overview of what Asterisk-Java can do and how it can be used to add phone support to Java applications. The presentation will have a duration of 5 to 10 minutes and include a small interactive demo that serves as a show case.
The main talk will be about JSF 2.0 vs Struts 2.1. I would be happy to meet a few Asterisk-Java developers over there.
The slides are available (in German) at slideshare.
Users: Asterisk and CTI, what’s that all about?
Some inspriation for playing with the Asterisk APIs
Sameh Shaker has posted some examples of what you can do with Asterisk using the Manager API and Fast AGI. I think it's a good starting point for new users of Asterisk-Java to get some inspiration for their own applications.
References
- Sameh Shaker: Asterisk and CTI, what’s that all about?
Speech Recognition with Asterisk-Java
Using the Lumenvox engine with Java
The latest snapshot of Asterisk-Java contains support for the Asterisk Speech API. This makes writing AGI script that recognize speech as easy as writing AGI scripts for DTMF input.
All you need to get started is a recent version of Asterisk 1.6 and the Lumenvox Speech Engine. For development you can buy a starter kit from Digium for 50 USD.
In your AGI script you initialize the speech engine, load and activate a grammer and are ready to recognize speech. The speechRecognize() method takes a voice prompt as its first parameter. The prompt is played to the user and the users response is recognized. The user doesn't have to wait for the prompt to finish, he can start talking right away ("barge in"). The corresponding Java code looks like this:
speechCreate();
speechLoadGrammar("digits", grammarPath);
speechActivateGrammar("digits");
SpeechRecognitionResult result =
speechRecognize("speech-demo/prompt", 10);
speechDeactivateGrammar("digits");
The SpeechRecognitionResult provided by Asterisk-Java contains the result and the confidence score – a value between 0 and 1000 that indicates how sure the speech engine is that the result is correct. The Java code to evaluate the result looks like this:
if (result.isSpeech())
{
if (result.getScore() > 990)
{
streamFile("speech-demo/absolutely-sure");
}
else if (result.getScore() > 800)
{
streamFile("speech-demo/pretty-sure");
}
else
{
streamFile("speech-demo/not-sure");
}
// say what we have recognized
sayDigits(result.getText());
}
Finally call speechDestory to end the speech recognition session (for a real application you probably want to do this in a finally block):
speechDestroy();
Pretty easy, isn't it?
You can have a look at the SpeechDemo AGI script or download the full demo that includes the latest snapshot of Asterisk-Java, the voice prompts and the AGI script.
Users: OpenNMS
Asterisk Monitoring and Notification
OpenNMS is an open source network management platform developed on the Java platform. It offers monitoring for a wide range of network devices and services.
As Asterisk becomes an important part of today's network infrastructure it becomes more important to be able to monitor it for outages and resource usage. Jeff Gehlbach of The OpenNMS Group is the de facto maintainer of res_snmp and is working on improved monitoring for Asterisk with OpenNMS. His slides from a recent talk in Frankfurt provide a good overview of the effort.
In addition to monitoring Asterisk Jeff has also added support to send OpenNMS notifications through Asterisk. This allows staff to be notified by a phone call of any outages in the network. The notification module is based on Asterisk-Java and uses the originate feature of the Manager API along with a custom AGI script that reads the notice details.
Jeff has made a screencast that shows it in action. If you are interested in the details have a look at his strategy class for originating calls and the AGI script that reads some of the notice details. Along with a few properties for configuration this makes a good example on how to integrate Asterisk into your applications with Asterisk-Java.
References
- OpenNMS homepage
- Jeff's slides on OpenNMS and Asterisk
- Jeff's screencast on OpenNMS Asterisk Notifications
Free Implementation of IAX in Java
Mexuar has released the sources for Correlata SDK under GPLv3
Tim Panton recently announced that Mexuar has released their Correlata SDK under the terms of GPLv3. It is available for download at http://www.mexuar.com/files/corraleta_sdk.rar.
Correlata SDK is a pure Java implementation of the IAX2 protocol. It includes an applet that can be accessed via JavaScript which makes it useful as a softphone embedded into web pages. In contrast to SIP IAX2 is firewall and NAT friendly.
To use the code you have to compile the sources and create a jar file. Then you have to sign it to allow the applet to access the microphone. Finally you'll setup a web page with the applet and add some JavaScript. You can have a look at the source code of the Mexuar homepage to see an example.
Though Mexuar has published the source code under GPL the download only contains the plain Java sources. There is no documentation except for JavaDoc, no build script and no sample code. The link to the download is quite hidden on their website. While Mexuar offers paid support, licenses and manged hosting there doesn't seem to be an Open Source community around it yet. Tim suggested to set up a project on Sourceforge or Google Code to build one. However due to his former relationship with Mexuar he prefers not be the project lead.
I think the code is a great complement to Asterisk-Java and will be very useful for a lot of applications. If you are also interested in giving it a good home and add some polish feel free to comment on this posting or discuss it on our mailing list.
References
- Download Source Code
- Implementing IAX2 In Java, presentation at Astricon Dallas by Tim Panton in 2006
Asterisk-Java With Groovy Presentation
A presentation by Justin Grammens
Justin Grammens has published a great overview of using Asterisk and Groovy with Asterisk-Java showing some real-worl examples.
The presentation is also available from SlideShare.
You might also want to have a look at Justin's blog Localtone. You'll find lots of information on Asterisk, Ruby and Groovy including the Ruby framework Adhearsion and some screencasts. I recommend his screencast on how to setup Asterisk to any Java or Ruby developer who wants to get started with VoIP and Asterisk.
Users: Zimbra Integration
Asterisk PBX Integration Zimlet
Zimbra is an open source groupware product for messaging and collaboration. Its core is implemented in Java and provides extension points for custom plugins so called Zimlets.
Swiss company BNC has developed a Zimlet to connect Asterisk to Zimbra using Asterisk-Java. The Asterisk PBX Integration Zimlet is available from Sourceforge under the terms of the GPL.
Features include
- Dial on-click in Contacts and Emails
- Sending SMS trough Asterisk's SMS application
- Inbound call notification
References
Users: Asterisk-Java and Spring
Mapping AGI URLs to Spring Beans
Sajid Moinuddin has blogged about using Asterisk-Java with Spring. His article shows how to implement a BeanNameAwareAGIMappingStrategy that automatically maps AGI URLs to Spring beans without any additional configuration.
References: