Class: Telerivet::Broadcast

Inherits:
Entity
  • Object
show all
Defined in:
lib/telerivet/broadcast.rb

Overview

Represents a collection of related outgoing messages. Typically, messages in a broadcast have the same content template and were sent at the same time; however, a broadcast can also contain messages with unrelated content and messages that were sent at different times. A broadcast is automatically created when sending a message to a group of contacts.

Fields:

- id (string, max 34 characters)
  * ID of the broadcast
  * Read-only

- recipients (array of objects)
  * List of recipients. Each recipient is an object with a string `type` property, which
      may be `"phone_number"`, `"group"`, or `"filter"`.
      
      If the type is `"phone_number"`, the `phone_number` property will
      be set to the recipient's phone number.
      
      If the type is `"group"`, the `group_id` property will be set to
      the ID of the group, and the `group_name` property will be set to the name of the
      group.
      
      If the type is `"filter"`, the `filter_type` property (string) and
      `filter_params` property (object) describe the filter used to send the broadcast. (API
      clients should not rely on a particular value or format of the `filter_type` or
      `filter_params` properties, as they may change without notice.)
  * Read-only

- title
  * Title of the broadcast. If a title was not provided when the broadcast was sent, it
      is automatically set to a human readable description of the first few recipients
      (possibly truncated)
  * Read-only

- time_created (UNIX timestamp)
  * Time the broadcast was sent in Telerivet
  * Read-only

- last_message_time (UNIX timestamp)
  * Time the most recent message was queued to send in this broadcast
  * Read-only

- last_send_time (UNIX timestamp)
  * Time the most recent message was sent (or failed to send) in this broadcast, or null
      if no messages have been sent yet
  * Read-only

- status_counts (Hash)
  * An object whose keys are the possible status codes (`"queued"`, `"sent"`,
      `"failed"`, `"failed_queued"`, `"delivered"`, `"not_delivered"`, and `"cancelled"`),
      and whose values are the number of messages in the broadcast currently in that status.
  * Read-only

- message_count (int)
  * The total number of messages created for this broadcast. For large broadcasts, the
      messages may not be created immediately after the broadcast is sent. The
      `message_count` includes messages in any status, including messages that are still
      queued.
  * Read-only

- estimated_count (int)
  * The estimated number of messages in this broadcast when it is complete. The
      `estimated_count` is calculated at the time the broadcast is sent. When the broadcast
      is completed, the `estimated_count` may differ from `message_count` if there are any
      blocked contacts among the recipients (blocked contacts are included in
      `estimated_count` but not in `message_count`), if any contacts don't have phone
      numbers, or if the group membership changed while the broadcast was being sent.
  * Read-only

- num_parts (number)
  * The total number of SMS parts that have been sent in this broadcast. The number of
      SMS parts does not include messages that are still queued, or messages that failed to
      send.
  * Read-only

- message_type
  * Type of message sent from this broadcast
  * Allowed values: sms, mms, ussd, ussd_session, call, chat, service
  * Read-only

- content (string)
  * The text content of the message (null for USSD messages and calls)
  * Read-only

- audio_url
  * For voice calls, the URL of an MP3 file to play when the contact answers the call
  * Read-only

- tts_lang
  * For voice calls, the language of the text-to-speech voice
  * Allowed values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA,
      de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
  * Read-only

- tts_voice
  * For voice calls, the text-to-speech voice
  * Allowed values: female, male
  * Read-only

- replace_variables (bool)
  * Set to true if Telerivet will render variables like [[contact.name]] in the message
      content, false otherwise
  * Read-only

- status
  * The current status of the broadcast.
  * Allowed values: queuing, sending, complete, cancelled
  * Read-only

- source
  * How the message originated within Telerivet
  * Allowed values: phone, provider, web, api, service, webhook, scheduled, integration,
      mcp
  * Read-only

- simulated (bool)
  * Whether this message was simulated within Telerivet for testing (and not actually
      sent to or received by a real phone)
  * Read-only

- track_clicks (boolean)
  * If true, URLs in the message content will automatically be replaced with unique
      short URLs.
  * Read-only

