respond_to :voice The Convergence of Web and Voice Interfaces with Rails and Asterisk or An introduction to Telegraph - Voice done MVC Jonathan Palley Co-Founder, Idapted Inc. [email protected]
Jun 27, 2015
respond_to :voice
The Convergence of Web and Voice Interfaces with Rails and Asterisk
or
An introduction to Telegraph - Voice done MVC
Jonathan PalleyCo-Founder, Idapted Inc.
VoIP Development Is NOT about cheaper phone calls
Already done and telcos can do cheaper...
It’s about the applications.
Voice is Another Interface for Your Application
The Plan
• Voice as the next Killer Interface
• The Voice/Web Analogy
• Asterisk in 5 minutes
• Telegraph - Bridging Voice and Rails
Why add voice? Why now?
Only Recently Available
Ripe for Innovation
Ubiquitous
• DB Driven applications (Rails/etc.)
• Phone system (VoIP/OSS PBX)
Lowered Barriers to Voice App Development
Space To Innovate
• Existing Voice Design Thinking = Phone Prompt Hell
• Few applications merge voice and web. Most users do.
• Underlying OSS Servers/Technology Available
Ubiquity
• 2.7 Billion mobile phones. 1.4 Billion fixed-lines.
• 1/3 of “Internet Users” access the internet from their mobile phone.
• Each of those 4.1 billion users can be uniquely identified by a standardized numerical system
Source: http://communities-dominate.blogs.com/brands/2007/02/mobile_the_7th_.html
Technology Web VoIP
Protocol
HTTPFTPRTPetc
SIP - Ind. StandardIAX - Asterisk onlyH.323 - Obsolete
Jingle - GtalkSkype - Proprietary
Codecgzip
jpg/gif/etc.wmv/rm/etc
g.711 - high bandwidthgsm - medium bandwidth
g.729 - low bandwidthiLBC - low bandwidth
Server apache/lighttpd asterisk
Interactivity CGI AGIAMI
The Voice/Web Analogy: Technology
• OSS Multipurpose PBX
• Very powerful/flexible
• Relatively Stable
• Very messy to deal with
Asterisk: The 5min Tutorial
Concept Explanation
Channel A “Channel” in Asterisk is what can setup/receive calls
Dialplan
Determines what to do with call. Given a call and a dialed number, what sounds should be played, input
received or connections made? Written in a “BASIC like language.
AGI Stdin/out or TCP method that allows external applications to dynamically write dialplans
AMI Method to send commands to Asterisk (independent of calls) and listen for stateful events
Asterisk: Key Concepts
Asterisk Server
PSTN Network
Origination/Termination
Server
SIP/IAX Rails/Telegraph
Server
AGI/AMI
VoIP Clients
SIP/IAX
AnalogInterface
Cards
Zaptel/OtherPSTN Phones/Network
Voice System Setup
Existing Ruby/Asterisk Integration Tools
RAGIJust for AGI.
Not well integrated into railsNot active.
RAMIAMI.
No Rails Integration.Not Active.
AdhearsionActive. Real Apps?
Good for writing pure voice appsNot tied to Rails or concept of shared voice/web
interfaces.
Introducing Telegraph
• Extracted from Real Application (Idapted’s distributed voice system for oral language training - EnglishQuad) with input of others.
• Started with RAGI/RAMI
• Tightly Integrated with Rails/Web Interfaces.
• Embraces the Voice/Web analogy.
Telegraph 1: Making Interfaces (AGI)
• Setup Dialplan
exten => 1, 1, AGI(agi://localhost/my_route?param1=value)
• Add respond_to and voice DSL.
wants.voice do render_voice do |voice| voice.play “hello-world” voice.link_to_dtmf 'bank-lineitem-menu' do link 1, :action=>"new" link 2, :action=>"list" link 3, :action=>"index" end endend
Demo I: Adding Voice Interface to Standard Scaffolding Application.
Look at account controller in demo app. Description/docs attelegraph.rubyforge.org
Sessions can be shared between voice and web. Making it easy to link
voice and web actions
Demo II: Phone Number Confirmation
Look at verify_number controller in demo app. Description/docs attelegraph.rubyforge.org
Telegraph II: Manipulating the System (AMI)(follows CRUD)
Create CallsRecordings
ReadCall/Channel/Queue Status
VariablesMailbox
UpdateContext
RecordingVariable
Delete Call (Hangup)Recording
Telegraph II: Deal with system info
• Create a model-like class:
class VoiceConnection < Telegraph::AsteriskManager
end
• Use CRUD technique’s to get Asterisk parameters, place calls, etc. Examples:
VoiceConnection.create(:call, :channel=>”SIP/dave”, :context=>”some_context”, :exten=>3)
VoiceConnection.destroy(:call, :channel=>my_channel)
VoiceConnection.find(:sip_peer, :peer=>”SIP/joe”)
VoiceConnection.update(:monitor, :channel=>my_channel, :file=>new_file)
Demo III: Placing a call and getting channel status
Look at dialer controller in demo app. Description/docs attelegraph.rubyforge.org
Telegraph III: Dealing with stateful events
• Add a special AMILogic class to your project
• Add methods to deal with events, use params to access info sent by asterisk.
• For example
class AmiLogic < Telegraph::AMIHandler
def link
puts "Linked #{params[:channel1]} to #{params[:channel2]}"
end
end
Look at documentation on AMI Events at telegraph.rubyforge.orgfor Examples
• AGI and AMI Events handled by independent rails processes that can be load balanced.
• AMI runs through distributed Ruby process.
• Deployment/daemonization very easy. Like mongrel, works with Capistrano
Easy Deployment/Scaling
Thanks To Rabble and John Shulty for their contributions to the source.
Contact Me:Jonathan Palley
[email protected]: jpalley, gizmo: jonathanpalley
idapted.com || englishquad.com
telegraph.rubyforge.orgtalkingruby.org
Questions/Discussion
Appendix: The Voice/Web Analogy: Interfaces
Concept Web Voice
Interacting with system Web Browser IVR Like Systems
Get/set info system Database/Models DB + Voice Connection Parameters
Handling Stateful Events -Handling connections/
disconnections/registrations