Latest Legacy

Handling incoming SMS/MMS/WhatsApp

Plivo forwards incoming messages to the message_url configured for the application associated with the phone number on which the message was received.

Certain values provided in the list of attributes below will be posted to your callback based on the number type (long code, toll-free, or short code) and message type (SMS or MMS). We’ve updated the availability of these attributes under the name attribute.

Note: LC — long code, TF — toll-free, SC — short code

Attributes

MessageUUIDSMS,WhatsApp,MMSLC, TF, SC

The unique identifier for the message.

FromSMS,WhatsApp,MMSLC, TF, SC

The source number of the incoming message — the phone number from which the message originated.

ToSMS,WhatsApp,MMSLC, TF, SC

The Plivo number on which the message was received.

TextSMSLC, TF, SC

The content of the message. Note that Plivo automatically concatenates multipart long messages before forwarding them to your message_url.

BodyWhatsApp,MMSLC, TF

The text content (if any) in the multimedia message (MMS). Together, Body and Media should not exceed 5MB.

For WhatsApp, any inbound text content (with or without media) will be populated here.

TypeSMS, WhatsApp,MMSLC, TF, SC

Allowed values:  sms, mms, whatsapp
Defaults to sms.

UnitsSMS, MMSLC, TF, SC

The number of parts in which the incoming message was received. This is > 1 for multipart long messages.

For whatsapp, this is always 1. 

TotalRateSMS,WhatsApp,MMSLC, TF, SC

The charge applicable per incoming message unit.

TotalAmountSMS,WhatsApp,MMSLC, TF, SC

Total charge for receiving the SMS (TotalRate * number of Units)

MessageIntentSMSLC, TF

Set to optout if the incoming message matches with one of the standard opt-out keywords. Set to optin if the incoming message matches with one of the standard opt-in keywords. Set to help if the incoming message matches with one of the standard help keywords. Left blank in all other cases.

PowerpackUUIDSMS, MMSLC, TF, SC

The UUID of the Powerpack associated with the To phone number. If the phone number does not belong to a Powerpack, this field is empty.

MediaCountMMSLC, TF

The number of media files attached with this MMS message.

Media<count> ex: Media1, Media2 ...MMS LC, TF

The URL to a specific media file associated with the MMS message. The integer suffixes range from 1 to the count of media files received.

ContentTypeWhatsAppLC, TF

WhatsApp only attribute

Specifies the content type of inbound message. Possible values are test, media, unknown

MimeTypeWhatsAppLC, TF

WhatsApp only attribute

Valid for inbound media only. Specifies the type of media file. ex: video/mp4
ErrorCodeWhatsApp,MMSLC, TF

The Plivo error code that identifies the reason for the inbound message delivery failure.

This parameter is only defined for “failed” or “undelivered” messages.

Replying to an incoming message

It is possible to reply to an incoming message by returning a Plivo Message XML element in the response to the incoming request.

Make sure to set the response Content-Type to application/xml in this case.

Example Request

1
1
1
1
1
1
1
1