Skip to content

Instantly share code, notes, and snippets.

View marks's full-sized avatar

Mark Silverberg marks

View GitHub Profile
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:
answer()
result = ask("What's your favorite color?", [
choices: "red, blue, green"])
log("They said: $result.value")
hangup()
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")
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 {
{
"tropo": [
{
"say": [
{
"value": "Please hold while your call is transferred to a customer service agent."
}
]
},
{
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
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}"
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
#record in dialplan.rb
thread = Thread.new do
#do stuff
end
thread.join
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