Pre-requisites

Create a list of users

Trigger Broadcast

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

const { Suprsend, SubscriberListBroadcast } = require("@suprsend/node-sdk");

const supr_client = new Suprsend("workspace_key", "workspace_secret");

// prepare payload
const broadcast_body = {
  list_id: "_list_id_",
  template: "_template_slug_",
  notification_category: "_",
  channels: [],
  delay: "_time_delay_",
  trigger_at: "_ISO_timestamp_"/"number in seconds",
  data: {
    key1: "value1",
    key2: "value2",
  },
};

const broadcast_instance = new SubscriberListBroadcast(broadcast_body, {tenant_id : "your_tenant_id", idempotency_key="__uniq_request_id__"}); // create broadcast instance

const response = supr_client.subscriber_lists.broadcast(inst); // trigger broadcast
response.then((res) => console.log("response", res));
ParameterDescription
list_idlist of users that you want to send broadcast messages.
templateIt is the template slug which can be found in Templates tab in SuprSend dashboard.
notification_categoryPreference Category to apply user preference settings while sending. Root categories - system / transactional / promotional
channels (Optional)User channels on which the broadcast messages to be sent. If not provided, it will trigger notifications on all available channels in user profile. Available channels: androidpush / iospush / inbox / email / whatsapp / sms Example:[“sms”, “inbox”]
delay (Optional)Broadcast will be halted for the time mentioned in delay, and become active once the delay period is over. Example: 1d2h3m4s / 60
trigger_at (Optional)Trigger broadcast on a specific date-time. Example: “2021-08-27T20:14:51.643Z”
data (Optional)variable data defined in templates

Add file attachment (for email)

To add one or more attachments to a notification (viz. Email), call add_attachment() on broadcast instance for each attachment file. Ensure that attachment url is valid and public, otherwise error will be raised. Since broadcast instance size can’t be > 100 KB, local file paths can’t be passed in event attachment.

const broadcast_instance = new SubscriberListBroadcast(broadcast_body);

broadcast_instance.add_attachment("https://www.adobe.com/sample_file.pdf");

🚧 A single broadcast instance size (including attachment) must not exceed 100KB (100 x 1024 bytes).