Skip to content

Instantly share code, notes, and snippets.

@pius
Created September 25, 2008 13:49
Show Gist options
  • Save pius/12819 to your computer and use it in GitHub Desktop.
Save pius/12819 to your computer and use it in GitHub Desktop.
require '../lib/client'
default {
ahn_log.dialplan.info "opened default context"
@client = Caitlin::Client.new('http://localhost:4647')
@num = @client.list.size
say_digits @num.to_i
@questions = [{:opening_id => 1, :respondent_id => 2}, {:opening_id => 1, :respondent_id => 3}, {:opening_id => 1, :respondent_id => 7}]
ahn_log.dialplan.info "Telling #{callerid} that there are #{@num} openings in the database right now."
ahn_log.dialplan.info "Executing the initial menu"
menu 'welcome', :timeout => 8.seconds, :tries => 3 do |link|
link.review_questions(@questions) 1
link.learn_about_other_openings 2
link.post_your_own_opening 3
link.on_invalid { play 'invalid' }
link.on_premature_timeout do |str|
play 'sorry'
end
link.on_failure do
play 'goodbye'
hangup
end
end
}
review_questions { |questions|
puts "Telling #{callerid} that he or she has N questions to manage."
# iterate through questions and, after each, give user a menu for accepting or rejecting
questions.each {|question|
describe_question(question)
}
}
learn_about_other_openings {
say_digits 123456789
}
post_your_own_opening {}
accept_question { #|question|
puts "inside 'accept_question'"
#execute 'swift', %{"Time to accept the question for opening number #{question['opening_id']} from user number #{question['respondent_id']}."}
# Place the caller into a queue
}
reject_question { #|question|
#execute 'swift', %{"Time to reject the question for opening number #{question['opening_id']} from user number #{question['respondent_id']}."}
# Place the caller into a queue
}
outgoing_32132 {
say_digits 12345
execute "swift", "\"I'm calling from Cloudvox to wish you a very happy birthday. This message could say
anything, interact with the caller, play sounds, MP3s, voices, connect them to another call, or do pretty much
anything your heart desires.\""
# .. more call processing ..
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment