Tropo is part of CiscoLearn More

Passing in Parameters

Another useful feature is the ability to pass parameters into your application as global variables. If you launch your application using REST with a GET request, any query string variable (everything after the ?) will get converted into a global variable in your application; if the URL contains numberToDial=14075550100, the numberToDial variable in your application will be set to 14075550100. When using POST, you can define variables within the request body, which will be treated the same way. Check out Related Reading at the bottom of this page for more info.

Note that you should HTML encode anything that isn't alphanumeric - so for example if you wanted to include the + sign in the REST request instead of in the application, you would reference it as %2B instead of + (otherwise it's detected as a space, which is intentionally used in the example below to insert a space between words in the "msg").

This example URL contains three variables: numberToDial, customerName, and msg. The code is written to accept those variables in certain places to complete the app. When the following app is launched, it will send a text message to the number defined in the URL that says “OMG Justin Dupree, PM Thunderstorms tomorrow!”.

You may notice this code is only slightly different than the code used in the Passing Parameters subsection of the Making a Call QuickStart - we changed the message slightly, just to make it stand out, and then just added the network parameter to define this app as SMS instead of a voice. You also need an SMS-enabled phone number attached to your application, otherwise there is no "transport" for the SMS to use for delivery.

https://api.tropo.com/1.0/sessions?action=create
&token=TOKEN&numberToDial=14075551212
&customerName=Justin+Dupree&msg=PM+Thunderstorms tomorrow

call('+' + numberToDial, {
    network:"SMS"});
say("OMG " + customerName + ", " + msg + "!");
log("This guy knows " + customerName);
call '+' + $numberToDial, {
    :network => "SMS"}
say "OMG " + $customerName + "," + $msg + "!"
log "This guy knows: " + $customerName
<?php
call('+'.$numberToDial, array(
    "network" => "SMS"));
say("OMG ".$customerName.", ".$msg."!");
_log("This guy knows: ".$customerName);
?>

//Note that with PHP, you need to declare the variable scope for 
//passed in parameters if you intend to use them in a called function

call("+" + numberToDial, {
    "network":"SMS"})
say("OMG" + customerName + ", " + msg + "!")
log("This guy knows: " + customerName)
call('+' + numberToDial, [
    network: "SMS"])
say("OMG " + customerName + ", " + msg + "!")
log("This guy knows: " + customerName)

Please note, you will need to contact support to verify your account prior to sending outbound SMS.