Tropo is part of CiscoLearn More

Logging from your application

In many cases, Tropo logging alone 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 - then you can log your own data to our logs.

With Tropo Scripting, there's a log function that enables you to insert whatever you want into the log. You give it a string as the only parameter, it interprets it and adds the result into the log with the other debugging information.

log("Call was from: " + currentCall.callerID);
log "Call was from: " + $currentCall.callerID
_log("Call was from: " . $currentCall->callerID);
log("Call was from: " + currentCall.callerID)
log("Call was from: " + currentCall.callerID)

The example above shows how you could insert the caller ID of the current call into the log. Note that with PHP, it's _log rather than log; the logarithm function in PHP already lays claim to log.

With WebAPI, 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 = => "Q")
  t.say(:value => "Tag, you're it!")
  t.on :event => 'incomplete', :next => '/incomplete.json'


post '/incomplete.json' do
  puts "The call did not complete."
var sys = require('sys');
var express = require('express');
var app = express.createServer();
var tropo_webapi = require('tropo-webapi');'/', function(req, res){
	var tropo = new TropoWebAPI();"Q");
	tropo.say("Tag, you're it!!");

	tropo.on("incomplete", null, "/incomplete", true);
});'/incomplete', function(req, res){
	console.log("The call did not complete.");

console.log('Server running on port :8000');
require 'tropo.class.php';
require 'lib/limonade.php';

dispatch_post('/start', 'app_start');
function app_start() {
	$tropo = new Tropo();
	$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.");


from itty import *
from tropo import Tropo

def index(request):

	t = Tropo()"Q")
	t.say("Tag, you're it!")
	t.on(event = "incomplete", next ="/incomplete.json")
	return t.RenderJson()
def index(request):
	print "The call did not complete."

run_itty(server='wsgiref', host='', 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