- # This script is called via HTTP.
- # This is to demo Tropo conferencing functionality (via hosted script).
- # Set up call options and conference options.
- callOptions = { :channel => "VOICE",
- :answerOnMedia => false,
- :timeout => 30.0,
- :callerID => "6502976707"
- }
- conferenceOptions = { :joinPrompt => "You are connecting.",
- :terminator => "*",
- :leavePrompt => "We hope you enjoyed your call!"
- }
- # Method to create timeStamp as our conferenceID.
- def get_conference_id()
- timeVar = Time.new
- returnValue = timeVar.strftime("%Y%H%M%S")
- return returnValue
- end
- # Before any calls, create conference ID and log it.
- conferenceID = get_conference_id()
- log "@"*20 + ": " + conferenceID
- # Make an outbound call to BANDMEMBER with call options.
- event = call 'tel:+1' + $bandmemberNumberToDial, callOptions
- if event.name == 'answer'
- log 'Outgoing call gets answered by ' + event.value.calledID
- # Ask BANDMEMBER if they want to talk to a fan now.
- wait(2000)
- say("<prosody rate='-40%'>This is band call calling with a lucky fan connection! Would you like to connect to your fan now?</prosody>",{:voice => "allison"})
- choiceOptions = { :choices => 'yes( 1, yes), no( 2, no)',
- :repeat => 3 }
- result = ask 'To connect, just say yes! or press 1. For no, just say no, or press 2.', choiceOptions
- if result.name == 'choice'
- case result.value
- when 'yes'
- say ('OK, we are connecting you with a fan right now. The fans name is' + $fanName + ', Please hold while we connect your call. You can press star at any time to disconnect.')
- conference(conferenceID, conferenceOptions)
- #Create new thread and make outbound call to FAN with call options.
- Thread.new do
- event = call 'tel:+1' + $fanNumberToDial, callOptions
- if event.name == 'answer'
- wait(2000)
- say('This is band call calling with a lucky fan connection!' + $bandmemberName + 'from the band, the hackers!, is calling you now! Would you like to connect to your band right now?',{:voice => "allison"})
- choiceOptions = { :choices => 'yes( 1, yes), no( 2, no)', :repeat => 3 }
- result = ask 'To connect, just say yes! or press 1. For no, just say no, or press 2.', choiceOptions
- if result.name == 'choice'
- case result.value
- when 'yes'
- say ('OK, we are connecting you right now!')
- # Create conference (with 1st Thread)
- log "@"*5 + " Start Conference ID: " + conferenceID
- conference(conferenceID, conferenceOptions)
- when 'no'
- say ('OK, Sorry we missed you. Goodbye.')
- hangup
- end
- end
- end
- end
- when 'no'
- say ('OK, We will try again later. Goodbye.')
- hangup
- end
- end
- end