- clicked_count (int)
  * The number of messages in this broadcast containing short links that were clicked.
      At most one click per message is counted. If track_clicks is false, this property will
      be null.
  * Read-only

- label_ids (array)
  * List of IDs of labels applied to all messages in the broadcast
  * Read-only

- media (array)
  * Array of media attachments for the text message. This property is undefined for
      messages that do not contain media files.
  * Read-only

- vars (Hash)
  * Custom variables stored for this broadcast. Variable names may be up to 32
      characters in length and can contain the characters a-z, A-Z, 0-9, and _.
      Values may be strings, numbers, or boolean (true/false).
      String values may be up to 4096 bytes in length when encoded as UTF-8.
      Up to 100 variables are supported per object.
      Setting a variable to null will delete the variable.
  * Read-only

- route_params (Hash)
  * Route-specific parameters for the messages in the broadcast.
      
      When sending messages via chat apps such as WhatsApp, the route_params
      parameter can be used to send messages with app-specific features such as quick
      replies and link buttons.
      
      For more details, see [Route-Specific Parameters](#route_params).
  * Read-only

- price (number)
  * The total price of all messages in this broadcast, if known.
  * Read-only

- price_currency
  * The currency of the message price, if applicable.
  * Read-only

- reply_count (int)
  * The number of replies received in response to a message sent in this broadcast.
      (Replies are not included in `message_count` ,`status_counts`, or `price`.)
  * Read-only

- last_reply_time (UNIX timestamp)
  * Time the most recent reply was received in response to a message sent in this
      broadcast, or null if no replies have been sent yet
  * Read-only

- route_id (string, max 34 characters)
  * ID of the phone or route used to send the broadcast (if applicable)
  * Read-only

- service_id (string, max 34 characters)
  * The service associated with this broadcast (for voice calls, the service defines the
      call flow)
  * Read-only

- url
  * URL to this broadcast in the Telerivet web app
  * Read-only

- user_id (string, max 34 characters)
  * ID of the Telerivet user who sent the broadcast (if applicable)
  * Read-only

- project_id
  * ID of the project this broadcast belongs to
  * Read-only

- is_template (bool)
  * Set to true if Telerivet will render variables like [[contact.name]] in the message
      content
  * Read-only

- recipients_str (string)
  * A string with a human readable description of the first few recipients (possibly
      truncated)
  * Read-only

Instance Method Summary collapse

Methods inherited from Entity

#get, #initialize, #load, #save, #set, #set_data, #to_s, #vars

Constructor Details

This class inherits a constructor from Telerivet::Entity

Instance Method Details

#audio_urlObject



278
279
280
# File 'lib/telerivet/broadcast.rb', line 278

def audio_url
    get('audio_url')
end

#cancelObject

Cancels sending a broadcast that has not yet been completely sent. No additional messages will be queued, and any existing queued messages will be cancelled when they would otherwise have been sent (except for messages already queued on the Telerivet Android app, which will not be automatically cancelled).

Returns: Telerivet::Broadcast



225
226
227
228
# File 'lib/telerivet/broadcast.rb', line 225

def cancel()
    require_relative 'broadcast'
    Broadcast.new(@api, @api.do_request("POST", get_base_api_path() + "/cancel"))
end

#clicked_countObject



310
311
312
# File 'lib/telerivet/broadcast.rb', line 310

def clicked_count
    get('clicked_count')
end

#contentObject



274
275
276
# File 'lib/telerivet/broadcast.rb', line 274

def content
    get('content')
end

#estimated_countObject



262
263
264
# File 'lib/telerivet/broadcast.rb', line 262

def estimated_count
    get('estimated_count')
end

#get_base_api_pathObject



370
371
372
# File 'lib/telerivet/broadcast.rb', line 370

def get_base_api_path()
    "/projects/#{get('project_id')}/broadcasts/#{get('id')}"
end

#idObject



230
231
232
# File 'lib/telerivet/broadcast.rb', line 230

def id
    get('id')
end

#is_templateObject



362
363
364
# File 'lib/telerivet/broadcast.rb', line 362

def is_template
    get('is_template')
end

#label_idsObject



314
315
316
# File 'lib/telerivet/broadcast.rb', line 314

def label_ids
    get('label_ids')
end

#last_message_timeObject



246
247
248
# File 'lib/telerivet/broadcast.rb', line 246

def last_message_time
    get('last_message_time')
end

#last_reply_timeObject



338
339
340
# File 'lib/telerivet/broadcast.rb', line 338

def last_reply_time
    get('last_reply_time')
end

#last_send_timeObject



250
251
252
# File 'lib/telerivet/broadcast.rb', line 250

def last_send_time
    get('last_send_time')
end

#mediaObject



318
319
320
# File 'lib/telerivet/broadcast.rb', line 318

def media
    get('media')
end

#message_countObject



258
259
260
# File 'lib/telerivet/broadcast.rb', line 258

def message_count
    get('message_count')
end

#message_typeObject



270
271
272
# File 'lib/telerivet/broadcast.rb', line 270

def message_type
    get('message_type')
end

#num_partsObject



266
267
268
# File 'lib/telerivet/broadcast.rb', line 266

def num_parts
    get('num_parts')
end

#priceObject



326
327
328
# File 'lib/telerivet/broadcast.rb', line 326

def price
    get('price')
end

#price_currencyObject



330
331
332
# File 'lib/telerivet/broadcast.rb', line 330

def price_currency
    get('price_currency')
end

#project_idObject



358
359
360
# File 'lib/telerivet/broadcast.rb', line 358

def project_id
    get('project_id')
end

#recipientsObject



234
235
236
# File 'lib/telerivet/broadcast.rb', line 234

def recipients
    get('recipients')
end

#recipients_strObject



366
367
368
# File 'lib/telerivet/broadcast.rb', line 366

def recipients_str
    get('recipients_str')
end

#replace_variablesObject



290
291
292
# File 'lib/telerivet/broadcast.rb', line 290

def replace_variables
    get('replace_variables')
end

#reply_countObject



334
335
336
# File 'lib/telerivet/broadcast.rb', line 334

def reply_count
    get('reply_count')
end

#route_idObject



342
343
344
# File 'lib/telerivet/broadcast.rb', line 342

def route_id
    get('route_id')
end

#route_paramsObject



322
323
324
# File 'lib/telerivet/broadcast.rb', line 322

def route_params
    get('route_params')
end

#service_idObject



346
347
348
# File 'lib/telerivet/broadcast.rb', line 346

def service_id
    get('service_id')
end

#simulatedObject



302
303
304
# File 'lib/telerivet/broadcast.rb', line 302

def simulated
    get('simulated')
end

#sourceObject



298
299
300
# File 'lib/telerivet/broadcast.rb', line 298

def source
    get('source')
end

#statusObject



294
295
296
# File 'lib/telerivet/broadcast.rb', line 294

def status
    get('status')
end

#status_countsObject



254
255
256
# File 'lib/telerivet/broadcast.rb', line 254

def status_counts
    get('status_counts')
end

#time_createdObject



242
243
244
# File 'lib/telerivet/broadcast.rb', line 242

def time_created
    get('time_created')
end

#titleObject



238
239
240
# File 'lib/telerivet/broadcast.rb', line 238

def title
    get('title')
end

#track_clicksObject



306
307
308
# File 'lib/telerivet/broadcast.rb', line 306

def track_clicks
    get('track_clicks')
end

#tts_langObject



282
283
284
# File 'lib/telerivet/broadcast.rb', line 282

def tts_lang
    get('tts_lang')
end

#tts_voiceObject



286
287
288
# File 'lib/telerivet/broadcast.rb', line 286

def tts_voice
    get('tts_voice')
end

#urlObject



350
351
352
# File 'lib/telerivet/broadcast.rb', line 350

def url
    get('url')
end

#user_idObject



354
355
356
# File 'lib/telerivet/broadcast.rb', line 354

def user_id
    get('user_id')
end