Tropo is part of CiscoLearn More

DevOps with Cisco Spark: Follow your Tropo calls and SMS activity in real-time

Posted on June 13, 2016 by Steve Sfartz

Integrating phone calls and SMS into your applications can be done in a snap with Tropo’s unique Scripting platform. A few lines of Javascript, PHP, Python, Groovy or Ruby, and you’re ready to run your phone call or SMS with a custom integration. Check this javascript snippet which implements a SMS subscription service. Try it yourself: text your email address to +1 414-882-4773

Try it by yourself at +1 438–448–3585 (text or call)

Now comes the time to support and grow your application: you want to track user activity in real-time and regularly check that your script executes properly on Tropo servers. To do this you’ ll have to create a custom dashboard, or dig into Tropo script logs (which can be detailed).

This is where Cisco Spark can help. We’ll show you how to push your Tropo script activity into a Cisco Spark room in (near) real-time. At the end of the article, you’ll have your INFO and DEBUG log levels pushed to Spark.

script

Tropo DevOps with Cisco Spark

If you care about DevOps, you’ve already connected most of your critical backend applications and strategic delivery processes to your favorite real-time messaging platform to raise alerts or to simply share information instantly with colleagues. Let’s extend your DevOps practices to Tropo in 3 steps:

“We’ll leverage the Cisco Spark API from Tropo’s Javascript Runtime. Note that the same principles apply to the all languages supported by the Tropo Cloud Platform (Javascript, Ruby, Python, PHP, and Groovy). As of now, example code is only provided in Javascript, and your contributions are welcome.”

1. Create a Spark incoming webhook

From the Spark Web client, create a room to be used exclusively for Tropo Logs or pick an existing room.

In the right hand panel of the Spark Room, click “add Integrations” and choose “incoming integration”.

“If you do not see the “incoming integration panel”, there’s good chance you are not in the Spark WEB client, but a Desktop or Mobile Spark client.”

Name your integration. Tis name will be used to publish messages to the Spark Room as new log entries are created by your Tropo script.

Finally, copy your webhook URI suffix.

1. Create a Spark incoming webhook

2. Add the Spark4Tropo Javascript library to your script

Copy/paste the Spark4Tropo.js code snippet at the top of your Tropo script.

Insert your Spark integrations suffix into the “YOUR_INTEGRATION_SUFFIX” placeholder. You may also want to identify your logs as they are pushed to the Spark room by changing the APPNAME.

2. Copy and customize the Spark4Tropo.js snippet

3. Enhance your Script Business Logic

Replace your script’s logs by the debug() and info() functions provided by the Spark4Tropo.js code snippet.

3. turn your logs to the provided log & debug functions

Now run your code again, and watch Tropo logs showing up in Spark as your script gets executed.

Future thoughts

You may create 2 Spark Rooms : one to follow Business activity (info logs in the example above), and the other one for Debugging Purposes (fine grained logs).

Spark4Logs configuration to send logs to several Spark Rooms

Leave a Reply