Tropo is part of CiscoLearn More

Labeling your CDRs

Often a software product that embeds Tropo wants to use Tropo's CDRs to track usage by their customers usage. While Tropo does not have the concept of sub-accounts, we do provide a mechanism that allows you to label a call with an arbitrary string. This label appears your CDRs. The labels can be anything you want, which means you can set a custom tracking ID in your application code that will later appear in the CDR for that call or message.

One common use of this tracking label is to insert your application's unique ID for a transaction, so that later you can correlate the transaction with the Tropo call or message. Another common use is to insert your customer's account ID into the CDR, to allow for later tabulation of all calls for each customer.

To set a label, include the "label" parameter in the call, transfer or message function, like so:

message("I'm gonna make him an offer he can't refuse.", {
  to: "+14075551212",
  network: "sms",
  label: "01decaf23bad45"
});
message "I'm gonna make him an offer he can't refuse.", {
  :to => "+14075551212",
  :network => "sms",
  :label => "01decaf23bad45"
}
<?php
message("I'm gonna make him an offer he can't refuse.", array(
  "to" => "+14075551212",
  "network" => "sms",
  "label" => "01decaf23bad45"
));
?>
message("I'm gonna make him an offer he can't refuse.", {
  "to" "+14075551212",
  "network" "sms",
  "label" "01decaf23bad45"
})
message("I'm gonna make him an offer he can't refuse.", [
  "to": "+14075551212",
  "network": "sms",
  "label": "01decaf23bad45"
])

For incoming calls in Tropo Scripting, you can set the label on the currentCall object, with the setLabel method:

answer();
currentCall.setLabel("01decaf23bad45");
say("I've a feeling we're not in Kansas anymore.");
answer
$currentCall.setLabel "01decaf23bad45"
say "I've a feeling we're not in Kansas anymore."
<?php
answer();
$currentCall->setLabel("01decaf23bad45");
say("I've a feeling we're not in Kansas anymore.");
?>
answer()
currentCall.setLabel("01decaf23bad45")
say("I've a feeling we're not in Kansas anymore.")
answer();
currentCall.setLabel("01decaf23bad45");
say("I've a feeling we're not in Kansas anymore.")

Note
The currentCall object is only created once a call is active. For an incoming call, this object does not exist until the call is answered. You need to either explicitly answer the call or call a Tropo function like say() that automatically answers the call before using currentCall.setLabel.

If more than one label is set, the last label set will be added to the CDR, an all other labels will be discarded. This applies regardless if the label is set by a label parameter or the setLabel medhod. Thus, if your code does this...

call("+14075551212", {label: "first label"});
currentCall.setLabel("new label");

... then the CDR will have a label of "new label". setLabel can be called as many times as you wish, but only the last label will appear in the CDR.

Note
It is not possible to set a label on incoming calls in WebAPI at this time.