Building	
  real	
  life	
  applica/ons	
  
      with	
  Adhearsion	
  
                 Luca	
  Pradovera	
  
       Voice	
  Applica/on	
  Developer	
  at	
  
         Mojo	
  Lingo	
  –	
  Atlanta,	
  GA	
  
What	
  is	
  Adhearsion?	
  
•    Ruby	
  voice	
  applica/on	
  framework	
  
•    Provides	
  logic	
  for	
  telephony	
  apps	
  
•    Open	
  source	
  and	
  managed	
  by	
  a	
  Founda/on	
  
•    Version	
  2.1	
  released	
  on	
  08/08	
  
•    2.0	
  was	
  released	
  in	
  April	
  with	
  a	
  complete	
  
     overhaul	
  



                                LSRC	
  2012	
  –	
  Aus/n,	
  TX	
       2	
  
Supported	
  plaSorms	
  
•    Ruby	
  1.9,	
  Jruby	
  with	
  a	
  couple	
  issues	
  
•    Asterisk	
  
•    Voxeo	
  PRISM	
  
•    FreeSWITCH	
  in	
  2.1.0	
  
•    Rayo	
  protocol	
  allows	
  for	
  other	
  plaSorms	
  to	
  be	
  
     supported	
  



                               LSRC	
  2012	
  –	
  Aus/n,	
  TX	
        3	
  
An	
  Adhearsion	
  applica/on	
  
•    Configura/on	
  
•    Call	
  Controllers	
  
•    Rou/ng	
  
•    The	
  ahn	
  command:	
  create,	
  daemon,	
  start,	
  
     stop,	
  restart,	
  generate,	
  help,	
  version	
  




                             LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     4	
  
Call	
  Controllers	
  
•  Contain	
  the	
  logic	
  for	
  the	
  applica/on	
  
•  Have	
  a	
  #run	
  method	
  that	
  is	
  called	
  for	
  
   execu/on	
  
!
class SimpleController < Adhearsion::CallController!
  def run!
     answer!
     play "tt-weasels"!
     hangup!
  end!
end!


                                LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     5	
  
Rou/ng	
  
•  Matches	
  condi/ons	
  to	
  controllers	
  
•  Is	
  in	
  adhearsion.rb	
  together	
  with	
  the	
  config	
  
	
  
Adhearsion.router do!
  route 'Simple controller', SimpleController, :to => '1'!
  route 'Outbound Notification', Adhearsion::OutboundCall,
ConnectingController!
  route 'default', MenuController!
end!




                               LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     6	
  
Basics	
  
•    Output:	
  #play,	
  #say	
  
•    Input:	
  #ask	
  
•    Menu:	
  #menu	
  
•    Recording:	
  #record	
  
•    Logging	
  
•    DemoController	
  demo	
  



                           LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     7	
  
Plugins	
  
•  Provide	
  extra	
  func/onality	
  in	
  a	
  reusable	
  
   manner	
  
•  Packaged	
  as	
  gems	
  
•  Self-­‐documen/ng	
  configura/on	
  
•  “Just”	
  a	
  library	
  of	
  classes	
  
•  Expose	
  hooks	
  for	
  loading	
  and	
  star/ng	
  
•  The	
  adhearsion-­‐drb	
  plugin	
  

                             LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     8	
  
Integra/ng	
  with	
  other	
  apps	
  
•    Database	
  (Ac/ve	
  Record,	
  Sequel)	
  
•    HTTP/REST	
  
•    DRb	
  
•    Queue	
  systems	
  
•    Click	
  to	
  call	
  demo	
  




                            LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     9	
  
Events	
  
•    Are	
  exposed	
  through	
  guarded	
  handlers	
  
•    Handled	
  globally	
  or	
  per-­‐call	
  
•    Essen/al	
  for	
  building	
  complex	
  interac/ons	
  
•    Events	
  in	
  the	
  browser	
  demo	
  




                             LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     10	
  
Call	
  events	
  and	
  /mers	
  
•    The	
  main	
  object	
  you	
  work	
  with	
  is	
  a	
  Call	
  
•    Calls	
  have	
  specialized	
  handlers	
  
