1 / 42

Asterisk on Rails : Using RAGI to create voice applications

Asterisk on Rails : Using RAGI to create voice applications. What is Ruby on Rails?. What is Ruby on Rails?. Ruby – the programming language 10 years old, originated in Japan Interpreted, not statically typed, object-oriented

jpoulin
Download Presentation

Asterisk on Rails : Using RAGI to create voice applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Asterisk on Rails: Using RAGI to create voice applications

  2. What is Ruby on Rails?

  3. What is Ruby on Rails? • Ruby – the programming language • 10 years old, originated in Japan • Interpreted, not statically typed, object-oriented • “more powerful than Perl, and more object-oriented than Python” • Rails – the framework • A full-stack web framework written using the Ruby programming language. Everything that you need to write a web application. • “web applications that formerly might have taken weeks or monthsto develop can be produced in a matter of days.” - Tim O'Reilly

  4. Rails • “Convention over configuration” • “Don’t repeat yourself” • Features: • Model-View-Controller • Simple database access via ActiveRecord • Integrated AJAX • Pretty URLs via routing • Flexible caching • Integrated testing framework • Integrated debugging • Sites that use Rails: • http://www.basecamp.com • http://www.43things.com • http://www.odeo.com • Many more

  5. What is Asterisk?

  6. “Asterisk is an Open Source PBX” Call to (415)555-1212… “Please enter the extension…” x101 = Amit x102 = Sally • Internet • Phone lines x103 = Arnaud • Linux hardware • Asterisk • Optional: TDM card • SIP • IAX • POTS • Phones • VoIP phones • Softphones

  7. What could you use Asterisk to do? • Set up an office with 4 phone lines, 25 extensions and 1 receptionist • Make the best home phone system ever • Build an IVR, call queuing and live customer support app for a banking call center • Power voicemail for Vonage • Call a list of phone numbers with a recorded message, “This is congressman Baird, did you know you can add yourself to the National Do Not Call list? Press 1 to add yourself now…”

  8. Asterisk: The Apache of Telephony • Asterisk is an open source bundle of telephony protocols and VoIP magic, in a PBX form factor. • Features: extensions, voicemail, conferencing, IVR, 3-way calling, caller ID, speech to text (Sphinx), text to speech (Festival) • Protocols: SIP, IAX, H.323, ADSI, + • Extensibility: the dialplan, AGI, manager API, C API

  9. Interfacing with Asterisk • There are several ways to write applications for Asterisk out of the box • The dialplan - extensions.conf • Hard to write and debug complicated systems, but fast. • AGI (Asterisk Gateway Interface) • Asterisk calls out to an application during dialplan. • Run telephony and app processes on separate servers • AMI (Asterisk Manager Interface) • Monitor asterisk call channel state • Modify the source code / loadable module • Hey it is open source. • Changes will be need to be migrated each version. • C code, will run fast, extensive access to asterisk internals via APIs

  10. RAGI = Rails + Asterisk

  11. What is RAGI? • RAGI = Ruby Asterisk Gateway Interface • Asterisk AGI implementation in Ruby + more • Supports both incoming and outgoing calls • Adds a “Handler” class type to Rails apps for doing phone apps

  12. database Architecture Application Logic VoIP Protocol Handling Ruby on Rails Asterisk AGI RAGI Server answer(); i = 0; n.times do end hangUp() Call Handler

  13. Why RAGI? • You are using Rails and/or Ruby for other development. • Asterisk alone is not enough: Wrestling with “extension.conf” is fine for PBX but not well suited for data-driven apps with complex flows • Deployment: separate your app server from your telephony server • Development: Direct access to your object hierarchy within your phone app

  14. What could you use RAGI to do? • Add a mobile interface to your web app that has more reach than with WAP or SMS • Add a phone interface to your blog (posting + listening) • Mash up RSS and IVR for a better kind of 411 • Route the call center calls to the CRM app (finally) • Broadcast live audio from the game to people listening to streaming audio off a website • Alternate reality games… the pay phone rings, a clue is given, punch in your cell phone number, etc • Rentable Phone Numbers - Temporary phone numbers for use in classified ads • Click-n-talk with others who are viewing this web page • Learn Chinese; fill out your profile and we’ll match you with a qualified instructor in China connecting you over voip and handling payment...

  15. Nice reach VoIP Clients Web Browsers HTTP SIP, Jabber Fixed line phones VoIP/PSTN Service SIP, IAX Asterisk + RAGI + RoR Mobile phones

  16. Who is using it? • Released 2.5 months ago • Nearly 500 downloads times • Emails and generally • “Thanks, now I have an excuse to learn Rails” and • “Thanks, now I have an excuse to learn Asterisk”

  17. e.g. Mobile Payments in Ghana

  18. Mobile Payments in Ghana (2) “ RAGI saved me a lot oftime, especially with the sample application using such an easy touse API. Ruby on Rails (ActiveRecord, really) helped a lot tobootstrap a working model and I was able to tie the model and RAGI into my application logic easily. I was new to Ruby, though I know quite a few languages, and I had to absorb Ruby, Rails, RAGI andAsterisk. ” Short story is after something like a week and a half, we had come up with the version that you can listen to in the audio demonstrations of the system. Guido Sohne http://www.corenett.com/ mailto:guido@sohne.net

  19. Let’s Build an App Right Now Note: See screencast on http://www.snapvine.com/code/ragi

  20. “Dial-a-Package.com” Track packages from web and phone Web: Use the web to enter UPS tracking numbers Phone: Dial in to hear delivery status

  21. For visual people…

  22. For visual people…

  23. For visual people…

  24. For visual people…

  25. For visual people…

  26. For visual people…

  27. For visual people…

  28. For visual people…

  29. Components • Ruby on Rails web & phone app UI • MySQL  data storage • Asterisk telephony low level • RAGI connect Rails and Asterisk

  30. Outline of Steps • 1) Create Rails Install • 2) Create database instance • 3) Build web app • 4) Install RAGI • 5) Build call handler

  31. Write the call handler • User dials in • Authenticate by caller ID (or ask) • For each user delivery, • Fetch and parse info from the web • Use text to speech to read status • Hangup

  32. Listen…

  33. Summary • Asterisk = open source PBX, VoIP and telephony protocols • RAGI = build phone interactions in your Ruby and Rails apps • More info: http://www.snapvine.com/code/ragi Today’s demo code and screencast will be posted online soon!

  34. Learn More Contact: joe@snapvine.com RAGI, these slides, a new tutorial and other goodies: http://www.snapvine.com/code/ragi http://www.asterisk.org http://www.voip-info.org/wiki/

  35. Backup Slides

  36. Example CallHandler API • answer, hangup • play_sound, record_file • dial • play_tone (various) • send_DTMF • MeetMe conferencing • get_data – read user input • speak_text – text to speech • say_digits, say_number, say_time • get call status • execute arbitrary Asterisk server extension

  37. Configure RAGI Ruby on Rails Asterisk Phone call RAGI Server Configuration: 1 Tell Asterisk where your RAGI server is (agi) 2 Tell Rails how to boot up with RAGI answer(); i = 0; n.times do end hangUp() Call Handler Your call handlers are found using URL, just like a web browser. e.g. exten => 101,2,agi(agi://192.168.1.203/banking/check_balance)

  38. Call Handler Goes here when the call is answered

  39. RAGI Classes • CallHandler – subclass this for each IVR you create • CallConnection – an API used by a call handler to operate on the call (e.g. play_sound, get_data, say_digits, etc) • CallServer – a process in your Rails app that communicates with your Asterisk server • CallInitiate – a class used to trigger outbound calls

  40. VoIP Termination / Origination • Origination – creation of a call session from the PSTN to a VoIP network. Think of this as a mobile device dialing a number, and that call session routing back through the mobile network, to that number (DID), which is routed over VoIP to your Asterisk server. Think of it as “dialing a phone number to reach your VoIP server” • Termination – creating a call session from the VoIP network to the PSTN. This of this as your server calling out to a regular phone number (e.g. Skype Out). Traffic is routed to a termination service provider who then routes the VoIP to the closest point of presence, where they typically have a switch that hands of to a PSTN network (i.e. to make a local phone call) • Providers – There are many providers of termination and origination. Many ISPs have entered the business, and there are plenty of resellers of Level3 and Global Crossing offering the service. • Prices – termination is ~$0.01 per minute within the USA and origination (phone numbers) for a few dollars per month flat rate unlimited minutes. International rates vary. • Setup – once you have found a provider, it is easy to configure asterisk to accept inbound phone calls (origination) and hand them to particular RAGI handlers by configuring asterisks’ basic config files. Outbound (termination) is similarly easy to configure so that you can use RAGI to place calls to phone numbers. • More info - http://www.voip-info.org/wiki/view/VOIP+Service+Providers+B2B

  41. RAGI – developer SDK Ruby Asterisk Gateway Interfacehttp://www.snapvine.com/code/ragi • “RAGI alone is like the 5th thing that makes me think I should sincerely add Ruby to Python as my two default languages” – Kendall Clark, Managing Editor of XML.com • “Ruby Asterisk Gateway Interface serves as a bridge between Ruby on Rails and Asterisk - Pretty exciting stuff” - David Heinemeier Hansson, creator of Ruby on Rails • “This has the potential to be really interesting, because Asterisk+Rails should be about a decade more advanced then anything that the IVR people are used to seeing.” – scottstuff blog • Over 500 downloads in the first 2.5 months!

More Related