Broadcast

Method to trigger broadcast messages using python SDK

You can use this method to send instant notifications to a list of users.

Pre-requisites

Create a list of users

Data Structure of Broadcast body

Brodcast body with all possible configurations

broadcast_body = {
  "list_id": "_list_id_",
  "template": "_template_slug_",
  "notification_category": "_",
  "channels": [],
  "delay": "_time_delay_",
  "trigger_at": "_ISO_timestamp_",
  "data": {
    "key1": "value1",
    "key2": "value2"

  }

Broadcast body field description:

ParameterDescriptionFormatObligation
list_idlist of users that you want to send broadcast messages to.textMandatory
templateIt is the unique slug of the template created on SuprSend platform. You can get this slug by clicking on the clipboard icon next to the Template name on SuprSend templates page.
It is the same for all channels
textMandatory
notification_categoryYou can understand more about them in the Notification Category documentationsystem / transactional / promotionalMandatory
channelsUser channels on which the broadcast messages to be sent. If not provided, it will trigger message on all available channels in user profile.
Currently, broadcast is supported in iospush and androidpush channel. So, please specify these channels in your broadcast body
comma-separated-stringOptional
delayBroadcast will be halted for the time mentioned in delay, and become active once the delay period is over.XXdXXhXXmXXs or if its number (n) then delay is in seconds (n)Optional
trigger_atTrigger broadcast on a specific date-timedate string in ISO 8601
eg. "2021-08-27T20:14:51.643Z"
Optional
datavariable data defined in templatesJSON
"data":
{ "key": {
"key": "value",
"key": "value"
}
},
Optional

Sample broadcast body

broadcast_body = {
  "list_id": "bulk_list",
  "template": "purchase-confirmation",
  "notification_category": "transactional",
  "channels": ["iospush"],
  # "delay": 30,
  # "trigger_at": "2022-12-27T11:14:51.643Z",
  "data": {
    "amount": "$100",
    "product_name": "Medicines"
  }

Triggering Broadcast

You can trigger broadcast using supr_client.subscriber_lists.broadcast() method.

from suprsend import Suprsend,  SuprsendAPIException, SubscriberListBroadcast

supr_client = Suprsend(
  "_api_key_",
  "_api_secret_",
)

broadcast_body = {...}

inst = SubscriberListBroadcast(body=broadcast_body)
resp = supr_client.subscriber_lists.broadcast(inst)
print(resp)