Tropo WebAPI Development Guide Home  |  Frameset Home

  Hosting Files with Tropo  |  TOC  |  Hosting Audio Files  

Logging & Debugging


So you created an application, you dial the phone number, but it’s not working like you planned. Now what? How do you find out what’s going on?

Tropo has a great debugger integrated with your account. It doesn’t even require any setup on your part. Simply click on the Application Debugger link in the footer of any Tropo page. Give it quick try - load the Debugger, place a call to your application and watch the steps as they occur in real time.


The debugger will also contain both the session and result JSON, which often points to the root of the problem when working with WebAPI (bad JSON syntax, no JSON at all, etc).

Logging


Last step you saw how the debugger shows you what happened when your script ran. In many cases, this will give you the information you need to troubleshoot any issues. But if you want to check specific items - the value of variables, the results of function calls and events - you'll need to utilize one of the libraries and work with the logging built into the language (either to the console or to an actual log). The Handling Call Failure Quickstart contains examples for Ruby, Node.js, PHP and Python; here's an abbreviated form:

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.response
  
end

post '/incomplete.json' do
  puts "The call did not complete."
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);
	
	res.send(TropoJSON(tropo));
});
	
app.post('/incomplete', function(req, res){
	console.log("The call did not complete.");
});	

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"));

	return $tropo->RenderJson();

}

dispatch_post('/incomplete', 'app_incomplete');
function app_incomplete() {
	error_log("The call did not complete.");
}

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 = "incomplete", next ="/incomplete.json")
	
	return t.RenderJson()
	
@post("/incomplete.json")
def index(request):
	
	print "The call did not complete."

run_itty(server='wsgiref', host='0.0.0.0', port=8888)


Note that if you use PHP, the above example includes the Limonade framework, so you would need to define the end of the start URL in Tropo to include the resource name, like http://www.example.com/test.php?uri=start:


Next Step: Hosting Files with Tropo



  ANNOTATIONS: EXISTING POSTS
0 posts - click the button below to add a note to this page

login
  Hosting Files with Tropo  |  TOC  |  Hosting Audio Files  

© 2012 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site