•    On_joined,	
  on_answer,	
  on_end	
  
•    Timers	
  allow	
  for	
  periodic	
  events	
  
•    BillingController	
  demo	
  




                                   LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     11	
  
Case	
  studies	
  
•    Adhearsion	
  is	
  used	
  in	
  produc/on	
  now	
  
•    Usage	
  covers	
  a	
  wide	
  range	
  of	
  applica/ons	
  
•    Testability,	
  integra/on,	
  modularity	
  
•    Built	
  for	
  the	
  developer	
  experience	
  




                               LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     12	
  
E-­‐Mediators	
  
•  Adhearsion	
  1.2	
  
•  Cultural	
  mediator	
  service	
  
•  Mul/lingual	
  menu	
  and	
  interface	
  
•  Complex	
  billing	
  with	
  rechargeable	
  accounts	
  
•  Web-­‐based	
  SIP	
  interface	
  with	
  Java	
  and	
  
   Websockets	
  
•  Mostly	
  SIP	
  based	
  

                          LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     13	
  
SOS	
  Travel	
  Card	
  
•  Transla/on	
  service	
  for	
  travelers	
  
•  Prepaid	
  cards	
  with	
  PIN	
  system	
  
•  Completely	
  manageable	
  through	
  IVR,	
  SMS,	
  
   and	
  Web	
  
•  Voicemail	
  handles	
  busy	
  situa/ons,	
  users	
  are	
  
   called	
  back	
  automa/cally	
  
•  Cellphone	
  based	
  and	
  operated	
  


                            LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     14	
  
VerbalizeIt	
  
•  Human	
  transla/on	
  service	
  
•  For	
  business	
  and	
  travelers	
  
•  Provides	
  over	
  the	
  phone	
  service,	
  a	
  mobile	
  
   app,	
  and	
  and	
  API	
  	
  
•  Also	
  offers	
  language	
  learning	
  sessions	
  




                             LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     15	
  
Mobile	
  operator	
  
•  “Inside	
  the	
  carrier”	
  deployment	
  
•  New	
  MVNO	
  opera/ng	
  in	
  North	
  America	
  
•  Ahn	
  operates	
  the	
  subscriber	
  database,	
  
   authen/ca/on,	
  billing	
  
•  All	
  call	
  rou/ng	
  
•  Voicemail	
  and	
  services	
  
•  In-­‐call	
  audio	
  using	
  early	
  media	
  to	
  provide	
  
   innova/ve	
  content	
  
                               LSRC	
  2012	
  –	
  Aus/n,	
  TX	
      16	
  
Thank	
  you!	
  
    Presented	
  by:	
  
   Luca	
  Pradovera	
  
             	
  
     @lucaprado	
  
  Github:	
  polysics	
  
hpp://adhearsion.com	
  
hpp://mojolingo.com	
  

       LSRC	
  2012	
  –	
  Aus/n,	
  TX	
     17	
  

