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
answer() | |
result = ask("What's your favorite color?", [ | |
attempts: 3, | |
choices: "red, blue, green", | |
onBadChoice: { event-> | |
switch(event.attempt){ | |
case 1: | |
say "We don't support that color. You can say red, blue or green." | |
break | |
case 2: |
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
answer() | |
result = ask("What's your favorite color?", [ | |
choices: "red, blue, green"]) | |
log("They said: $result.value") | |
hangup() |
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
answer() | |
ask("Welcome to the Tropo company directory. Who are you trying to reach?", [ | |
choices: "department(support, engineering, sales), person(jose, jason, adam)", | |
onChoice: { event-> | |
switch(event.value) { | |
case "department": | |
log("Department info: $event.choice.interpretation") | |
break | |
case "person": | |
log("Person info: $event.choice.interpretation") |
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
call('[email protected]', [ | |
network: 'GMAIL', | |
onAnswer: { | |
ask("Hey, did you remember to take your pills?", [ | |
timeout: 120, | |
choices: 'yes(yes,y,1), no(no,n,2)', | |
onChoice: { event-> | |
if(event.value == "yes") { | |
say "ok, just checkin." | |
} else { |
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
{ | |
"tropo": [ | |
{ | |
"say": [ | |
{ | |
"value": "Please hold while your call is transferred to a customer service agent." | |
} | |
] | |
}, | |
{ |
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 "socket" | |
tcp_socket = TCPSocket.new('thehost', 20000) | |
active_call = true | |
options = { :choices => '1,2,3,4,5,6,7,8,9,0' } | |
while active_call == true do | |
result = ask 'Please enter a command.', options | |
if result.value == 0 | |
active_call = false |
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 'eventmachine' | |
module DigitCollector | |
def post_init | |
puts "-- someone connected to the echo server!" | |
end | |
def receive_data data | |
p ">>>you sent: #{data}" |
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 'appengine-apis/logger' | |
require 'appengine-apis/datastore' | |
require 'json' | |
get '/' do | |
logger.info "Sinatra in your Google Appengine p0wning your JRuby" | |
"I AM SINATRA! Doing a ditty for you on Google Appengine with JRuby!" | |
end |
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
#record in dialplan.rb | |
thread = Thread.new do | |
#do stuff | |
end | |
thread.join |
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
task :export do | |
require 'sequel' | |
require 'fastercsv' | |
db = Sequel.connect(ENV['DATABASE_URL']) | |
table_name = ENV['table'].to_sym | |
table = db[table_name] | |
fields = table.first.keys |