This document summarizes an interface that allows Ruby on Rails applications to integrate voice functionality using Asterisk or alternative platforms like Adhearsion and Telegraph. It provides examples of configuring these platforms and building voice interfaces in Rails applications to handle phone calls and integrate features like voicemail, phone menus, and retrieving data to read to callers. The document discusses considerations for voice user interfaces and demonstrates integrating voice response with existing Rails controllers and views.
1 of 48
More Related Content
Interface de Voz con Rails
1. RoR puede también hablar:
Interface de voz con Rails
Svet Ivantchev, eFaber
svet@efaber.net
22 de noviembre de 2007, ConferenciaRails 2007, Madrid
16. Ideas
• Respuesta diferente por horas
• Respuesta diferente en función del CallerID
• Integración con Jabber
• Voicemail
• IVR, colas
• 1000s de cosas mas ...
17. El dialplan se complica
[efmenu]
include => users5xx
include => rooms
include => efhq
exten => s,1,NoOp(Entering eF main menu for caller ${CALLERID})
exten => s,2,Answer
exten => s,3,Wait(2)
exten => s,4,Playback(beep)
exten => s,5,Background(${SALUDOEN}enter-ext-of-person)
exten => s,6,Background(beep)
exten => s,7,WaitExten(15)
exten => 101,1,Playback(room-service)
exten => 101,2,Goto(efmenu,s,4)
exten => 999,1,Goto(svetdisa,s,1)
exten => 999,2,Goto(efmenu,s,4)
exten => i,1,Playback(pbx-invalid)
exten => i,2,Goto(efmenu,s,6)
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup()
25. internal {
case extension
when 101...200
employee = User.find_by_extension extension
if employee.busy? then voicemail extension
else
dial employee, :for => 10.rings
voicemail unless last_call_successful?
end
when 888
play weather_report(quot;Dallas Texasquot;)
when 999 then +joker_voicemail
end
}
27. require 'amazon/search'
r = Amazon::Search::Request.new( '10N1KX1NVQZ2VXXXXXXX')
begin
resp = r.keyword_search( '0596529260', 'books' )
resp.products.each do |p|
unless p.availability =~ /not available/
printf( quot;%s (ASIN %s) -- %snquot;,
p.product_name, p.asin, p.our_price )
end
end
rescue
puts quot;No se encuentra.quot;
end
$ ruby price2
RESTful Web Services (ASIN 0596529260) -- $26.39
28. Adhearsion II: Amazon
adhearsion {
require 'amazon/search'
r = Amazon::Search::Request.new( '10N1KX1NVQZ2VXXXXXXX')
begin
resp = r.keyword_search( extension, 'books' )
resp.products.each do |p|
unless p.availability =~ /not available/
play p.our_price
end
end
rescue
play quot;no-info-about-numberquot;
end
}
31. voxbone {
sleep 2.seconds
play quot;hello-worldquot;
isbn = input()
require 'amazon/search'
r = Amazon::Search::Request.new( '10N1KX1NVQZ2VXXXXXXX')
begin
resp = r.keyword_search( isbn, 'books' )
resp.products.each do |p|
unless p.availability =~ /not available/
play p.our_price
end
end
rescue
play quot;no-info-about-numberquot;
end
}
33. Telegraph y AGI
exten => 105, 1, AGI(agi://127.0.0.1/my_route?param1=value)
wants.voice do
render_voice do |voice|
voice.play “hello-world”
voice.link_to_dtmf 'bank-lineitem-menu' do
link 1, :action=>quot;newquot;
link 2, :action=>quot;listquot;
link 3, :action=>quot;indexquot;
end
end
end
40. respond_to
def index
respond_to do |wants|
wants.html { render }
wants.voice { render_voice }
end
end
$ vi app/views/alumnos/index.voice
voice.play_sound quot;hello-worldquot;
41. index
# index.rhtml
<h1>Consultas</h1>
<ul>
<li> <%= link_to quot;Faltasquot;, :action=>quot;faltasquot; %> </li>
<li> <%= link_to quot;Notasquot;, :action=>quot;notasquot; %> </li>
</ul>
# index.voice
voice.play_sound 'thank-you-for-calling'
voice.link_to_dtmf 'presione1-2' do
link 1, :controller => quot;alumnosquot;, :action => quot;faltasquot;
link 2, :action => quot;notasquot;
end
42. formulario
# notas.rhtml
<h1>Consultar notas</h1>
<% form_tag '/alumnos/show_notas' do %>
DNI: <%= text_field_tag 'dni' %>
<%= submit_tag 'Ver notas' %>
<% end %>
# notas.voice
voice.form :url=>{:controller =>
'alumnos', :action=>'show_notas'} do |form|
form.numeric_input 'dni', 'dni', :max_digits=>8
end
43. resultados
# show_notas rhtml
<h3>Notas de <%= @alumno.nombre %></h3>
<table class=quot;listquot;>
<% @notas.each do |nota| %>
<tr>
<td class=quot;listquot;><%= nota.asignatura %></td>
<td class=quot;listquot;><%= nota.nota %></td>
</tr>
<% end %>
</table>
# show.voice
@notas.each do |nota|
voice.play nota.asignatura.to_slug
voice.play nota.nota
end
sleep 2.seconds
voice.play quot;vm-goodbyequot;
45. No hay que pasarse
• Web vs Mobile web vs Voz
• ej: 466453.com
46. Telegraph con AMI
$ script/generate ami_model AMIModel
# environment.rb (user y password en manager.conf):
Telegraph::AMIManager.establish_connection!(
:host=> 'your.host.name.com',
:username=>'user',
:secret=>'password')
$ script/ami_server
# usar así:
AMIModel.create(:call, :channel=>'SIP/101', :context=>'default',
:exten => 'outgoing', :priority=>1)