Building Real Life Applications with Adhearsion

  • 1.
    Building  real  life  applica/ons   with  Adhearsion   Luca  Pradovera   Voice  Applica/on  Developer  at   Mojo  Lingo  –  Atlanta,  GA  
  • 2.
    What  is  Adhearsion?   •  Ruby  voice  applica/on  framework   •  Provides  logic  for  telephony  apps   •  Open  source  and  managed  by  a  Founda/on   •  Version  2.1  released  on  08/08   •  2.0  was  released  in  April  with  a  complete   overhaul   LSRC  2012  –  Aus/n,  TX   2  
  • 3.
    Supported  plaSorms   •  Ruby  1.9,  Jruby  with  a  couple  issues   •  Asterisk   •  Voxeo  PRISM   •  FreeSWITCH  in  2.1.0   •  Rayo  protocol  allows  for  other  plaSorms  to  be   supported   LSRC  2012  –  Aus/n,  TX   3  
  • 4.
    An  Adhearsion  applica/on   •  Configura/on   •  Call  Controllers   •  Rou/ng   •  The  ahn  command:  create,  daemon,  start,   stop,  restart,  generate,  help,  version   LSRC  2012  –  Aus/n,  TX   4  
  • 5.
    Call  Controllers   • Contain  the  logic  for  the  applica/on   •  Have  a  #run  method  that  is  called  for   execu/on   ! class SimpleController < Adhearsion::CallController! def run! answer! play "tt-weasels"! hangup! end! end! LSRC  2012  –  Aus/n,  TX   5  
  • 6.
    Rou/ng   •  Matches  condi/ons  to  controllers   •  Is  in  adhearsion.rb  together  with  the  config     Adhearsion.router do! route 'Simple controller', SimpleController, :to => '1'! route 'Outbound Notification', Adhearsion::OutboundCall, ConnectingController! route 'default', MenuController! end! LSRC  2012  –  Aus/n,  TX   6  
  • 7.
    Basics   •  Output:  #play,  #say   •  Input:  #ask   •  Menu:  #menu   •  Recording:  #record   •  Logging   •  DemoController  demo   LSRC  2012  –  Aus/n,  TX   7  
  • 8.
    Plugins   •  Provide  extra  func/onality  in  a  reusable   manner   •  Packaged  as  gems   •  Self-­‐documen/ng  configura/on   •  “Just”  a  library  of  classes   •  Expose  hooks  for  loading  and  star/ng   •  The  adhearsion-­‐drb  plugin   LSRC  2012  –  Aus/n,  TX   8  
  • 9.
    Integra/ng  with  other  apps   •  Database  (Ac/ve  Record,  Sequel)   •  HTTP/REST   •  DRb   •  Queue  systems   •  Click  to  call  demo   LSRC  2012  –  Aus/n,  TX   9  
  • 10.
    Events   •  Are  exposed  through  guarded  handlers   •  Handled  globally  or  per-­‐call   •  Essen/al  for  building  complex  interac/ons   •  Events  in  the  browser  demo   LSRC  2012  –  Aus/n,  TX   10  
  • 11.
    Call  events  and  /mers   •  The  main  object  you  work  with  is  a  Call   •  Calls  have  specialized  handlers   •  On_joined,  on_answer,  on_end   •  Timers  allow  for  periodic  events   •  BillingController  demo   LSRC  2012  –  Aus/n,  TX   11  
  • 12.
    Case  studies   •  Adhearsion  is  used  in  produc/on  now   •  Usage  covers  a  wide  range  of  applica/ons   •  Testability,  integra/on,  modularity   •  Built  for  the  developer  experience   LSRC  2012  –  Aus/n,  TX   12  
  • 13.
    E-­‐Mediators   •  Adhearsion  1.2   •  Cultural  mediator  service   •  Mul/lingual  menu  and  interface   •  Complex  billing  with  rechargeable  accounts   •  Web-­‐based  SIP  interface  with  Java  and   Websockets   •  Mostly  SIP  based   LSRC  2012  –  Aus/n,  TX   13  
  • 14.
    SOS  Travel  Card   •  Transla/on  service  for  travelers   •  Prepaid  cards  with  PIN  system   •  Completely  manageable  through  IVR,  SMS,   and  Web   •  Voicemail  handles  busy  situa/ons,  users  are   called  back  automa/cally   •  Cellphone  based  and  operated   LSRC  2012  –  Aus/n,  TX   14  
  • 15.
    VerbalizeIt   •  Human  transla/on  service   •  For  business  and  travelers   •  Provides  over  the  phone  service,  a  mobile   app,  and  and  API     •  Also  offers  language  learning  sessions   LSRC  2012  –  Aus/n,  TX   15  
  • 16.
    Mobile  operator   • “Inside  the  carrier”  deployment   •  New  MVNO  opera/ng  in  North  America   •  Ahn  operates  the  subscriber  database,   authen/ca/on,  billing   •  All  call  rou/ng   •  Voicemail  and  services   •  In-­‐call  audio  using  early  media  to  provide   innova/ve  content   LSRC  2012  –  Aus/n,  TX   16  
  • 17.
    Thank  you!   Presented  by:   Luca  Pradovera     @lucaprado   Github:  polysics   hpp://adhearsion.com   hpp://mojolingo.com   LSRC  2012  –  Aus/n,  TX   17