Use SMS gateway services to forward all incoming SMS messages directly to your web server in near real time. The forward process is performed by the SMS business partner. Before you can use this service, contact the provisioning team to enable it for your organization.
For added security, you can add firewall rules to only allow traffic from the following IP addresses: 208.71.240.0/21.
Dedicated code (short or long code)
If you are using a dedicated short or long code, the service posts all incoming messages to your web server. This option is not available for shared codes.
- Name of your Acoustic Campaign organization (org)
- Code type: Short or long code
- URL for your web server: The gateway must be publicly accessible. Make sure to update the required firewall settings to receive the traffic.
Dedicated OR shared code (short or long code)
For incoming messages, only messages that match the specific keywords are auto-forwarded.
- Name of your Acoustic Campaign organization (org)
- Code type: Short or long code
- Keyword(s): Used for various SMS programs, such as text to join, text for info, etc.
- URL for your web server: The gateway must be publicly accessible. Make sure to update the required firewall settings to receive the traffic.
Sample MO SMS post and HTTPS POST parameters
Note: Examples used in this section are simply for reference. They are from customers that use Kaleyra (formerly mGage) as an SMS aggregator.
This is an example of a mobile originating (MO) post that you might expect to receive directly from the SMS partner's gateway, in near real-time, when the SMS message is received from the end-user.
device_address=1447ß7665544&inbound_address=26161&router=cingular&carrier=cingular&channel=sms&message_orig=Hello+from+SMPPSim&message=Hello+from+SMPPSim&message_id=148929155953&message_subid=0&status=Processing&status_code=10&a2w_mo_ref_id=148929155953&country_code=1
The SMS business partner performs an HTTPS POST back to the client. The following fields are provided as part of the payload:
Table 1. Message notification contents. The MO messages are form-encoded and are delivered to your URL as an HTTP POST (just as an HTML form submission would be). The following post parameters are sent: | |
Key | Description |
attachment | An mGage-assigned ID that is given to the attachment sent by the end user. Use this ID. |
carrier | Carrier from which the subscriber MO originated. |
channel | Channel that is used that is for SMS message delivery. |
device_address | Mobile number of the wireless device that is sending the message. |
inbound_address | A source address that is hosted by Kaleyra (formerly mGage) systems and registered with the carrier to which a subscriber sends a subscriber MO. |
message | SMS message body content that the recipient receives. Kaleyra (formerly mGage) might strip some unnecessary characters from the original message. |
message_id | An mGage-assigned message ID that is given to a message when the SMS MO is received from the carrier. |
message_orig | SMS message body content as originally sent by the subscriber from their mobile device. |
mmsID | mGage-assigned message ID that is given to a message when the MMS MO is received from the carrier. |
router | Value that identifies the Kaleyra (formerly mGage) router through which the message was submitted. |
status | This parameter is empty. |
status_code | This parameter is empty. |
Sample code to process incoming MO SMS: Receiving a message or status notification
The following example uses the CGI module to extract components of a MO or status notification and write the values to the log file called "DirectTEXTReceived.text".
#
#Example of processing mGage DirectTEXT MO/status notifications with Perl.
#
use strict;
use CGI;
# Load POST data into a new CGI object
my $query = new CGI;
# Extract values and create timestamped output line
my $output;
$output = scalar(localtime(time)) . " -- ";
$output .= "Carrier: " . $query->param('carrier') . "; ";
$output .= "Channel: " . $query->param('channel') . "; ";
$output .= "Device address: " . $query->param('device_address') . "\n";
# Write output to file
open(FILEH, ">>DirectTextReceived.txt") || die("Cannot open log file: $!\n");
print(FILEH $output);
close(FILEH);
Process incoming messages that fail to post
Note: Any example used in this section is simply for reference, as examples are from customers that use Kaleyra (formerly mGage) as an SMS aggregator.
When an attempt to post incoming SMS messages to the client's web server fails, the SMS gateway retries to post this message. The gateway retries at the following intervals (in minutes): 1, 5, 10, 60, 120, 360, 720.
Next, the gateway stops doing retry for this message and permanently deletes it from the queue for the posting to your web server.