RESTful Click to Call with Adhearsion

One of the great new features of the latest release of Adhearsion is the RESTful RPC API. With the RESTful API one may now use virtually any modern language to interact with Adhearsion to voice enable their apps, including PHP, Perl, Python, Java and more. Everytime you create a new Adhearsion project the resful_rpc component is installed, just disabled by default. To enable the REST API of your new Adhearsion app, simply do the following from within your project directory: ahn enable component restful_rpc Thats it! Your Adhearsion app now has a REST API. To showcase this capability we have created an example component (restful_clicktocall) that provides a web form to do a 'Click to Call'. The web form is developed using JQuery in order to provide a dynamic interface, using AJAX (but with JSON), that shows call progress. The web form is then served up using the great Sinatra library as the web server that in turn calls Adhearsion methods using the restful_adhearsion client library. Enough of that, lets see how it works: [blip.tv ?posts_id=1743747&dest=-1] Feel free to download the example component here and give it a try yourself.
Posted
 

Using DRb with Adhearsion

Media_httpjsgoeckefil_ffbje
Adhearsion now has an RPC implementation that supports several technologies out of the box for connecting an external process to Adhearsion. These technologies include a RESTful component, a STOMP queue component, as well as support for Distributed Ruby (DRb). DRb is a distributed object system that allows another process to invoke methods on a remote object over TCP, similar to the Java RMI and included in the Ruby standard library. With a DRb connection you may have inter-process communication between two Ruby processes on the same server, or between two processes distributed geographically via the internet. By default an ami_remote component is enabled in Adhearsion that exposes the Asterisk Manager Interface Class via DRb. With this, you may initiate outbound dials from a Rails app by simply doing the following: [sourcecode language='ruby'] require 'drb' Adhearsion = DRbObject.new_with_uri "druby://localhost:9050" Adhearsion.call_into_context("SIP/17475551212@proxy01.sipphone.com", "play_message_context") [/sourcecode] This example would initiate a call to a SIPPhone user and once connected could play a message to the person dialed. Using an Adhearsion Component you may also add additional RPC methods. For example: [sourcecode language='ruby'] methods_for :rpc do def method_for_remote_access(options) #some code here end end [/sourcecode] This code would create a method that could be accessed via DRb or any of the other supported RPC transports from your remote process. The Adhearsion RPC support is a powerful capability of the framework that allows for virtually any application to access Adhearsion capabilities. For additional information visit the DRb and Components pages on the Adhearsion Wiki.
Posted