Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 3.00 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # This script is called via HTTP.
  2. # This is to demo Tropo conferencing functionality (via hosted script).
  3.  
  4. # Set up call options and conference options.
  5.  
  6. callOptions = { :channel => "VOICE",
  7.                 :answerOnMedia => false,
  8.                 :timeout => 30.0,
  9.                 :callerID => "6502976707"
  10.               }
  11.  
  12. conferenceOptions = { :joinPrompt => "You are connecting.",
  13.                       :terminator => "*",
  14.                       :leavePrompt => "We hope you enjoyed your call!"
  15.                     }
  16.  
  17. # Method to create timeStamp as our conferenceID.
  18.  
  19. def get_conference_id()
  20.   timeVar  = Time.new
  21.   returnValue = timeVar.strftime("%Y%H%M%S")
  22.   return returnValue
  23. end
  24.  
  25. # Before any calls, create conference ID and log it.
  26. conferenceID = get_conference_id()
  27. log "@"*20 + ": " + conferenceID
  28.  
  29. # Make an outbound call to BANDMEMBER with call options.
  30. event = call 'tel:+1' + $bandmemberNumberToDial, callOptions
  31.  
  32. if event.name == 'answer'
  33.   log 'Outgoing call gets answered by ' + event.value.calledID
  34.  
  35.   # Ask BANDMEMBER if they want to talk to a fan now.
  36.   wait(2000)
  37.   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"})
  38.  
  39.   choiceOptions = { :choices => 'yes( 1, yes), no( 2, no)',
  40.                     :repeat  => 3 }
  41.  
  42.   result = ask 'To connect, just say yes! or press 1. For no, just say no, or press 2.', choiceOptions
  43.  
  44.   if result.name == 'choice'
  45.     case result.value
  46.      when 'yes'
  47.        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.')
  48.        conference(conferenceID, conferenceOptions)
  49.  
  50.        #Create new thread and make outbound call to FAN with call options.
  51.        Thread.new do
  52.          event = call 'tel:+1' + $fanNumberToDial, callOptions
  53.  
  54.          if event.name == 'answer'
  55.          wait(2000)
  56.          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"})
  57.  
  58.            choiceOptions = { :choices => 'yes( 1, yes), no( 2, no)', :repeat  => 3 }
  59.  
  60.            result = ask 'To connect, just say yes! or press 1. For no, just say no, or press 2.', choiceOptions
  61.  
  62.            if result.name == 'choice'
  63.              case result.value
  64.                when 'yes'
  65.                  say ('OK, we are connecting you right now!')
  66.  
  67.                  # Create conference (with 1st Thread)
  68.                  log "@"*5 + " Start Conference ID: " + conferenceID
  69.                  conference(conferenceID, conferenceOptions)
  70.  
  71.                when 'no'
  72.                  say ('OK, Sorry we missed you. Goodbye.')
  73.                  hangup
  74.              end
  75.            end
  76.          end
  77.        end
  78.  
  79.       when 'no'
  80.         say ('OK, We will try again later. Goodbye.')
  81.         hangup
  82.  
  83.     end
  84.   end
  85. end