Skip to content

Instantly share code, notes, and snippets.

@t2-support-gists
Created September 14, 2012 18:08
Show Gist options
  • Save t2-support-gists/3723620 to your computer and use it in GitHub Desktop.
Save t2-support-gists/3723620 to your computer and use it in GitHub Desktop.
CMS Ruby RESTFul App 1
*******************************************************************************
* Licensed by AT&T under 'Software Development Kit Tools Agreement.'
*
* 2013 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION:
* http://developer.att.com/sdk_agreement/
*
* Copyright 2013 AT&T Intellectual Property. All rights reserved.
* http://developer.att.com
*
* For more information contact developer.support@att.com
*******************************************************************************
AT&T API Platform Sample Apps
--------------------------------------
This file describes how to set up, configure and run the Ruby sample
applications using the AT&T API Platform services. It covers all steps
required to register the applications on DevConnect as well as running the
sample applications locally.
1. Configuration
2. Installation
3. Parameters
4. Running the application
1. Configuration
Configuration consists of a few steps necessary to get an application
registered on DevConnect with the proper services and endpoints, depending on
the type of client-side application (autonomous/non-autonomous).
To register an application, go to https://devconnect-api.att.com/ and login
with your valid username and password. Next, choose "My Apps" from the bar at
the top of the page and click the "Setup a New Application" button.
Fill in the form, in particular all fields marked as "required".
Be careful while filling in the "OAuth Redirect URL" field. It should contain
the URL that the OAuth provider will redirect users to when he/she
successfully authenticates and authorizes your application. The oauth
redirect field must match the redirect specified in the app's config.yml
NOTE: You MUST select the Sample Applications name in the list of services
under field 'Services' in order to enable access to the cloud api.
After your application is registered you will receive an API and Secret key.
They are necessary for your registered applications to access the AT&T
Platform APIs. See 'Adjusting parameters' below to learn how to use these
keys in your applications.
Initially your newly registered application is restricted to the "Sandbox"
environment only. To move it to production, you may promote it by clicking
the "Promote to production" button. Notice that you will get a different API
key and secret, so these values in your application should be adjusted
accordingly.
Depending on the kind of authentication used, an application may be based on
either the Autonomous Client or the Web-Server Client OAuth flow; see:
https://devconnect-api.att.com/docs/oauth20/autonomous-client-application-oauth-flow
https://devconnect-api.att.com/docs/oauth20/web-server-client-application-oauth-flow
2. Installation
** Requirements
To run the examples you will need ruby 1.8+ and a few ruby gems that the
applications are built upon:
- sinatra: (http://www.sinatrarb.com/) used to construct a simple web
application and manage URLs within.
- sinatra-contrib: additional set of useful helpers, including ones used to
read settings from external files.
- rest-client: library for making restful calls
- json: used for encoding and decoding requests/responses
- att-codekit: library developed around the att cloud services (see below
to install)
- rake: compiling tool used to make att-codekit
- yard: documentation tool used by att-codekit
To install these gems open up a terminal window and invoke:
gem install sinatra sinatra-contrib rest-client json rake yard
On a *nix based system you may need to raise your access privliges, such as
prefixing the command with sudo or logging in as root by running su.
** Installing the att-codekit library
Note: required for ruby 1.9+ and suggested for 1.8
The code kit library can be installed by using our hosted gem file.
gem sources --add http://ldev.code-api-att.com:8808
gem install att-codekit
Note that the codekit is under heavy development and is using a semantic
versioning scheme. Non-backwards compatible changes _will_ increase the
major version number.
** Setting up on a different port number
In the case multiple applications need to be run at the same time, you need
to use different port numbers.
By default sinatra uses port number 4567; however only one running
application may use this port. In the case that you want to run more than one
sinatra-based application, you will need to update each applications' port
number (located in config.yml).
eg. application 1 - port: 4567, application 2 - port: 4568
The alternative is to set up your webserver to use a tool such as phusion
passenger. Setting up a webserver, however, is beyond the scope of this
article.
3. Parameters
Each application contains a config.yml file. It holds configurable parameters
described in the easy to read format YAML. You are free to adjust these to
your needs. If you introduce a change make sure to restart the application
for it to take effect.
The following are short descriptions of commonly used parameters:
REQUIRED -
1) FQDN : The main server handling requests, ex: https://api.att.com
2) api_key : set the value as per your registered application 'API
key' field value
3) secret_key : set the value as per your registered application
'Secret key' field value
OPTIONAL -
4) port : The port number which the application will run standalone
5) tokens_file : The path where the oauth token will be saved. This option
is only usable in client credential style authentication.
Must have write permissions.
Note: If your application is promoted from the Sandbox environment to
Production environment and you decide to use production application settings,
you must update api_key and secret_key as per production application details.
4. Running the application
To run the application, open up a terminal window in the application's
directory and type:
ruby (app name).rb
Where (app name) is replaced with the current directories app name.
Your application by default is accessible in a web browser at the url:
http://localhost:4567/
You may interrupt the application at any time by pressing ctrl-C.
******************************************************************************************
* Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2013
* TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/
* Copyright 2013 AT&T Intellectual Property. All rights reserved. http://developer.att.com
* For more information contact developer.support@att.com<mailto:developer.support@att.com>
******************************************************************************************
AT&T API Platform Samples - CMS app 1
------------------------------
This application demonstrates the usage of Call Management API of AT&T platform.
The application provides operations to support the creation of outgoing call session
and signals to existing sessions. Incoming call sessison will be created automatically
in the call environment.
This file describes how to set up, configure and run the Ruby applications using AT&T
API Platform services. It covers all steps required to register the application on DevConnect
and, based on the generated API keys and secrets, create and run one's own full-fledged sample applications.
1. Configuration
2. Installation
3. Parameters
4. Running the application
1. Configuration
Configuration consists of a few steps necessary to get an application registered on DevConnect with the proper
services and endpoints, depending on the type of client-side application (autonomous/non-autonomous).
To register an application, go to https://devconnect-api.att.com/ and login with your valid username and password.
Next, choose "My Apps" from the bar at the top of the page and click the "Setup a New Application" button.
Fill in the form, in particular all fields marked as "required".
Be careful while filling in the "OAuth Redirect URL" field. It should contain the URL that the oAuth provider will
redirect users to when he/she successfully authenticates and authorizes your application.
NOTE: You MUST select Call Management in the list of services under field 'Services' in order to use this sample
application code.
Having your application registered, you will get back an important pair of data: an API key and Secret key. They are
necessary to get your applications working with the AT&T Platform APIs. See 'Adjusting parameters' below to learn how
to use these keys.
Initially your newly registered application is restricted to the "Sandbox" environment only. To move it to production,
you may promote it by clicking the "Promote to production" button. Notice that you will get a different API key and secret,
so these values in your application should be adjusted accordingly.
Depending on the kind of authentication used, an application may be based on either the Autonomous Client or the Web-Server
Client OAuth flow (see https://devconnect-api.att.com/docs/oauth20/autonomous-client-application-oauth-flow or
https://devconnect-api.att.com/docs/oauth20/web-server-client-application-oauth-flow respectively).
2. Installation
** Requirements
To run the examples you need ruby 1.8+ and a few gems that the applications are heavily based on:
- sinatra (http://www.sinatrarb.com/)
used to construct a simple web application and manage URLs within.
- eventmachine
To ensure installation of the sinatra-contrib gem you must first install the gem eventmachine.
Sinatra-contrib has a dependency on eventmachine. EventMachine enables programs to easily
interface with other programs using TCP/IP, especially if custom protocols are required.
- sinatra-contrib
Additional set of useful helpers, including ones used to read settings from external files.
- Also make sure you have rest-client and json gems installed.
To install these gems open up a terminal window and invoke:
- gem install sinatra eventmachine sinatra-contrib rest-client json
If you are experiencing any additional difficulties installing gems, particularly sinatra-contrib,
it may prove useful to install the ruby gem thin. This can be installed in the terminal by invoking:
- gem install thin
Having them installed, you are almost ready to run the sample applications.
** Setting up on a different port number
In case multiple applications need to be run at the same time, you need to consider using different port numbers.
By default sinatra uses port number 4567 and only one running application may use this port. In case you want to run one
more sinatra-based application, you need to change its port number, eg. to 4568. This way you may have each application
running on a unique port.
3. Parameters
Each application contains a config.yml file. It holds configurable parameters
described in an easy to read YAML format which you are free to adjust to your needs. Following are short descriptions
of parameters used by this application:
1) FQDN : https://api.att.com
2) port : port number that application binds to (default: 4567)
3) api_key : set the value as per your registered application 'API key' field value
4) secret_key : set the value as per your registered application 'Secret key' field value
5) tokens_file : file containing authorization and refresh tokens
6) phoneNumber : set the phone number value as per the outbound session in Feature 1
Note: If your application is promoted from Sandbox environment to Production environment and you decide to use
production application settings, you must update parameters 1-2 as per production application details.
4. Running the application
To run the application, open up a terminal window and type:
ruby ./cms.rb
or
./cms.rb
Your application becomes available in a web browser, so you may visit: http://localhost:4567/ to see it working.
You may interrupt the application at any time by pressing ctrl-C.
# Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2012
# TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/
# Copyright 2012 AT&T Intellectual Property. All rights reserved. http://developer.att.com
# For more information contact developer.support@att.com
#!/usr/bin/ruby
require 'rubygems'
require 'json'
require 'rest_client'
require 'sinatra'
require 'open-uri'
require 'sinatra/config_file'
require File.join(File.dirname(__FILE__), 'common.rb')
enable :sessions
config_file 'config.yml'
set :port, settings.port
set :protection, :except => :frame_options
SCOPE = 'CCS'
# Obtain an OAuth access token if necessary.
['/CreateSession', '/SendSignal'].each do |path|
before path do
obtain_tokens(settings.FQDN, settings.api_key, settings.secret_key, SCOPE, settings.tokens_file)
end
end
# On start of application clear any session id value and read scripts.
get '/' do
clear_session_variables
read_script
erb :ccs
end
post '/CreateSession' do
read_script
if params[:btnCreateSession] != nil
numberScript = params[:txtNumberToDial]
if numberScript.empty?
read_script
@error = 'You must enter in a telephone number or sip address.'
return erb :ccs
else
read_script
create_session
return erb :ccs
end
else
erb :ccs
end
end
post '/SendSignal' do
if params[:scriptType].nil?
send_signal
read_script
return erb :ccs
else
read_script
return erb :ccs
end
end
def clear_session_variables
session[:txtNumberToDial] = nil
session[:txtMessageToPlay] = nil
session[:txtNumber] = nil
session[:ccs_id] = nil
end
# Function to get contents of selected script file.
def getContentsFromFile filetoread
return File.read Dir.pwd + '/' + filetoread
end
def read_script
# Populate Feature 1: Outbound voice/message Session text area with contents of Script.rb script.
@firstscript = 'First.rb'
@outbound = getContentsFromFile @firstscript
end
# Function to create session for outbound voice and messaging.
def create_session
# Script variables for First.rb.
numberToDial = session[:txtNumberToDial] = params[:txtNumberToDial]
messageToPlay = session[:txtMessageToPlay] = params[:txtMessageToPlay]
numberVar = session[:txtNumber] = params[:txtNumber]
scriptType = session[:scriptType] = params[:scriptType]
# Pass the script variable for First.rb in request body.
requestbody = '{"feature":"' + scriptType + '","messageToPlay":"' + messageToPlay + '","numberToDial":"' + numberToDial.to_s + '","featurenumber":"' + numberVar.to_s + '"}'
# Resource URL for Create Session.
url = "#{settings.FQDN}/rest/1/Sessions"
RestClient.post url, "#{requestbody}", :Authorization => "Bearer #{@access_token}", :Content_Type => 'application/json', :Accept => 'application/json' do |response, request, result, &block|
@r = response
end
if @r.code == 200
@result = JSON.parse @r
session[:ccs_id] = @result['id']
else
@error = @r
end
end
# Function which sends signal to either exit, hold or dequeue session.
def send_signal
# Resource URL for Send Signal.
url = "#{settings.FQDN}/rest/1/Sessions/#{session[:ccs_id]}/Signals"
# Pass the signal paramater in request body.
requestBody = '{"signal":"' + params[:signal] + '"}'
response = RestClient.post url, "#{requestBody}", :Authorization => "Bearer #{@access_token}",
:Content_Type => 'application/json', :Accept => 'application/json'
@signal_result = JSON.parse response
rescue => e
@signal_error = e.message
ensure
return erb :ccs
end
#!/usr/bin/env ruby
# Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2013 TERMS
# AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION:
# http://developer.att.com/sdk_agreement/ Copyright 2013 AT&T Intellectual
# Property. All rights reserved. http://developer.att.com For more information
# contact developer.support@att.com
require 'rubygems'
require 'sinatra'
require 'open-uri'
require 'sinatra/config_file'
require 'cgi'
require 'att/codekit'
include Att::Codekit
enable :sessions
config_file 'config.yml'
set :port, settings.port
set :protection, :except => :frame_options
SCOPE = 'CMS'
#An array of all the methods our script supports
SCRIPT_METHODS = settings.script_methods.split(",")
#Set the proxy that's used in att/codekit
RestClient.proxy = settings.proxy
#setup our oauth service
configure do
begin
FILE_SUPPORT = (settings.tokens_file && !settings.tokens_file.strip.empty?)
FILE_EXISTS = FILE_SUPPORT && File.file?(settings.tokens_file)
OAuth = Auth::ClientCred.new(settings.FQDN,
settings.api_key,
settings.secret_key)
if FILE_EXISTS
@@token = Auth::OAuthToken.load(settings.tokens_file)
else
@@token = OAuth.createToken(SCOPE)
end
Auth::OAuthToken.save(settings.tokens_file, @@token) if FILE_SUPPORT
rescue Exception => e
@error = e.message
end
end
#load our file for display before anything
before do
read_script
begin
if @@token.expired?
@@token = OAuth.refreshToken(@@token)
Auth::OAuthToken.save(settings.tokens_file, @@token) if FILE_SUPPORT
end
rescue Exception => e
@error = e.message
end
end
# On start of application clear any session id value and read scripts.
get '/' do
clear_session_variables
erb :cms
end
post '/CreateSession' do
begin
create_session unless params[:btnCreateSession].nil?
rescue Exception => e
@error = e.message
end
erb :cms
end
post '/SendSignal' do
begin
service = Service::CMSService.new(settings.FQDN, @@token)
if params[:scriptType].nil?
@signal_result = service.sendSignal(session[:cms_id], params[:signal])
end
rescue Exception => e
@signal_error = e.message
end
erb :cms
end
def clear_session_variables
session[:txtNumberToDial] = nil
session[:txtMessageToPlay] = nil
session[:txtNumber] = nil
session[:cms_id] = nil
end
# Function to get contents of selected script file.
def getContentsFromFile filetoread
return File.read(Dir.pwd + '/' + filetoread)
end
def read_script
# Populate Feature 1: Outbound voice/message Session text area with contents of Script.rb script.
@firstscript = 'First.rb'
@outbound = getContentsFromFile @firstscript
end
# Function to create session for outbound voice and messaging.
def create_session
# Script variables for First.rb.
numberToDial = session[:txtNumberToDial] = CGI.escapeHTML(params[:txtNumberToDial])
messageToPlay = session[:txtMessageToPlay] = CGI.escapeHTML(params[:txtMessageToPlay])
numberVar = session[:txtNumber] = CGI.escapeHTML(params[:txtNumber])
scriptType = session[:scriptType] = CGI.escapeHTML(params[:scriptType])
# Pass the script variable for First.rb in request body.
requestbody = {
'feature' => scriptType,
'messageToPlay' => messageToPlay,
'numberToDial' => numberToDial.to_s,
'featurenumber' => numberVar.to_s,
'smsCallerID' => settings.phoneNumber.to_s,
}
begin
service = Service::CMSService.new(settings.FQDN, @@token)
@result = service.create_session(requestbody)
session[:cms_id] = @result.id
rescue Exception => e
@error = e.message
end
end
# Makes sure that valid access_token is stored in the session. Retrieves new tokens if needed.
def obtain_tokens(fqdn, client_id, client_secret, scope, tokens_file)
read_tokens(tokens_file)
response = RestClient.post "#{fqdn}/oauth/token", :grant_type => 'client_credentials', :client_id => client_id, :client_secret => client_secret, :scope => scope
from_json = JSON.parse(response.to_str)
@access_token = from_json['access_token']
@refresh_token = from_json['refresh_token']
write_tokens(tokens_file)
end
def write_tokens(tokens_file)
File.open(tokens_file, 'w+') { |f| f.puts @access_token, @refresh_token }
end
def read_tokens(tokens_file)
@access_token, @refresh_token, refresh_expiration = File.foreach(tokens_file).first(2).map! &:strip!
rescue
return
end
port: 50100
proxy:
api_key: 79e76414c689f681ca1e263cbab3761d
secret_key: 9d31e6b02582bfcf
tokens_file: tokens
FQDN: https://api.att.com
phoneNumber: +114153401646
script_methods: ,ask,conference,message,reject,transfer,wait
source_link: https://gist.github.com/3723620
download_link: https://github.com/attdevsupport/ATT_APIPlatform_SampleApps/tree/master/RESTFul/CMS/Ruby/app1
help_link: https://raw.github.com/attdevsupport/ATT_APIPlatform_SampleApps/master/RESTFul/CMS/Ruby/app1/README.txt
# Utility method for saying individual characters in a string
sayNumber = lambda { |text|
if text.nil? then
say "Please enter a valid number"
else
text.split("").each do |c|
say c
end
end
}
messageToPlay = "http://wdev.code-api-att.com:8181/Tropo/music.mp3"
if (defined? $numberToDial).nil?
say "Welcome to the A T and T Call Management sample application demo."
smsResult = ask("Please enter a ten digit number to send an S M S to, or press pound to skip",
{
:choices => "[10 DIGITS]",
:terminator => "#",
:timeout => 10.0,
:mode => "dtmf",
:interdigitTimeout => 10.0,
:onChoice => lambda { |event|
say "Sending sms to "
}
})
if smsResult.value != "" then
number = smsResult.value
sayNumber.call number
message("Message from AT&T Call Control Sample Application",
{
:to => number,
:network => "SMS",
:callerID => $currentCall.calledID
})
end
result20 = ask("Press a digit to listen to what you press or press pound to skip.",
{
:choices => "[1 DIGITS]",
:terminator => "#",
:timeout => 5.0,
:mode => "dtmf",
:interdigitTimeout => 5,
:onChoice => lambda { |event|
say "Thank you for entering"
},
:onBadChoice => lambda { |event|
say "Sorry, I am not able to get the digit."
}
})
say result20.value unless result20.value.nil?
result21 = ask("Press a digit to join 1337 conferencing or press pound to skip.",
{
:choices => "[1 DIGITS]",
:terminator => "#",
:timeout => 5.0,
:mode => "dtmf",
:interdigitTimeout => 5,
:onChoice => lambda { |event|
say "Thank you for joining 1337 conferencing. To quit, press star at any time."
conference("1337",
{
:terminator => "*",
:playTones => true,
:onChoice => lambda { |event|
say "Disconnecting from conference."
}
})
}
}
)
result24 = ask("Enter a ten digit phone number from which you are calling to reject this call or press pound to skip.",
{
:choices => "[10 DIGITS]",
:terminator => '#',
:timeout => 120.0,
:mode => "dtmf",
:interdigitTimeout => 10,
:onChoice => lambda { |event| }
}
)
if result24.value != ""
numbertest = result24.value
strippedCID = $currentCall.callerID[2..-1]
if strippedCID .eql? numbertest
say "Your calls will be rejected."
say "Thank you for using A T and T Call Management sample application demo. Goodbye."
reject
else
say "Number not matched for reject feature."
say "The current caller I D is "
sayNumber.call strippedCID
say " and the number you entered is"
sayNumber.call numbertest
end
end
result25 = ask("Enter a 10 digit phone number to transfer the call or press pound to skip.",
{
:choices => "[10 DIGITS]",
:terminator => "#",
:timeout => 120.0,
:mode => "dtmf",
:interdigitTimeout => 10,
:onChoice => lambda { |event|
}
})
if result25.value != ""
numbertest = result25.value
transfernumb = "+1" + numbertest
say "Transfering to "
sayNumber.call numbertest
transfer(transfernumb,
{
:playvalue => messageToPlay,
:terminator => "*",
:onCallFailure => lambda { |event|
say "Unable to transfer. Call failed."
},
:onTimeout => lambda { |event|
say "Unable to transfer. Nobody answered."
}
}
)
end
result27 = ask("Enter the ten digit phone number from which you are calling to wait this call or press pound to skip.",
{
:choices => "[10 DIGITS]",
:terminator => "#",
:timeout => 120.0,
:mode => "dtmf",
:interdigitTimeout => 10,
:onChoice => lambda { |event|
}
})
if result27.value != ""
numbertest = result27.value
strippedCID = $currentCall.callerID[2..-1]
if strippedCID .eql? numbertest
say "Entered number matched with current caller I D."
say "Will now set the call to wait three seconds."
wait(3000)
else
say "Number not matched for wait feature."
say "The current caller I D is "
sat " and the number you entered is"
sayNumber.call numbertest
end
end
result29 = ask("Press a digit to test the signaling or press pound to skip.",
{
:choices => "[1 DIGITS]",
:terminator => "#",
:timeout => 5.0,
:mode => "dtmf",
:interdigitTimeout => 5,
:onChoice => lambda { |event|
say "Waiting for exit signal"
say(messageToPlay,
{
:allowSignals => "exit",
:onSignal => lambda { |event1|
say "Received exit signal, hence the music is paused. Enjoy the music again."
}
})
say "Waiting for stopHold signal"
say(messageToPlay,
{
:allowSignals => "stopHold",
:onSignal => lambda { |event2|
say "Received stop hold signal, hence the music is paused. Enjoy the music again."
}
})
say "Waiting for deueue signal"
say(messageToPlay,
{
:allowSignals => "dequeue",
:onSignal => lambda { |event3|
say "Received dequeue signal, hence the music is stopped."
}
})
}
})
say "Thank you for using A T and T Call Management sample application demo. Goodbye."
hangup
else
call $numberToDial
say "Welcome to the A T and T Call Management sample application demo."
case $feature
when "ask"
say "The ask feature has been selected."
result9 = ask("Press four or five digits and press pound when finished.",
{
:choices => "[4-5 DIGITS]",
:terminator => "#",
:timeout => 90.0,
:mode => "dtmf",
:interdigitTimeout => 5,
:onChoice => lambda { |event|
say "Thank you for entering"
},
:onBadChoice => lambda { |event|
say "Sorry, I am not able to get the four or five digits you pressed."
}
}
)
if result9.value != ""
sayNumber.call result9.value
end
when "conference"
say "Thank you for joining 1337 conferencing. To quit, press star at any time."
conference("1337",
{
:terminator => "*",
:playTones => true,
:onChoice => lambda { |event|
say "Disconnecting from conference."
}
}
)
when "reject"
callID = $currentCall.callerID
if callID .eql? $featurenumber
say "Your calls will be rejected."
say "Thank you for using A T and T Call Management application demo. Goodbye."
reject
hangup
else
say "Number not matched for reject feature."
say "The present number is"
sayNumber.call callID
say "and requested number is"
sayNumber.call $featurenumber
end
when "message"
if $featurenumber.nil?
say "Please enter a number to send a message to and try again."
else
say "Sending message to"
sayNumber.call $featurenumber
say "from caller I D"
sayNumber.call $smsCallerID
message("Message from AT&T Call Control Service Sample Application", {
:to => $featurenumber,
:network => 'SMS',
:callerID => $smsCallerID
})
end
when "transfer"
say "Transfering to"
sayNumber.call $featurenumber
transfer($featurenumber,
{
:playvalue => messageToPlay,
:terminator => "*",
:onCallFailure => lambda { |event|
say "Unable to transfer. Call failed."
},
:onTimeout => lambda { |event|
say "Unable to transfer. Nobody answered."
}
}
)
when "wait"
callID = $currentCall.callerID
if callID .eql? $featurenumber
say "Present number matched with requested number."
say "Will now set the call to wait three seconds."
wait(3000)
else
say "Number not matched for wait feature."
say "The present number is"
sayNumber.call callID
say "and the requested number is"
sayNumber.call $featurenumber
end
end
result4 = ask("Press a digit to test the signaling or press pound to skip.",
{
:choices => "[1 DIGITS]",
:terminator => "#",
:timeout => 5.0,
:mode => "dtmf",
:interdigitTimeout => 5,
:onChoice => lambda { |event|
say "Waiting for exit signal"
say(messageToPlay,
{
:allowSignals => "exit",
:onSignal => lambda { |event1|
say "Received exit signal, hence the music is paused. Enjoy the music again."
}
})
say "Waiting for stopHold signal"
say(messageToPlay,
{
:allowSignals => "stopHold",
:onSignal => lambda { |event2|
say "Received stop hold signal, hence the music is paused. Enjoy the music again."
}
})
say "Waiting for dequeue signal"
say(messageToPlay,
{
:allowSignals => "dequeue",
:onSignal => lambda { |event3|
say "Received dequeue signal, hence the music is stopped."
}
})
}
})
say "Thank you for using the A T and T Call Management sample application demo. Goodbye."
hangup
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment