Outbound Calls Using Python on Tropo

Two crucial but undocumented rules about Python on the new Tropo service from Voxeo.

1. The result of a call() is an object.

2. Variables you send via GET/POST when you trigger an outbound call do not use the standard "cgi" library. Instead, the variable shows up in the script automatically.

Here's a working script that makes an outbound call (1st known version in the wild:)

log("about to call " + tn )
e=call(tn)

try:
if e.name == "answer":
log("e is here")
e.value.say("Hello, RJ. Outbound calls now work on Python.")
except:
log("some sort of problem")

hangup()

Notice the mysterious variable "tn," which is the phone number to call. How does it get into the script?

To trigger this call, I need to send a token, the "action" create, and the value of "tn":

"http://api.tropo.com/1.0/sessions?action=create&token=TOKEN&tn=17737648727"

We'll see an outbound call to +1 773 764 8727, i.e., my office.

Also, please notice that the return value of call() was an event, and I used e.value.say() to send a prompt to that particular event.