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

MessageUUID SMS, MMS, WhatsApp LC, TF, SC

The unique identifier for the message.

From SMS, MMS, WhatsApp LC, TF, SC

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

To SMS, MMS, WhatsApp LC, TF, SC

The Plivo number on which the message was received.

Text SMS LC, TF, SC

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

Body MMS, WhatsApp LC, 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).

Type SMS, MMS, WhatsApp LC, TF, SC

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

Units SMS, MMS LC, 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.

TotalRate SMS, MMS, WhatsApp LC, TF, SC

The charge applicable per incoming message unit.

TotalAmount SMS, MMS, WhatsApp LC, TF, SC

The total charge for receiving the SMS (TotalRate * number of Units).

ContentType WhatsApp

Specifies the content type of inbound WhatsApp message. Allowed values: text, media, button, unknown

MimeType WhatsApp

Valid for inbound WhatsApp media only. Specifies the type of media file — for example, video/mp4.

ErrorCode WhatsApp,MMS LC, TF

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

This parameter is only defined for failed or undelivered messages.

Context WhatsApp

Json object. An object containing the ID of a previous message to which you are replying.

Example -

“Context”:{
"MessageUUID":"1Aff6e1cc-1d26-42a0-ba55-b748fc8013d"
}

Button WhatsApp

Json object. This is present when the ContentType is button.

Contains two fields -

Text - Display text on the button you have configured in the template

Payload - Developer-defined payload that is returned when the button is clicked in addition to the display text on the button.

Example -

"Button":{
"Text":"Yes",
"Payload":"Yes-Button-Payload"
}

MessageIntent SMS LC, 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.

PowerpackUUID SMS, MMS LC, 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.

MediaCount MMS LC, 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.

Replying to an incoming message

You can reply to an incoming message (except for WhatsApp) by returning a Plivo Message XML element in the response to the incoming request.

Set the response Content-Type to application/xml.