Using the Message Shortcut

In the Mixing Text & Voice in a Single App QuickStart, we showed how to insert the hangup method to disconnect one session and then used call to start a new one - however that might not work for all applications. Tropo includes a shortcut method called message that allows you to make an outbound call or send a text message right in the middle of an app. The following code is very close to the code used in Mixing Text & Voice, but notice there's no hangup breaking the app into two sessions, and there's also no call and no separate say - they're replaced by message:

record("We're not available right now, please leave your message at the beep.", {
   beep:true,
   recordURI:"http://example.com/phone_call.js"
    }
);

message("Received office voice mail", {
    to:"+14075550100",
    network:"SMS"
});
record "We're not available right now, please leave your message at the beep.", {
    :beep => true,
    :recordURI => "http://example.com/phone_call.rb"
     }

message "Received office voice mail.", {
    :to => "+14075550100",  
    :network => 'SMS'}
<?php

record("We're not available right now, please leave your message at the beep.", array(
   "beep"=>"true",
   "recordURI"=>"http://example.com/phone_call.php"
    )
);

message("Received office voice mail.", array(
  "to" => "+14075550100", 
  "network" => "SMS"));

?>
record("We're not available right now, please leave your message at the beep.", {
   "beep":true,
   "recordURI":"http://example.com/phone_call.py"
})

message("Received office voice mail.", {
  "to":"+14075550100", 
  "network":"SMS"})
record("We're not available right now, please leave your message at the beep.", [
   beep: true,
   recordURI: "http://example.com/phone_call.groovy"
])

message("Received office voice mail.", [
  to: "+14075550100",
  network: "SMS" 
]

Modifying message to send a voice message is very easy - just omit or adjust the network value. This example sends a voice message:

message("Received office voice mail.", {
    to:"+14705550100"
});
message "Received office voice mail.", {
    :to => "+14075550100"}
<?php
message("Received office voice mail.", array(
    "to" => "+14075550100"));
?>
message("Received office voice mail.", {
    "to":"+14075550100"})
message("Received office voice mail.", [
    to: "+14075550100" 
])

Message can also be used all by itself - if all you want is an application that makes a call, says something and then hangs up, message combines all three together for a much simpler app.

Next, we cover using "record".