Tropo WebAPI Development Guide Home  |  Frameset Home

  Handling Call Failures  |  TOC  |  Passing in Parameters  

Sending Text Messages


There are two parts to sending a text message - first, you need to write the code that tells Tropo what message to send, who to send it to, and in some cases, what to do with the text message they send back. The second step is telling Tropo to run your code. You also need a U.S. or Canadian phone number attached to your application, otherwise there is no "transport" for the SMS to use for delivery.

Here's an example of a simple outbound app that places a quick call:

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

post '/index.json' do
  
  t = Tropo::Generator.new
  
  t.call(:to => "+14075550100", :network => "SMS")
  t.say(:value => "Tag, you're it!")

  t.response
  
end

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

var server = http.createServer(function (request, response) {

	var tropo = new TropoWebAPI();

	//to, answerOnMedia, channel, from, headers, name, network, recording, required, timeout
	tropo.call("+14075550100", null, null, null, null, null, "SMS", null, null, null);
	tropo.say("Tag, you're it!!");

	response.end(TropoJSON(tropo));

}).listen(8000);  
<?php

require 'tropo.class.php';

$tropo = new Tropo();

$tropo->call("+14155550100", array('network'=>'SMS'));
$tropo->say("Tag, you're it!");

$tropo->RenderJson();
?>
from itty import *
from tropo import Tropo, Session

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

	t = Tropo()

	t.call(to="+14075550100", network = "SMS")
	t.say("Tag, you're it!")
	
	return t.RenderJson()

run_itty(server='wsgiref', host='0.0.0.0', port=8888)
{"tropo":[
      {"call":{
         "to":"+14075550100",
         "network":"SMS"
          }
      },
      {"say":{"value":"Tag, you're it!"}}
]}

To then launch the code, Tropo provides you with a URL to hit, which tells Tropo to launch your application. You also get a secret API key called a “token” that ensures only you can start your code (we recommend guarding the token like you would a password, or that exclusive ability could be jeopardized). Your token is found just under the phone numbers when you view your application in the Tropo User Interface.

To launch an application using your secret token, embed it directly into a URL like this:


Then either run the link through a browser or utilize an HTTP client like curl (the http client that comes with your favorite language is absolutely fine) and set it to use GET. You can also use a POST with XML if you'd prefer - this page outlines the syntax you would use.

Note, if you're attempting to send a text message to a non-U.S. destination, there are restrictions. Review this page for more information.

Want to include parameters in the URL you use to launch your application, such as the message content?

Next Step: Passing in Parameters



Additional Reading

A complete list of all the parameters for call can be found here, including all the possible values for network.


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

login
  Handling Call Failures  |  TOC  |  Passing in Parameters  

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