Additional SMS Info

The following SMS information is presented primarily for informational purposes. It pertains to use cases or procedures that, while possible, rarely occur.

Group Messaging Example

Here is an example application that could be used to perform group messaging using the Plum Voice Inbound SMS platform:

group_messaging.php

<?php
header('Content-type: text/xml');
echo("<?xml version=\"1.0\"?>\n");

// The list of people in this group
$group = array('12125550000'=>'Michael', '12125550001'=>'Bob', '12125550002'=>'Lindsay', '12125550003'=>'Jim');

// Make sure the sender is part of this group
if ( isset($_POST['from']) && isset($group[$_POST['from']]) ) {
  echo('<reply>');

  // Reply to everyone except the sender
  foreach ($group as $to=>$contact) {
    if ($to != $_POST['from']) {
      echo("<sms_message to=\"$to\">".htmlspecialchars($_POST['body']).'</sms_message>');
    }
  }
  echo('</reply>');
} 
else { echo('<reply/>'); }
?>

From this example, we've created a messaging group consisting of four people. The SMS request POSTs the “from” variable and we can set up our code to exclude the sender from our reply. We can also use the POST variable “body” to forward the message on to everyone else in the group.

The code allows for the following SMS exchange:

Michael: Has anyone paid the insurance bill? (Bob, Lindsay and Jim receive SMS message) Bob: When is it due? (Michael, Lindsay and Jim receive SMS message) Michael: Next Monday? (Bob, Lindsay and Jim receive SMS message) Jim: I might have? I'll have to check, Michael. (Michael, Bob and Lindsay receive SMS message) Lindsay: No, he didn't. (Michael, Bob and Jim receive SMS message)

The <sms_message> Tag

The <sms_message> tag supports a number of optional parameters that can be used to build more advanced SMS applications. These attributes give you the ability to send SMS messages to multiple recipients from any of your SMS numbers as well as setting up callback URLs so that you can be notified when the messages have been sent. Here is the full list of supported attributes:

Attribute

Description

to

Phone number that the SMS message will be sent to Note: You must include a '1' before the 10 digit phone number. If the 'to' attribute is not provided, the default is set to the originating phone number that sent the SMS message.

from

Phone number that the SMS will appear from Note: This phone number must appear as an “SMS Number” on the “Account Configuration” page in your Plum DEV account. Any attempt to reply using an SMS using a number not listed as an “SMS Number” in your account will fail. If the 'from' attribute is not provided, the default is set to the SMS number that received the SMS message. Your SMS-enabled number must be non-PCI. SMS is unencrypted, which makes SMS messaging incompatible with PCI numbers and infrastructure.

result_url

URL for tracking the SMS result status Note: After the SMS is sent, this URL will receive a POST with the following variables: 'sms_message_id' and 'status'. This should be used to get the status of an SMS message. If the 'result_url' attribute is not provided, the default is set to no result URL being used.

Here is an example application that sends three SMS messages as a response to an incoming message:

<?xml version="1.0"?>
<reply>
    <sms_message to="12125550000" from="6177123000">Yeah, mom's awesome. We should call her!</sms_message>
    <sms_message to="12125550001" from="6177123000">There's always money in the banana stand!</sms_message>
    <sms_message to="12125550002" from="6177123000">Return from whence you came!</sms_message>
</reply>

Last updated