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
- 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
* 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)
* For text messages containing media files, this is an array of objects with the
properties `url`, `type` (MIME type), `filename`, and `size` (file size in bytes).
Unknown properties are null. This property is undefined for messages that do not
contain media files. Note: For files uploaded via the Telerivet web app, the URL is
temporary and may not be valid for more than 1 day.
* 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
- 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
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
- #label_ids ⇒ Object
- #last_message_time ⇒ Object
- #last_reply_time ⇒ Object
- #last_send_time ⇒ Object
- #media ⇒ Object
- #message_count ⇒ Object
- #message_type ⇒ Object
- #price ⇒ Object
- #price_currency ⇒ Object
- #project_id ⇒ Object
- #recipients ⇒ 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
- #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
256 257 258 |
# File 'lib/telerivet/broadcast.rb', line 256 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
207 208 209 210 |
# File 'lib/telerivet/broadcast.rb', line 207 def cancel() require_relative 'broadcast' Broadcast.new(@api, @api.do_request("POST", get_base_api_path() + "/cancel")) end |
#clicked_count ⇒ Object
288 289 290 |
# File 'lib/telerivet/broadcast.rb', line 288 def clicked_count get('clicked_count') end |
#content ⇒ Object
252 253 254 |
# File 'lib/telerivet/broadcast.rb', line 252 def content get('content') end |
#estimated_count ⇒ Object
244 245 246 |
# File 'lib/telerivet/broadcast.rb', line 244 def estimated_count get('estimated_count') end |
#get_base_api_path ⇒ Object
336 337 338 |
# File 'lib/telerivet/broadcast.rb', line 336 def get_base_api_path() "/projects/#{get('project_id')}/broadcasts/#{get('id')}" end |
#id ⇒ Object
212 213 214 |
# File 'lib/telerivet/broadcast.rb', line 212 def id get('id') end |
#label_ids ⇒ Object
292 293 294 |
# File 'lib/telerivet/broadcast.rb', line 292 def label_ids get('label_ids') end |
#last_message_time ⇒ Object
228 229 230 |
# File 'lib/telerivet/broadcast.rb', line 228 def get('last_message_time') end |
#last_reply_time ⇒ Object
316 317 318 |
# File 'lib/telerivet/broadcast.rb', line 316 def last_reply_time get('last_reply_time') end |
#last_send_time ⇒ Object
232 233 234 |
# File 'lib/telerivet/broadcast.rb', line 232 def last_send_time get('last_send_time') end |
#media ⇒ Object
296 297 298 |
# File 'lib/telerivet/broadcast.rb', line 296 def media get('media') end |
#message_count ⇒ Object
240 241 242 |
# File 'lib/telerivet/broadcast.rb', line 240 def get('message_count') end |
#message_type ⇒ Object
248 249 250 |
# File 'lib/telerivet/broadcast.rb', line 248 def get('message_type') end |
#price ⇒ Object
304 305 306 |
# File 'lib/telerivet/broadcast.rb', line 304 def price get('price') end |
#price_currency ⇒ Object
308 309 310 |
# File 'lib/telerivet/broadcast.rb', line 308 def price_currency get('price_currency') end |
#project_id ⇒ Object
332 333 334 |
# File 'lib/telerivet/broadcast.rb', line 332 def project_id get('project_id') end |
#recipients ⇒ Object
216 217 218 |
# File 'lib/telerivet/broadcast.rb', line 216 def recipients get('recipients') end |
#replace_variables ⇒ Object
268 269 270 |
# File 'lib/telerivet/broadcast.rb', line 268 def replace_variables get('replace_variables') end |
#reply_count ⇒ Object
312 313 314 |
# File 'lib/telerivet/broadcast.rb', line 312 def reply_count get('reply_count') end |
#route_id ⇒ Object
320 321 322 |
# File 'lib/telerivet/broadcast.rb', line 320 def route_id get('route_id') end |
#route_params ⇒ Object
300 301 302 |
# File 'lib/telerivet/broadcast.rb', line 300 def route_params get('route_params') end |
#service_id ⇒ Object
324 325 326 |
# File 'lib/telerivet/broadcast.rb', line 324 def service_id get('service_id') end |
#simulated ⇒ Object
280 281 282 |
# File 'lib/telerivet/broadcast.rb', line 280 def simulated get('simulated') end |
#source ⇒ Object
276 277 278 |
# File 'lib/telerivet/broadcast.rb', line 276 def source get('source') end |
#status ⇒ Object
272 273 274 |
# File 'lib/telerivet/broadcast.rb', line 272 def status get('status') end |
#status_counts ⇒ Object
236 237 238 |
# File 'lib/telerivet/broadcast.rb', line 236 def status_counts get('status_counts') end |
#time_created ⇒ Object
224 225 226 |
# File 'lib/telerivet/broadcast.rb', line 224 def time_created get('time_created') end |
#title ⇒ Object
220 221 222 |
# File 'lib/telerivet/broadcast.rb', line 220 def title get('title') end |
#track_clicks ⇒ Object
284 285 286 |
# File 'lib/telerivet/broadcast.rb', line 284 def track_clicks get('track_clicks') end |
#tts_lang ⇒ Object
260 261 262 |
# File 'lib/telerivet/broadcast.rb', line 260 def tts_lang get('tts_lang') end |
#tts_voice ⇒ Object
264 265 266 |
# File 'lib/telerivet/broadcast.rb', line 264 def tts_voice get('tts_voice') end |
#user_id ⇒ Object
328 329 330 |
# File 'lib/telerivet/broadcast.rb', line 328 def user_id get('user_id') end |