require 'tropo-webapi-ruby'
require 'sinatra'
post '/index.json' do
t = Tropo::Generator.new
t.call(:to => "Q")
t.say(:value => "Tag, you're it!")
t.on :event => 'incomplete', :next => '/incomplete.json'
t.on :event => 'hangup', :next => '/hangup.json'
t.on :event => 'error', :next => '/error.json'
t.response
end
post '/incomplete.json' do
puts "The call did not complete."
end
post '/hangup.json' do
puts "The user hungup or the call went to voicemail."
end
post '/error.json' do
puts "A server error has occurred."
end
var sys = require('sys');
var express = require('express');
var app = express.createServer();
var tropo_webapi = require('tropo-webapi');
app.post('/', function(req, res){
var tropo = new TropoWebAPI();
tropo.call("Q");
tropo.say("Tag, you're it!!");
tropo.on("incomplete", null, "/incomplete", true);
tropo.on("hangup", null, "/hangup", true);
tropo.on("error", null, "/error", true);
res.send(TropoJSON(tropo));
});
app.post('/incomplete', function(req, res){
console.log("The call did not complete.");
});
app.post('/hangup', function(req, res){
console.log("The user hungup or the call went to voicemail.");
});
app.post('/error', function(req, res){
console.log("A server error has occurred.");
});
app.listen(8000);
console.log('Server running on port :8000');
<?php
require 'tropo.class.php';
require 'lib/limonade.php';
dispatch_post('/start', 'app_start');
function app_start() {
$tropo = new Tropo();
$tropo->call("Q");
$tropo->say("Tag, you're it!");
$tropo->on(array("event" => "incomplete", "next" => "hello_world.php?uri=incomplete"));
$tropo->on(array("event" => "hangup", "next" => "hello_world.php?uri=hangup"));
$tropo->on(array("event" => "error", "next" => "hello_world.php?uri=error"));
return $tropo->RenderJson();
}
dispatch_post('/incomplete', 'app_incomplete');
function app_incomplete() {
error_log("The call did not complete.");
}
dispatch_post('/hangup', 'app_hangup');
function app_hangup() {
error_log("The user hungup or the call went to voicemail.");
}
dispatch_post('/error', 'app_error');
function app_error() {
error_log("A server error has occurred.");
}
run();
?>
from itty import *
from tropo import Tropo
@post('/index.json')
def index(request):
t = Tropo()
t.call("Q")
t.say("Tag, you're it!")
t.on(event = "hangup", next = "/hangup.json")
t.on(event = "incomplete", next ="/incomplete.json")
t.on(event = "error", next ="/incomplete.json")
return t.RenderJson()
@post("/hangup.json")
def index(request):
print "The user hungup or the call went to voicemail."
@post("/incomplete.json")
def index(request):
print "The call did not complete."
@post("/error.json")
def index(request):
print "A server error has occurred."
run_itty(server='wsgiref', host='0.0.0.0', port=8888)
{
"tropo":[
{
"on":{
"event":"error",
"next":"/error.json"
}
},
{
"on":{
"event":"hangup",
"next":"/hangup.json"
}
},
{
"on":{
"event":"incomplete",
"next":"/incomplete.json"
}
},
{"call":
{"to":"Q"}
},
{"say":[
{"value":"Tag, you're it!"}
]}
]}