Tropo is part of CiscoLearn More

Getting Call Detail Records

Posted on August 3, 2016 by Taylor Hanson

Call Detail Records (CDR) are useful for gleaning information about your account’s voice and SMS traffic. They contain the callerID, the calledID, duration, channel/network, disposition and more. Tropo provides the CDR information in your account logs, and they are available from the web portal or through FTP (ftp.tropo.com). However, since these logs also contain lots of additional information about the application session, they can be a little overwhelming, and too verbose to easily search through manually. We’ll show you how a simple program can solve that issue, and provide you with the full code to run it yourself. Some modifications may be desired, but this walkthrough will provide a good starting point to get all of the CDRs, for every application in your Tropo account, for the last sixty days.

This tool requires knowledge of the command terminal, and Python (~2.7) needs to be installed in order to run it out of the box; no additional Python packages are required. It will use ftp.tropo.com (using your tropo.com username and password) to download your account log files.

To start, the app will download your log files to a local folder. It will only retrieve the logs that changed since the last time the tool was run (by checking the names and file sizes on the FTP server vs those already downloaded), which means the first time you run it, it will download all of your account logs, but each time after will be incremental. As an additional measure of security, the app uses FTPS.

After the log files are downloaded, the app will extract any logs that are compressed (archived logs are compressed, active logs remain plain text), parse the content for just the CDRs and then save them to their own files, without the extra Tropo log content.

Last, the app gives you the option to create a CSV file that contains all of the CDRs for every file collected; this method is a bit easier to read and process than the pure JSON CDRs. For every file downloaded, new CDRs will be appended to the CSV – unless you change the name of the CSV each time you run it, in which case only the new CDRs since the last run would appear in the CSV.

By default, the downloaded and extracted logs are placed into a “workinglogs” folder, while the final parsed logs are separated and placed into a “parsedlogs” folder; these can be changed in the code. We also include a prompt to ask for your Tropo username and password; you can hardcode it if you prefer.

Download or clone the complete app from our Github repository and once downloaded (assuming you already have Python installed), open up your terminal, navigate to your newly created file, and then type:

python ftp_cdr_tool.py myoutputCSV.csv

Leave a Reply