Posted on by 6 comments


We continue our focus this week on ways to create real-time interfaces for your users via Tropo for phone calls, instant messaging, SMS and Twitter. As promised in my recent blogpost, WebSockets with Tropo, I would like to build upon Chris Matthieu’s XMPP with Tropo post by throwing BOSH into the mix.

“Bidirectional-streams Over Synchronous HTTP”, or BOSH, provides for  two-way communications over HTTP, emulating much of TCP. This allows yet another approach for creating low-latency interfaces to Tropo using the unique capabilities of our scripting platform. With this, you skip the latency inherent in chatty request/response APIs over HTTP REST. Allowing you to have fluid interactions with users in public spaces where their only interface to your application is a phone call.

Tropo has native support for XMPP built right into the standard API. Therefore a call comes into Tropo, we start asking the caller for input and then send those responses to the XMPP user that represents our browser application. In the browser we use JQuery and Strophe.js for the XMPP/BOSH support and then Artisan.js for the HTML5 Canvas tag rendering of the graphics. On the Tropo side we  have a Ruby script that looks like this:

require 'json'

loop do
ask "Press a key or push zero to exit.", {
:choices => "[1 DIGITS]",
:onChoice => lambda { |event|
input = { :command => event.value }.to_json
message input, {
:to => "",
:network => "JABBER" }
break if event.value == "0"

The simplicity of this is driven home by the fact that the Tropo API is the same for interacting with phone calls or messages (IM, Twitter or SMS), the power of a unified API. You may watch this in action here:

The Tropo script and Javascript/HTML examples may be found on Github here (Tropo script and HTML/Javscript example). And don’t forget to add and enable a Tropo Jabber account on your application:


6 Responses to “Tropo with XMPP and BOSH, More Real-time in Your Communications”

  1. Ted Gilchrist

    Hi Jason,

    Are you going to be publishing the Javascript code you used to create the web page in this examples?


    Ted Gilchrist

  2. Ted Gilchrist

    Hi Jason,

    So, I’m trying to get the client html page side working, and I keep getting “Strophe failed to connect” errors. Where is it supposed to be getting login credentials from?



  3. Jason Goecke

    Lines 120 through 123 in the HTML file:

    $(document).ready(function () {
    connection = new Strophe.Connection(BOSH_SERVICE);
    connection.connect(‘user’, ‘pass’, onConnect);

    Are where you may put the login credentials. Any XMPP server/service will work. For the demonstration I used’s public XMPP service.

  4. Ted Gilchrist

    One more thing that people should know. In order to make this work, you have to activate Jabber on your Tropo app. It’s right there in the UI, when you create the app. So, yes, the demo does indeed work!




Leave a Reply

  • (will not be published)