Tropo’s coding model is designed around conversations. Ask a question, get an answer, ask something else, get another answer. Through grammars and our ask() functions, we make it easy to rapidly build a powerful automated phone or text conversation.
But what if you don’t want a conversation? What if you just want to send a text message out, without writing any code. One simple GET request and you’re on your way. And if someone texts your app, you just want that text posted somewhere like a form field would be.
One common case that’s come up a few times is people wanting to build SMS applications that run on SalesForce’s Force.com cloud. The Force.com programming language has a limitation that it can accept form posts, but sending other sorts of complex data into it doesn’t work. For example, there’s no way to receive and parse the JSON data that our WebAPI can send.
I’ve written a small application that anyone can use to do just this. Just drop it into your Tropo application and you can easily send text messages out. by passing the variables “to” and “msg” in the query string. Add in your secret API token from your Tropo account, and sending out messages is easy.
If you prefer to use POST to send your messages, Tropo can do that, too. Just post an XML document to us using the same fields above. The details of the document format can be found toward the end of our session API documentation.
To post incoming messages to a server, all you need to do is change one line in the code to add the URL you want to post to. You can also add a username and password if the server requires authentication.
Incoming messages are posted as form fields to your url. The fields “to”, “from” and “msg” contain the number (or IM address!) the message was sent to, the number or address the message was from, and the contents of the message.
Because Tropo works across multiple services with the same API, you can send and receive instant messages, too. Just remember, in order to send a message on a network, you need to have that an account for that network set up on your Tropo account. In other words, to send or receive SMS, you need an SMS phone number. To send or receive over Jabber, you need to add a Jabber account to your Tropo app.
The code is up on our GitHub account, so go read the short usage guide and grab it and try it out. You can even run it straight from GitHub without copying it up to Tropo if you want. Just fork it, edit to add your URL, then grab the “raw” url for the file off GitHub and use that as your Tropo app URL.
Here’s a short screencast showing you how to fork the code into your own github account, change the URL, and then use GitHub to serve the code to Tropo.
- Tropo Now Speaks Asterisk Gateway Interface (AGI)
- Canadian voice and SMS numbers, improved rate limit, and shortcodes
- Creating a Chat Room Interface using Multiple Conferences
- Developer Story: myaNUMBER for Simple, Secure Family Communications using Tropo and Phono