You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add trigger_broadcast to APIClient
Adds TriggerBroadcastRequest and APIClient#trigger_broadcast for the
POST /v1/campaigns/{broadcast_id}/triggers endpoint. Supports all
audience options (recipients, emails, ids, per_user_data, data_file_url)
with validation that only one audience type is provided per request.
Closes#100
Copy file name to clipboardExpand all lines: README.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -401,6 +401,45 @@ rescue Customerio::InvalidResponse => e
401
401
end
402
402
```
403
403
404
+
### Trigger Broadcasts
405
+
406
+
You can trigger [API-triggered broadcasts](https://customer.io/docs/api-triggered-broadcasts/) using the `APIClient`. Create a `TriggerBroadcastRequest` with the broadcast's numeric ID and optional audience/data parameters.
407
+
408
+
```ruby
409
+
require"customerio"
410
+
411
+
client =Customerio::APIClient.new("your API key", region:Customerio::Regions::US)
412
+
413
+
request =Customerio::TriggerBroadcastRequest.new(
414
+
broadcast_id:12,
415
+
emails: ["recipient@example.com"],
416
+
data: {
417
+
headline:"Roadrunner spotted in Albuquerque!",
418
+
date:1511315635,
419
+
},
420
+
email_add_duplicates:false,
421
+
email_ignore_missing:false,
422
+
id_ignore_missing:false,
423
+
)
424
+
425
+
begin
426
+
response = client.trigger_broadcast(request)
427
+
puts response
428
+
rescueCustomerio::InvalidResponse => e
429
+
puts e.code, e.message
430
+
end
431
+
```
432
+
433
+
You can target the broadcast audience in several ways. Only one audience option can be present per request:
434
+
435
+
-`recipients`: a hash with filter conditions (e.g., `{ segment: { id: 7 } }`)
436
+
-`emails`: an array of email addresses
437
+
-`ids`: an array of customer IDs
438
+
-`per_user_data`: an array of per-user objects
439
+
-`data_file_url`: a URL to a JSON lines file
440
+
441
+
If you omit the audience option, the broadcast uses its default audience configured in the UI.
0 commit comments