Skip to main content
Use the Message element to send a message during your call flow. For instance, if you want to send out an SMS notification when you receive an incoming call on your Plivo number, you can use the <Message> element in your application. To receive a message, you must set a message URL in your Plivo application via the API or in the Plivo console at Messaging > Applications.

Attributes

Here are the attributes the Message element supports. You can modify the default behavior of each attribute by using the allowed values.
NameTypeDescription
srcstringSource number — for example, 12025550000. Must be a purchased, valid number.
dststringDestination number. Must be a valid number. To use bulk numbers, specify them separated by < — for example, 12025551111<12025552222.
typestringType of the message. Allowed values: sms
callbackUrlstringA valid, reachable URL that Plivo notifies when a response is available and to which the response is sent (Delivery reports).
callbackMethodstringThe method used to notify the callbackUrl. Allowed values: GET, POST. Defaults to POST.

Example

This example XML document is used to send out an SMS message. Plivo sends a delivery report to the callback URL using the HTTP POST method.
from plivo import plivoxml

response = plivoxml.ResponseElement()
response.add(
    plivoxml.MessageElement(
        'Hi, this is a sample text',
        src='+12025550000',
        dst='+12025551111',
        type='sms',
        callback_url='https://<yourdomain>.com/sms_status/',
        callback_method='POST'))
print(response.to_string())

Response

<Response>
  <Message src="12022220000" dst="12025551111" type="sms" callbackUrl="https://<yourdomain>.com/sms_status/" callbackMethod="POST">
    Hi, this is a text message
  </Message>
</Response>