Posts Tagged ‘sockets’

Tropo DTMF to XMPP IM Relay

Friday, November 19th, 2010

Are you building real-time gaming applications that use the phone (Voice or DTMF touch-tone) and require immediate response to your application?  Ever wondered how to get input from a caller at the speed of light – rather than traditional AJAX API calls?

Tropo’s Scripting API allows you to do all sorts of interesting hacks to make this possible!  Earlier, Jason Geocke demonstrated how to do this using real-time TCP sockets in the following blog post: Using Persistent Sockets in Tropo Applications.  I recently had a customer asking about a similar request but using XMPP Instant Messaging to relay the DTMF touch-tones to any IM client.

I’m always up for a new challenge but was disappointed to find that this request wasn’t challenging at all.  Tropo is ideal for building multi-modal communications apps like this going from Voice to IM in the same application.

Here is a video that demonstrates how this works.

Here is the Tropo Scripting that I used to make this demo possible.

answer
sleep 2

keeprunning = true
while keeprunning

  ask "press a key or zero to end", {
    :choices => "[1 DIGITS]",
    :onChoice => lambda { |event|
    message event.value, {
      :to => "christoffe@jabber.org",
      :network => "JABBER"}
      if event.value == "0"
        keeprunning = false
      end
    }
  }

end

The only thing left to do is connect your IM bot to your Tropo application by simply creating one dynamically like cmtest@tropo.im.  See below:

That’s all she wrote :)

Using Persistent Sockets in Tropo.com Applications

Thursday, September 10th, 2009

While Tropo supports RESTful Web Services as a form of moving data to and from the communication cloud, it may not always be fast enough for all applications. There are apps that require the lowest possible latency, for example, when mobile devices become input devices. The unique approach of Tropo, allowing developers to host scripts in our cloud, allows you the ability to write applications that take direct advantage of persistent sockets. This means that you may open the socket once and then stream data to your remote application in realtime without having to establish HTTP connections each time.

I recently created an example of this using Ruby to serve a socket using EventMachine, and then writing a script on Tropo that opens a socket and sends touch-tones (DTMF) down the socket immediately as they come in. Here it is in action:

The code examples may be found here.