Skip to content

Instantly share code, notes, and snippets.

@cloudvoxcode
cloudvoxcode / cloudvox-inbound-simple-ruby.rb
Created October 7, 2009 22:30
Answer call, welcome with Matrix monologue, prompt for input, speak today's date
# Cloudvox works with standard Asterisk (AGI) libraries, like Adhearsion
default {
play 'sounds/matrix'
execute 'swift', '"Press 1 to hear the date."'
case input(1)
when '1'
execute 'swift', '"Today is %s"' % Time.now.strftime("%A, %B %e")
else
play 'unavailable'
end
@cloudvoxcode
cloudvoxcode / cloudvox-inbound-simple-json.rb
Created October 8, 2009 06:48
Uses phone API with JSON
# use any language, or static JSON:
[{"name":"speak", "phrase":"Hello! Enter a 6-digit number."},
{"name":"getdigits", "max":6, "url":"http://a.web.server/step-2"}]
# input is passed to you. Act on it:
[{"name":"speak", "phrase":"You entered $_GET['result']"},
{"name":"playback", "filename":"thanks-for-calling"}]
@cloudvoxcode
cloudvoxcode / cloudvox-http-1.json
Created October 8, 2009 07:04
Answer call with HTTP/JSON & Asterisk (more at help.cloudvox.com)
[{"name":"speak","phrase":"Thanks for calling!"},
{"name":"playback","filename":"monkeys"}]
Cloudvox Phone API Platform Launches: "Telephony in the Cloud"
New Cloudvox service lets Web developers manipulate phone calls like Web
pages -- from their own software, over the Internet, in minutes.
Cloudvox launched today, bringing unprecedented phone call flexibility to
entrepreneurs and technologists. Any Web developer can place, receive, and
control phone calls from their own application or Web site, with no new
infrastructure.
@cloudvoxcode
cloudvoxcode / http-click-to-call-example-1.php
Created October 30, 2009 16:37
Basic click-to-call example using HTTP via Cloudvox
<?php // more: http://help.cloudvox.com/
$r= new HttpRequest('http://your.cloudvox.com/applications/42/dial', HttpRequest::METH_POST);
$r->addPostFields (
array (
'destination' => '2061112222',
'caller_id' => '2065559999',
'remote_number' => $_GET['remote_number'];
)
);
$r->send ()
@cloudvoxcode
cloudvoxcode / sound_uploader.rb
Created December 22, 2009 14:43
Cloudvox sound uploader - see help.cloudvox.com
#!/usr/bin/env ruby -w
require 'net/http'
require 'net/https'
begin
require 'net/http/post/multipart'
rescue LoadError
puts "This requires multipart-post."
puts " $ sudo gem install multipart-post"
@cloudvoxcode
cloudvoxcode / cloudvox-cdr-export.rb
Created January 9, 2010 23:27
Cloudvox call history export to CSV sample
#!/usr/bin/ruby
require 'rubygems'
require 'httparty'
# basic Cloudvox call history to CSV example
# see http://help.cloudvox.com/faqs/provisioning/call-history
class CallDetailRecords
include HTTParty
format :json
@cloudvoxcode
cloudvoxcode / cell-phone-simulator.rb
Created February 27, 2010 15:11
bring that unique cell phone experience to every phone call
# cell phone simulator with Adhearsion & Cloudvox (http://bit.ly/cvruby)
default {
until caller_finally_given_up?
case (rand*5).to_i
when 0 then play 'intermittent-static'
when 1 then execute 'swift', '"All circuits are busy. Please try your call again later."'
when 2 then hangup
when 3 then execute 'echo'
when 4
sleep until phone_location_changed?
[{"name":"playback","filename":"thanks-for-calling"},
{"name":"speak","phrase":"Record your update now."},
{"name":"record","filename":"update-from-afar.wav","url":"http://your.server/send-as-email"},
{"name":"speak","phrase":"Submitted. Goodbye."}]
@cloudvoxcode
cloudvoxcode / ami_listener.rb
Created May 6, 2010 15:54
Asterisk AMI event listener - connect, read, & output
#!/usr/bin/ruby
# connect to Asterisk AMI port, authenticate, and print all AMI event messages
# as they're received.
# more or for Asterisk hosting: http://help.cloudvox.com/
# version: 2010-05-04
require 'socket'
unless ARGV.length == 4
puts 'usage: ruby ./ami_listener.rb hostname port username password'