Skip to content

Instantly share code, notes, and snippets.

@rwjblue
Created November 14, 2012 05:43
Show Gist options
  • Save rwjblue/4070523 to your computer and use it in GitHub Desktop.
Save rwjblue/4070523 to your computer and use it in GitHub Desktop.
Automated Dialier with Machine Detection using Tropo.
require 'restclient'
RestClient.get 'https://api.tropo.com/1.0/sessions', {:params => {
:action => 'create',
:token => 'YOUR TROPO TOKEN HERE',
:number => "13525557567",
:client_name => "Joe Bob's Anesthesia",
:account_number => '539181',
:first_name => 'Robert',
:balance => 1345.12,
:callback_number => "3525558898"}}
def human_answered?
starttime = Time.new
record ".", {
:beep => false,
:timeout => 10,
:silenceTimeout => 1,
:maxTime => 10
}
endtime = Time.now
difference = endtime - starttime
difference < 3
end
call '+' + $number, {
:callerID => $callback_number
}
human = human_answered?
say "This is #{$client_name}. We are trying to reach #{$first_name}, regarding your outstanding balance of, $#{$balance}; on account number #{$account_number}."
if human
result = ask "Please press 1 to make a payment via our automated gateway. Please press 2 to speak to a representative.", {
:choices => "1, 2",
:mode => 'dtmf',
:timeout => 10,
:attempts => 2}
if result.value == "1"
say 'entered 1. should transfer to payment processing here.'
else
say 'entered 2. should transfer to live agent here.'
end
else
say "Please call us back at #{$callback_number} and reference account number #{$account_number}."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment