Tropo is part of CiscoLearn More

Starting a Session

The following example shows how to kick off an "outbound session" using a token and the REST API, which then launches the application, makes a call and plays a message. It will also show how to pass additional parameters into your application when initiating the Tropo Scripting session. To find your token, login to your Tropo account, display the application configuration screen, and look down under the phone numbers:

First, the application code:

call('+1' + numberToDial);
say("OMG " + customerName + ", " + msg + "!");
log("This guy knows: " + customerName);
call '+1' + $numberToDial
say "OMG " + $customerName + "," + $msg + "!"
log "This guy knows: " + $customerName
<?php
call('+1'.$numberToDial);
say("OMG ".$customerName.", ".$msg."!");
_log("This guy knows: ".$customerName);
?>
call("+1" + numberToDial)
say("OMG " + customerName + ", " + msg + "!")
log("This guy knows: " + customerName)
call('+1' + numberToDial)
say("OMG " + customerName + ", " + msg + "!")
log("This guy knows: " + customerName)

In the above example, we're passing numberToDial, customerName and msg. These can be added as variables in JSON, XML or form-encoded format (when using POST) or added directly into a URL (when using GET). The following information explains how to use either method:

Request

URL:

https://api.tropo.com/1.0/sessions

Method:

POST or GET

Headers:

Only required when using POST:

accept:application/json

content-type:application/json
accept:text/xml

content-type:text/xml
content-type:application/x-www-form-urlencoded

Request Body:

POST:

{
    "token":"TOKEN",
    "customerName":"John Dyer",
    "numberToDial":"4075551212",
    "msg":"the sky is falling."
}
<session>
    <token>TOKEN</token>
    <var name="customerName" value="John Dyer"></var>
    <var name="numberToDial" value="4075551212"></var>
    <var name="msg" value="the sky is falling"></var>
</session>
token=TOKEN&customerName=John+Dyer&numberToDial=4075551212&msg=the+sky+is+falling

GET:

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

Response

    Response Body:

    {
        "success": true,
        "token": "TOKEN",
        "id": "ID"
    }
    <session>
        <success>true</success>
        <token>TOKEN</token>
        <id>ID</id>
    </session>
    success=true&token=TOKEN&id=ID
    

The names numberToDial, customerName, and msg are not special names in Tropo. Tropo can accept any variable name, and will convert these to global variables in your script.

Note
The values for each variable can be strings only, If you use another data type in JSON (an array, for example), it will be wrapped in quotes to turn it into to a string before passing it to your application.