Tropo is part of CiscoLearn More

Redirecting Your App Based on a Signal

Please review Interrupting Your Code - One Signal or Interrupting Your Code - Multiple Signals first, as this example builds on those concepts.

Tropo Scripting

You can include an onSignal parameter that specifies a callback function to run if the function is interrupted. If included, this will run, the method will end and your script will continue. If it's not present, the method simply ends and returns control back to your script. Here's an example:

say("http://example.org/holdmusic.mp3", {
    allowSignals: "exit",
    onSignal: function (event) {
        say("Hold music over.");
        }
});

say("You are now off hold.");
say "http://example.org/holdmusic.mp3", {
    :allowSignals => "exit",
    :onSignal => lambda { |event| 
        say "Hold music over."}
}

say "You are now off hold."
<?php
function signalFCN($event) {
    say("Hold music over.");
    }
say("http://example.org/holdmusic.mp3", array(
    "allowSignals" => "exit",
    "onSignal" => "signalFCN"
));

say("You are now off hold.");
?>
def signalFCN(event):
    say("Hold music over.")

say("http://example.org/holdmusic.mp3", {
    "allowSignals": "exit",
    "onSignal": signalFCN
})

say("You are now off hold.")
say("http://example.org/holdmusic.mp3", [
    allowSignals: "exit",
    onSignal: { event->
        say "Hold music over."}
])

say("You are now off hold.")

WebAPI

In WebAPI, you can include an on object in your document, specifying what to do when an event comes in for a particular event name. Where WebAPI typically uses events like event:continue or event:incomplete, you can also set an event to the name of your signal:

    {
       "tropo":[
          {
             "on":{
                "event":"exit",
                "next":"exit-say.json"
             }
          },
          {
             "say":{
                "value":"http://example.org/holdmusic.mp3",
                "allowSignals":"exit"
             }
          }
       ]
    }