Class: Telerivet::Broadcast
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
- #audio_url ⇒ Object
-
#cancel ⇒ Object
Cancels sending a broadcast that has not yet been completely sent.
- #clicked_count ⇒ Object
- #content ⇒ Object
- #estimated_count ⇒ Object
- #get_base_api_path ⇒ Object
- #id ⇒ Object
- #is_template ⇒ Object
- #label_ids ⇒ Object
- #last_message_time ⇒ Object
- #last_reply_time ⇒ Object
- #last_send_time ⇒ Object
- #media ⇒ Object
- #message_count ⇒ Object
- #message_type ⇒ Object
- #num_parts ⇒ Object
- #price ⇒ Object
- #price_currency ⇒ Object
- #project_id ⇒ Object
- #recipients ⇒ Object
- #recipients_str ⇒ Object
- #replace_variables ⇒ Object
- #reply_count ⇒ Object
- #route_id ⇒ Object
- #route_params ⇒ Object
- #service_id ⇒ Object
- #simulated ⇒ Object
- #source ⇒ Object
- #status ⇒ Object
- #status_counts ⇒ Object
- #time_created ⇒ Object
- #title ⇒ Object
- #track_clicks ⇒ Object
- #tts_lang ⇒ Object
- #tts_voice ⇒ Object
- #url ⇒ Object
- #user_id ⇒ Object
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_url ⇒ Object
278 279 280 |
# File 'lib/telerivet/broadcast.rb', line 278 def audio_url get('audio_url') end |
#cancel ⇒ Object
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_count ⇒ Object
310 311 312 |
# File 'lib/telerivet/broadcast.rb', line 310 def clicked_count get('clicked_count') end |
#content ⇒ Object
274 275 276 |
# File 'lib/telerivet/broadcast.rb', line 274 def content get('content') end |
#estimated_count ⇒ Object
262 263 264 |
# File 'lib/telerivet/broadcast.rb', line 262 def estimated_count get('estimated_count') end |
#get_base_api_path ⇒ Object
370 371 372 |
# File 'lib/telerivet/broadcast.rb', line 370 def get_base_api_path() "/projects/#{get('project_id')}/broadcasts/#{get('id')}" end |
#id ⇒ Object
230 231 232 |
# File 'lib/telerivet/broadcast.rb', line 230 def id get('id') end |
#is_template ⇒ Object
362 363 364 |
# File 'lib/telerivet/broadcast.rb', line 362 def is_template get('is_template') end |
#label_ids ⇒ Object
314 315 316 |
# File 'lib/telerivet/broadcast.rb', line 314 def label_ids get('label_ids') end |
#last_message_time ⇒ Object
246 247 248 |
# File 'lib/telerivet/broadcast.rb', line 246 def get('last_message_time') end |
#last_reply_time ⇒ Object
338 339 340 |
# File 'lib/telerivet/broadcast.rb', line 338 def last_reply_time get('last_reply_time') end |
#last_send_time ⇒ Object
250 251 252 |
# File 'lib/telerivet/broadcast.rb', line 250 def last_send_time get('last_send_time') end |
#media ⇒ Object
318 319 320 |
# File 'lib/telerivet/broadcast.rb', line 318 def media get('media') end |
#message_count ⇒ Object
258 259 260 |
# File 'lib/telerivet/broadcast.rb', line 258 def get('message_count') end |
#message_type ⇒ Object
270 271 272 |
# File 'lib/telerivet/broadcast.rb', line 270 def get('message_type') end |
#num_parts ⇒ Object
266 267 268 |
# File 'lib/telerivet/broadcast.rb', line 266 def num_parts get('num_parts') end |
#price ⇒ Object
326 327 328 |
# File 'lib/telerivet/broadcast.rb', line 326 def price get('price') end |
#price_currency ⇒ Object
330 331 332 |
# File 'lib/telerivet/broadcast.rb', line 330 def price_currency get('price_currency') end |
#project_id ⇒ Object
358 359 360 |
# File 'lib/telerivet/broadcast.rb', line 358 def project_id get('project_id') end |
#recipients ⇒ Object
234 235 236 |
# File 'lib/telerivet/broadcast.rb', line 234 def recipients get('recipients') end |
#recipients_str ⇒ Object
366 367 368 |
# File 'lib/telerivet/broadcast.rb', line 366 def recipients_str get('recipients_str') end |
#replace_variables ⇒ Object
290 291 292 |
# File 'lib/telerivet/broadcast.rb', line 290 def replace_variables get('replace_variables') end |
#reply_count ⇒ Object
334 335 336 |
# File 'lib/telerivet/broadcast.rb', line 334 def reply_count get('reply_count') end |
#route_id ⇒ Object
342 343 344 |
# File 'lib/telerivet/broadcast.rb', line 342 def route_id get('route_id') end |
#route_params ⇒ Object
322 323 324 |
# File 'lib/telerivet/broadcast.rb', line 322 def route_params get('route_params') end |
#service_id ⇒ Object
346 347 348 |
# File 'lib/telerivet/broadcast.rb', line 346 def service_id get('service_id') end |
#simulated ⇒ Object
302 303 304 |
# File 'lib/telerivet/broadcast.rb', line 302 def simulated get('simulated') end |
#source ⇒ Object
298 299 300 |
# File 'lib/telerivet/broadcast.rb', line 298 def source get('source') end |
#status ⇒ Object
294 295 296 |
# File 'lib/telerivet/broadcast.rb', line 294 def status get('status') end |
#status_counts ⇒ Object
254 255 256 |
# File 'lib/telerivet/broadcast.rb', line 254 def status_counts get('status_counts') end |
#time_created ⇒ Object
242 243 244 |
# File 'lib/telerivet/broadcast.rb', line 242 def time_created get('time_created') end |
#title ⇒ Object
238 239 240 |
# File 'lib/telerivet/broadcast.rb', line 238 def title get('title') end |
#track_clicks ⇒ Object
306 307 308 |
# File 'lib/telerivet/broadcast.rb', line 306 def track_clicks get('track_clicks') end |
#tts_lang ⇒ Object
282 283 284 |
# File 'lib/telerivet/broadcast.rb', line 282 def tts_lang get('tts_lang') end |
#tts_voice ⇒ Object
286 287 288 |
# File 'lib/telerivet/broadcast.rb', line 286 def tts_voice get('tts_voice') end |
#url ⇒ Object
350 351 352 |
# File 'lib/telerivet/broadcast.rb', line 350 def url get('url') end |
#user_id ⇒ Object
354 355 356 |
# File 'lib/telerivet/broadcast.rb', line 354 def user_id get('user_id') end |