Telegraph

Posted by seven_admin @ August 06, 2008 15:52 | Category in: Plugins, Voip,

Intro

Telegraph allows you to write MVC voice application in Ruby on Rails that tightly integrate with the web. In our second release we go FreeSWITCH (the new OSS carrier grade switch) and Rails 2.1. Here’s the details:

For the FreeSWITCH fan:

  • Complete implementation of Outbound Socket, Event (Inbound) Socket and XML-RPC
  • ORM (ActiveRecord) like wrappings around the XML-RPC. Do things like VoiceChannel.find(uuid).destroy to hangup a channel or Conference.find(conf_id).members.first.mute? to see if the first member of a conference is muted.
  • Event socket routing to different code modules. Allows events related to one set business logic go to one codebase and another set go to another. No more if..thens..
  • Easy to read “voice view” syntax for outbound socket.
  • Complete integration with Ruby on Rails and all of its database logic.
  • Easy to deploy, log and maintain.

For the Ruby/Rails fan:

  • Voice code fits right into your usual MVC patterns.
  • Originate/destroy/change calls, conferences and sip settings just like you’d manipulate database tables.
  • Write voice_views like you write html/js/xml views. Use respond_to blocks to share application logic between web/voice interfaces.
  • Write a callback application in only a few lines of code.
  • Need to understand VoIP kept to a minimum.

For The Sys Admin:

  • Easy to deploy, daemonize
  • Based on EventMachine – the super solid and fast networking library

Getting Started

Read below for a step by step guide to installing Telegraph and getting your first app running. Some general information:

  1. Telegraph is available in the FreeSWITCH SVN.
  2. A demo app is also available in the FreeSWITCH SVN.
  3. Early and incomplete documentation is available here: http://code.google.com/p/telegraph

Step By Step Guide

  1. Install Ruby, Ruby on Rails and FreeSWITCH. Make sure each can run (with defaults).
  2. Make a new rails application
    $rails my_app_name
    and cd into the app directory.
  3. Install the telegraph rails plugin
     script/plugin install http://svn.freeswitch.org/svn/freeswitch/trunk/scripts/contrib/jpalley/telegraph/trunk 
  4. Edit the telegraph.yml file in your rails/config directory to point to the IP address of your FreeSWITCH (the port numbers should work by default, but you may need to confirm those also in the FS config).
  5. Edit your freeswitch vars file (by default at /usr/local/freeswitch/conf/vars.xml). You must insert the following global variable that points back to your rails application:
       <X-PRE-PROCESS cmd="set" data="rails_server=127.0.0.1:8084"/>
    Where 127.0.0.1 is the address your rails app will be accessible on.
  6. Comment out the request_from_forgery statement in the application.rb file in your rails app. (currently not supported by Telegraph)
  7. You are good to go. Check out the example or the following articles on Voice Models, Views and Events for more information:

Design Philosophy

Telegraph tries to bring the MVC goodiness of Rails to the Voice environment. There are three core components of Telegraph:

Component For the Web Developer For the Voice Developer
VoiceModel Allows you to perform CRUD operation on elements of your voice system. Anywhere ActiveRecord? is accessible, so are the voice models For example, for a channel (call) you can create it (call someone), find (get info on a specific call), update (record/etc.) and delete (hangup). Same with Conferences and SIP Profiles Provides a clean, Object Orientated abstraction wrapper around the FS XML-RPC interface (this is like a better version of AMI for Asterisk folks)
VoiceView Allows you to control what happens to a live “call” like you would control what happens to a web page. Bridge one channel to another, play sounds, put in queues, record, get dtmf input and so on. Provides abstraction layer around outbound event socket and allows you to separate business (controller) logic and view code.
VoiceEvents Allows you to respond to non-linear events thrown by voice server in the rails environment. Events like a user logging in, a call completing or hanging up and so on Provides easy access to inbound socket. You can “route” events to different code modules and easily access databases through the rails ORM magic.

About this entry