Tropo is part of CiscoLearn More

Transferring a Call

At some point, the majority of applications will find a use for transfer, whether it's a voicemail system with caller selection options, blind forwards based on callerID or middle-of-a-call transfers to move a caller to a different application - all of it can be handled by Tropo with relatively little code.

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

Here's the simplest form of transfer:

say("Transferring you now, please wait.");
transfer("+14075550100");
say "Transferring you now, please wait."
transfer "+14075550100"
<?php
say("Transferring you now, please wait.");
transfer("+14075550100");
?>
say("Transferring you now, please wait.")
transfer("+14075550100")
say("Transferring you now, please wait.")
transfer("+14075550100")

You can get fancier, however. The two legs of the call can be on different networks: one on SIP and one over the telephone network. The following example adds multiple destinations as an array (first to answer wins!), then adds hold music, a terminator to cancel the transfer AND error handling for timeouts, all with just a little extra code. Note the mixing of SIP and phone number destinations in the transfer.

say("Please wait while we transfer your call. Press star to cancel the transfer.");
transfer(["+14075550100","sip:12345678912@221.122.54.86"], {
    playvalue: "http://www.phono.com/audio/holdmusic.mp3",
    terminator: "*",
    onTimeout: function(event) {
        say("Sorry, but nobody answered");
    }
});
say "Please wait while we transfer your call. Press star to cancel the transfer."
transfer ["+14075550100","sip:12345678912@221.122.54.86"], {
    :playvalue => "http://www.phono.com/audio/holdmusic.mp3",
    :terminator => "*",
    :onTimeout => lambda { |event|
        say "Sorry, but nobody answered"
    }
}
<?php
say("Please wait while we transfer your call. Press star to cancel the transfer.");
transfer(array("+14075550100","sip:12345678912@221.122.54.86"), array(
    "playvalue" => "http://www.phono.com/audio/holdmusic.mp3",
    "terminator" => "*",
    "onTimeout" => "timeoutFCN"
    )
);
function timeoutFCN($event) {
    say("Sorry, but nobody answered.");
    }
?>
say("Please wait while we transfer your call. Press star to cancel the transfer.")
transfer(["+14075550100","sip:12345678912@221.122.54.86"], {
    "playvalue":"http://www.phono.com/audio/holdmusic.mp3", 
    "terminator": "*",
    "onTimeout": lambda event : say("Sorry, but nobody answered.")})
say("Please wait while we transfer your call. Press star to cancel the transfer.")
transfer(["+14075550100","sip:12345678912@221.122.54.86"], [
    playvalue: "http://www.phono.com/audio/holdmusic.mp3",
    terminator: "*",
    onTimeout: { event->
        say "Sorry, but nobody answered" }
])

How about the blind forward based on callerID?

var callerID = currentCall.callerID;
if (callerID == "4075550100") {
    transfer("+3217105094");
    }
else {
    say("Hi friend!");
    }
callerID = $currentCall.callerID
if (callerID == "4075550100")
    transfer "+3217105094"
else
    say "Hi friend!"
end
<?php
 $callerID = $currentCall->callerID;
if ($callerID == "4075550100") {
    transfer("+3217105094");
 } else {
    say("Hi friend!");
 }
?>
callerID = currentCall.callerID
if (callerID == "4075550100") :
    transfer("+3217105094")
else :
    say("Hi friend!")
callerID = currentCall.callerID
if (callerID == "4075550100") {
    transfer("+3217105094")
    }
else {
    say("Hi friend!")
    }

These examples all transfer an incoming call to somewhere else. Alice calls a Tropo number and is transferred to Bob. It's also possible to transfer an outgoing call. First, Tropo calls Alice and then transfers her to Bob. Whether Alice joined from an incoming call or an outgoing call, transfer behaves the same.

call("sip:alice@example.com");
say("Transferring you now, please wait.");
transfer("+14075550100");
call "sip:alice@example.com";
say "Transferring you now, please wait."
transfer "+14075550100"
<?php
call("sip:alice@example.com");
say("Transferring you now, please wait.");
transfer("+14075550100");
?>
call("sip:alice@example.com")
say("Transferring you now, please wait.")
transfer("+14075550100")
call("sip:alice@example.com")
say("Transferring you now, please wait.")
transfer("+14075550100")