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
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:
Parameter | Description | Format | Obligation |
---|---|---|---|
list_id | list of users that you want to send broadcast messages to. | text | Mandatory |
template | It 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 | text | Mandatory |
notification_category | You can understand more about them in the Notification Category documentation | system / transactional / promotional | Mandatory |
channels | User 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-string | Optional |
delay | Broadcast 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_at | Trigger broadcast on a specific date-time | date string in ISO 8601 eg. "2021-08-27T20:14:51.643Z" | Optional |
data | variable data defined in templates | JSON "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)
Updated 8 months ago