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 this page for more info on using POST. 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").

The example URL that follows contains three variables: numberToDial, customerName, and msg. The code is written to accept those variables in certain places to complete the app. When the app is launched, it will call the number defined in the URL and say “OMG John Dyer, the sky is falling!”, log a record of the call and then disconnect:

https://api.tropo.com/1.0/sessions?action=create&token=TOKEN&
numberToDial=14075551212&customerName=John+Dyer&
msg=the+sky+is+falling

call('+' + numberToDial);
say("OMG " + customerName + ", " + msg + "!");
log("This guy knows: " + customerName);
call '+' + $numberToDial
say "OMG " + $customerName + "," + $msg + "!"
log "This guy knows: " + $customerName
<?php
call('+'.$numberToDial);
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)
say("OMG " + customerName + ", " + msg + "!")
log("This guy knows: " + customerName)
call('+' + numberToDial)
say("OMG " + customerName + ", " + msg + "!")
log("This guy knows: " + customerName)

Please note, you will need to open an account ticket to verify your account prior to making outbound calls.