Tropo WebAPI Development Guide Home  |  Frameset Home

  Receiving Text Responses  |  TOC  |  Capturing Incoming Text  

Receiving Text Messages


Working with incoming text messages is as smooth and simple as voice calls - possibly even easier. At it's most basic, it's actually the same code - much of Tropo functions exactly the same way whether you're communicating via voice or text, and that's because its actually the same API; there's no need to learn two different things.

If you want to receive (or send) text messages, you need a phone number assigned to your application. To add a phone number, first log in at the Tropo website, then go to "Your Applications" and expand your application so you can make changes to it. Near the bottom of the application you'll see an "Add a new phone number" link; click on it, select your area code and you're ready to go!


Check out this extremely simple example - whenever you text the application, doesn't matter with what, it will respond with "Really, it's that easy."

require 'tropo-webapi-ruby'
require 'sinatra'

post '/index.json' do

    t = Tropo::Generator.new

    t.say "Really, it's that easy."

    t.response

end
var http = require('http');
var tropo_webapi = require('tropo-webapi');

var server = http.createServer(function (request, response) {
	
	var tropo = new TropoWebAPI();

	tropo.say("Really, it's that easy.");
	
	response.end(TropoJSON(tropo));

}).listen(8000); 
<?php

require('tropo.class.php');

$tropo = new Tropo();
$tropo->say("Really, it's that easy.");
$tropo->RenderJson();

?>
from itty import *
from tropo import Tropo

@post('/index.json')
def index(request):

    t = Tropo()
    t.say(["Really, it's that easy."])
    return t.RenderJson()

run_itty(server='wsgiref', host='0.0.0.0', port=8888)
{
   "tropo":[{"say":{"value":"Really, it's that easy."}}]
}

Answer is handled automatically for you, and hangup is optional - the call will disconnect when the script ends.

Now, as mentioned, that's as basic as it comes. In a real world application, you'll likely need to use the content of the incoming text message.

Next Step: Capturing Incoming Text


  ANNOTATIONS: EXISTING POSTS
0 posts - click the button below to add a note to this page

login
  Receiving Text Responses  |  TOC  |  Capturing Incoming Text  

© 2012 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site