Tropo is part of CiscoLearn More

message

This is a shortcut function to create a call or text message, say something, then disconnect - all in one step. This is especially useful when you are on a voice call and want to send a quick text message out.

If message makes a voice call, you can also define multiple phone numbers/SIP addresses for the destination as an array; whichever destination picks up first, wins. While you can define multiple SMS destinations as well, it won't break the application, only the first number in the array will actually receive the text message. In order to send an SMS message, you must have an SMS-Enabled phone number attached to the application.

Note
Before you can send to non-U.S. destinations, both for voice and SMS, you need to contact support first to get international dialing enabled. This can be done via an account ticket or via support@tropo.com.

Since Tropo is synchronous, message is a blocking method. This means no other method can run until message is complete.

Parameters

text

String
(Required)

In the case of a voice session, this can either be the text to be rendered by the Text to Speech Engine (may also be SSML), or a URL to an audio file to be played. In the case of a text messaging session, this will be the text to be sent to the user.

Map Parameters

callerID

String

The callerID passed to the call recipient. For example, if the number 14155551212 called 14075551000, the *1212 number would be the callerID. Phone numbers with formatting (for example +1 415-555-1212) will have formatting removed by Tropo prior to dialing. When transferring an incoming call, If you do not specifically define anything for this field, the callerID of the incoming call leg will be used.

The callerID can be manually set to a specific number - for voice calls, this can be any valid phone number. For SMS, it must be a number assigned to your account. See Tips for Setting Valid Caller ID for detailed rules about Caller ID.

channel

String

Channel tells Tropo whether the call is "voice" or "text". This is not a required field and is actually often unnecessary - in most cases, Tropo is able to determine the channel based on the network. Channel is primarily used to split an inbound oriented application into different sets of instructions - one set for any input that comes in via text and a different set for input that comes in over voice.

network

String

The name of the network being used for this session. For voice, this can be 'PSTN", "SIP", or "INUM". For text, this can be "SMS". This is primarily used to define an SMS application from a voice application, since both call out to phone numbers.

timeout

Float
Default: 
30.0

How long Tropo will wait - in seconds - for an answer, busy signal, or other event to occur. The maximum value for this parameter is 2 hours. It's recommended for outbound voice calls that this be set somewhere between 50-90 seconds. This ensures if one carrier cannot connect the call for whatever reason, there is time to try it on another carrier.

to

String or Array
(Required)

The destination to make a call to or send a message to. This may currently take one of the following forms:

  • +14155551212 - The telephone number to dial with a '+' and country code.
  • tel:+14155551212 - The telephone number with a tel: prefix
  • sip:username@doamin.com - The SIP URI to dial
  • When making a voice call, you can specify dialing options as part of the number:

    • postd - The DTMF digits to dial after the call has connected
    • pause - The amount of time to wait before issuing the digits after the call is connected
    • Example: "+14155551212;postd=1234pp56;pause=1000ms". This will dial 1234 one second after connecting to the phone number, pause for an additional 2 seconds (pp) and then dial 56

    As mentioned in the main description, you can also list multiple phone numbers or SIP addresses (or both!) as an array for a voice call; whichever destination picks up first, wins.

promptLogSecurity

String
Default: 
none

Controls whether Tropo logs the text to speech string used by the method. Possible values are "none" (the default) and "suppress", which disables output logging for this method. See Log Suppression for complete details and examples.

label

String

Set by you, an arbitrary label for this call or message. The label you set will appear in your CDR, allowing you to track a CDR by a string you define. See Labeling your CDRs for examples.

Examples

  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"
])