require 'tropo-webapi-ruby'
require 'sinatra'
post '/index.json' do
t = Tropo::Generator.new
t.ask :name => 'digits',
:timeout => 60,
:say => {:value => "What's your four or five digit pin? Press pound when finished."},
:choices => {:value => "[4-5 DIGITS]", :mode => "dtmf", :terminator => "#"}
t.on :event => 'continue', :next => '/continue.json'
t.response
end
post '/continue.json' do
t = Tropo::Generator.new
t.say(:value => "Thank you.")
t.response
end
var http = require('http');
var express = require('express');
var app = express.createServer();
var tropo_webapi = require('tropo-webapi');
// Required to process the HTTP body.
// req.body has the Object while req.rawBody has the JSON string.
app.configure(function(){
app.use(express.bodyParser());
});
app.post('/', function(req, res){
var tropo = new TropoWebAPI();
var say = new Say("What's your four or five digit pin? Press pound when finished.");
// (value, mode, terminator)
var choices = new Choices("[4-5 DIGITS]", "dtmf", "#");
// (choices, attempts, bargein, minConfidence, name, recognizer, required, say, timeout, voice);
tropo.ask(choices, null, null, null, "digits", null, null, say, 60, null);
tropo.on("continue", null, "/continue", true);
res.send(TropoJSON(tropo));
});
app.post('/continue', function(req, res){
var tropo = new TropoWebAPI();
tropo.say("Thank you.");
res.send(TropoJSON(tropo));
});
app.listen(8000);
console.log('Server running on port :8000');
<?php
require 'tropo.class.php';
require 'lib/limonade.php';
dispatch_post('/', 'app_start');
function app_start() {
$tropo = new Tropo();
$options = array("choices" => "[4-5 DIGITS]", "name" => "digits", "timeout" => 60, "mode" => "dtmf", "terminator" => "#");
$tropo->ask("What's your four or five digit pin? Press pound when finished.", $options);
$tropo->on(array("event" => "continue", "next" => "hello_world.php?uri=continue"));
$tropo->RenderJson();
}
dispatch_post('/continue', 'app_continue');
function app_continue() {
$tropo = new Tropo();
$tropo->say("Thank you!");
$tropo->RenderJson();
}
run();
?>
from itty import *
from tropo import Tropo, Choices
@post('/index.json')
def index(request):
t = Tropo()
choices = Choices("[4-5 DIGITS]", mode="dtmf", terminator = "#")
t.ask(choices, timeout=60, name="digit", say = "What's your four or five digit pin? Press pound when finished.")
t.on(event = "continue", next ="/continue")
return t.RenderJson()
@post("/continue")
def index(request):
t = Tropo()
t.say("Thank you!")
return t.RenderJson()
run_itty(server='wsgiref', host='0.0.0.0', port=8888)