Created
June 12, 2013 11:56
-
-
Save RobSpectre/5764644 to your computer and use it in GitHub Desktop.
Call Queue That Calls Out To Agent For The First Caller. I *think* this works, but I'm not a Rubyist so may have some n00b gaffes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'sinatra' | |
| require 'twilio-ruby' | |
| # Endpoint for the call-in line that your customers call. | |
| post '/caller' do | |
| Twilio::TwiML::Response.new do |r| | |
| r.Enqueue 'Customer Queue', :waitUrl => '/wait' | |
| end.text | |
| end | |
| # Custom Wait Room that will dequeue the user if it is the first one to call the agent. | |
| post '/wait' do | |
| Twilio::TwiML::Response.new do |r| | |
| if params[:QueuePosition] == "1" | |
| r.Leave | |
| else | |
| r.Play "http://yourserver.com/yourmusic.mp3" | |
| end | |
| end.text | |
| end | |
| # Call the agent | |
| post '/callagent' do | |
| Twilio::TwiML::Response.new do |r| | |
| r.Dial do |d| | |
| r.Number "+15556667777" ### Your agent's number, could be dynamically generated. | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment