Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Asterisk-Java Framework Presentation


Published on

My presentation of the Asterisk-Java framework and Click-to-Call service I developed to The Groovy Users of Minnesota technology group.

Published in: Technology, Business

Asterisk-Java Framework Presentation

  1. 1. VoIP using Groovy Building a “Click to Call” web service in Groovy using Open Source Software. Justin Grammens Localtone Interactive
  2. 2. But First A lot of background on Asterisk, VoIP, Open Source Telephony... and a little of who I am.
  3. 3. About Me Interested and developing applications using Asterisk for more than a year. Created screencasts for how to get started with Asterisk and Adhearsion. Developed an application for GeekSquad to handle computer repairs Currently developing a phone voting interface for Localtone Radio
  4. 4. VoIP is NOT About Cheap Phone Calls Other companies are already doing this cheaper and better.
  5. 5. VoIP Applications! It's about the applications that we can build!
  6. 6. What We Will Cover What is Asterisk? ➢ What is a VoIP application? ➢ Why build it now? ➢ Asterisk-Java ➢ Click to Call Web Service ➢
  7. 7. Asterisk + Open Source Private Branch Exchange (PBX). ➢ Handles calls over ethernet or RJ11 (phone line). + Very powerful and flexible. I call Asterisk not ➢ just a PBX, but a telephony platform. + Relatively stable and scalable. ➢ - Messy to deal with in terms of extending ➢ functionality. +++ Free! ➢
  8. 8. Asterisk : Terminology Channel – A channel is what can setup and ➢ receive calls. Dialplan – Script of what to do with a call. Written ➢ in the asterisk macro language. AGI – Stdin/out TCP method allowing external ➢ applications to dynamically write dialplans. AMI – Allows sending of commands and listen ➢ for stateful events.
  9. 9. VOIP / Web Analogy Technology Web VOIP HTTP Protocol SIP – Industry Standard FTP IAX – Asterisk Specific RTP H.323 – Obsolete Jingle – Gtalk Skype - Proprietary gzip, jpg, gif, g.711 – high bandwidth Codec mp3, ogg, wma, gsm – medium bandwidth flv, mpeg, avi g.729 – low bandwidth Apache / Tomcat Asterisk, Freeswitch Server AGI – Asterisk Gateway Interactivity Interface CGI AMI – Asterisk Manager Interface
  10. 10. What is a VoIP Application Same applications we typically develop, but the website can interface with voice and phones. User's send commands using the dialpad of their phone. Users see the application change either on their phone or on the internet. It's all just data!
  11. 11. Why Now? Only recently has good Open Source Software ➢ been developed ( Grails / Groovy / Asterisk ). Telecoms are slow to react. ➢ Few applications merge voice and web. ➢ Cell phone are everywhere! ➢
  12. 12. Why Now? 2.7 Billion mobile phones. 1.4 Billion fixed-lines. ➢ Users can access your application by any ➢ standard home phone. Still hundreds of millions of phones that don't ➢ have an internet browser. Most phone users can be identified by a ➢ standardized numerical system.
  13. 13. Typical Voice System VOIP Clients SIP Grails / Origination/ AGI / PSTN Termination Asterisk SIP / IAX AMI Asterisk Network Server - Java Server Libs / Tomcat Analog PSTN Zaptel Interface Network / Other Card
  14. 14. Asterisk Dialplan Language [demo] ; Sample from Asterisk configuration extensions.conf file ; ; We start with what to do when a call first comes in. ; exten => s,1,Wait(1) ; Wait a second, just for fun exten => s,n,Answer ; Answer the line exten => s,n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds exten => s,n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds exten => s,n(restart),BackGround(demo-congrats) ; Play a congratulatory message exten => s,n(instruct),BackGround(demo-instruct); Play some instructions exten => s,n,WaitExten ; Wait for an extension to be dialed. exten => 2,1,BackGround(demo-moreinfo) ; Give some more information. exten => 2,n,Goto(s,instruct) exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french exten => 3,n,Goto(s,restart) ; Start with the congratulations exten => 1000,1,Goto(default,s,1)
  15. 15. Difficulties in Asterisk Conditional Loops Error Handling ➢ ➢ Complex Data Date and time ➢ ➢ Structure handling Database / LDAP RegEx Pattern ➢ ➢ Integration Matching Extending the Variables ➢ ➢ language Object Oriented ➢ Portability - Asterisk Design ➢ v.s Freeswitch, etc.
  16. 16. Java / Asterisk Integration Tools Asterisk-Java project ➢ Started in 2005. ➢ ➢ Provides support for AGI and AMI. ➢ Open Source library. ➢ Runs in the JVM, so it's accessible via Groovy. ➢ Have used it via JRuby as well. ➢ Cross platform.
  17. 17. Asterisk-Java Put the line below in extensions.conf Tells Asterisk to process all calls by our Asterisk-Java process exten => _X.,1,Agi(agi:// or... when extension 888 is dialed. exten => 888,1,Agi(agi://
  18. 18. AGI Topology Cell Origination/ Phone Asterisk Termination AGI Java Server StdOut Asterisk PSTN Process Internet extensions .conf AGI StdIn
  19. 19. Asterisk – Groovy AGI import org.asteriskjava.fastagi.* public class HelloAgiScript extends BaseAgiScript { public void service(AgiRequest request, AgiChannel channel) throws AgiException { answer() // Answer streamFile(quot;welcomequot;) // play file hangup() //hangup } }
  20. 20. AMI Topology Grails Cell Origination/ Phone Termination Server PSTN Asterisk Internet AMI Web Request
  21. 21. Asterisk – Groovy AMI import org.asteriskjava.manager.* class HelloManager { def void run() throws IOException, AuthenticationFailedException, TimeoutException { originateAction = new OriginateAction() originateAction.setChannel(quot;SIP/Johnquot;) originateAction.setContext(quot;defaultquot;) originateAction.setExten(quot;1300quot;) originateAction.setPriority(new Integer(1)) originateAction.setTimeout(new Integer(30000)) }
  22. 22. Asterisk - Java Write Groovy in our ➢ dial plans! Ability to use ➢ databases, frameworks (Grails) rd and 3 party Java libraries. Test and debug our ➢ application in isolation.
  23. 23. Asterisk - Java It's Java (or Groovy) ➢ It's simpler ➢ It's extensible ➢ It's readable ➢ It's maintainable ➢ Bring OO practices to ➢ VoIP development.
  24. 24. Asterisk Screencast Learn more at ➢ Downloading Asterisk. ➢ Configuring Asterisk in extensions.conf ➢ Download X-Lite or SJ Phone. ➢ Register to Asterisk two phones using SIP ● protocol.
  25. 25. Real World Application eStara Offers a service where a user browsing a site can enter their phone number. The system will dial their number, ask the person to hold and then dial customer service. We'll do this.
  26. 26. Amazon Support – Click to Call
  27. 27. Click to Call Web Service Problem: You have a website and want to allow your users to type their phone number in and have your business phone ring and then connect the call. Web service allows you to pass in a source phone number, a destination phone number and an API Key.
  28. 28. Web Service Request Request: /dial/create?source=${SOURCE}&destination=${D ESTINATION}&apiKey=${APIKEY} Result: <Result xml:ns=quot;urn:localtone:clicktocalljavaquot; xsi:schemaLocation=quot;http://api.localtoneinteractiv;> <Guid>IQ40M</Guid> <Status>100</Status> <Description>Call queued</Description> </Result>
  29. 29. Web Service Status Request: /clicktocalljava/dial/show/IQ40M Result: <Result xml:ns=quot;urn:localtone:clicktocalljavaquot; xsi:schemaLocation=quot;http://api.localtoneinteractiv;> <Guid>IQ40M</Guid> <Status>200</Status> <Description>No Answer</Description> <Source>SIP/200</Source> <Destination>SIP/200</Destination> <User>admin</User> </Result>
  30. 30. GitHub Project Current code for the click to call web service implemented in Asterisk-Java can be found at: ee/master Working on an implementation in Ruby, using the Adhearsion framework.
  31. 31. Questions? Thanks!