Skip to content

Instantly share code, notes, and snippets.

@howethomas
Created August 21, 2009 18:57
Show Gist options
  • Save howethomas/172325 to your computer and use it in GitHub Desktop.
Save howethomas/172325 to your computer and use it in GitHub Desktop.
# -----------
# connecting the call to another number ()
# -----------
answer
log "Inbound call answered at #{Time.now}"
wait 2000
result = record "Hello. Thanks for calling. Leave your message at the beep.",
{ :beep => true, :timeout => 10, :silenceTimeout => 7, :maxTime => 10 }
if( result.name=='record' )
## record returns a URI pointing to the recorded audio...
log "result.recordURI = " + result.recordURI
## we can then use that URI in a say command to play the recorded audio back...
say "you said " + result.recordURI
recordURI = result.recordURI
end
hangup
$currentCall = nil
# If this script is called via HTTP, the initial "answer();" can be
# removed.
options = { :answerOnMedia => false,
:callerID => '+15083750743',
:timeout => 12.123,
:onAnswer => lambda { |event| log '******************** Answered from ' + event.inspect.to_s },
:onError => lambda { |event| log '******************** oops , error*********************' + event.inspect.to_s },
:onTimeout => lambda { |event| log '******************** timeout *********************' + event.inspect.to_s },
:onCallFailure => lambda { |event| log '******************** call failed *********************' + event.inspect.to_s }
}
event = call "tel:+15088153428", options
if event.name == 'answer'
log 'Outgoing call gets answered by ' + event.value.calledID
log recordURI
say "you said " + recordURI
end
hangup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment