Skip to content

Instantly share code, notes, and snippets.

@dougiebuckets
Created October 30, 2012 16:18
Show Gist options
  • Save dougiebuckets/3981266 to your computer and use it in GitHub Desktop.
Save dougiebuckets/3981266 to your computer and use it in GitHub Desktop.
Interactive Voice Response
class CallsController < ApplicationController
def ivr
xml = Telapi::InboundXml.new do # TelAPI inbound XML document
# Gather is used to obtain the digits callers submit in response to their IVR selection optioners options
Gather(
# URL where the gathered digits will be sent for further processing
:action => "http://ivrdemo.com/ivr-user-response.rb",
# HTTP method used to request the action URL
:method => "GET",
# The maximum number of digits that will be gathered
:numDigits => "1",
# The key a caller can press to finish the gather
:finishOnKey => "#",
# The number of seconds <Gather> should wait for digits to be entered before requesting the action URL
:timeout => "10")
{
# The following Say elements are used to present the caller with the menu selection items
Say("If you would like assistance regarding service offering A, press 1.",
:voice => 'man')
Say("If you would like assistance regarding service offering B, press 2.",
:voice => 'man')
Say("If you would like assistance regarding service offering c, press 3.",
:voice => 'man')
}
end
# Ruby used to generate an XML response
respond_to do |format|
format.xml { render :xml => xml.response }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment