Skip to content

Add trigger broadcast method DEV-733#100

Closed
jeremygottfried wants to merge 3 commits into
customerio:mainfrom
MLH:jg-add-trigger-broadcast-request
Closed

Add trigger broadcast method DEV-733#100
jeremygottfried wants to merge 3 commits into
customerio:mainfrom
MLH:jg-add-trigger-broadcast-request

Conversation

@jeremygottfried
Copy link
Copy Markdown

@jeremygottfried jeremygottfried commented May 4, 2023

At MLH, we extended the customerio-ruby gem to add a method for the trigger broadcast API, aka /v1/campaigns/#{broadcast_id}/triggers

This feature has been very helpful for us, and we'd love to contribute to the base gem so everyone can use it.

Here's an example demonstrating how our code works:

require "customerio"

client = Customerio::APIClient.new("your API key", region: Customerio::Regions::US)

payload = {
  emails: [
    "recipient1@example.com",
    "anotherRecipient@example.com"
  ],
  data: {
    headline: "Roadrunner spotted in Albuquerque!",
    date: 1511315635,
    text: "We received reports of a roadrunner in your immediate area! Head to your dashboard to view more information!"
  },
  email_add_duplicates: false,
  email_ignore_missing: false,
  id_ignore_missing: false
}

request = Customerio::TriggerBroadcastRequest.new(
  broadcast_id: 12345,
  payload: payload
)

begin
  response = client.trigger_broadcast(request)
  puts response
rescue Customerio::InvalidResponse => e
  puts e.code, e.message
end

@skatkov
Copy link
Copy Markdown

skatkov commented Aug 2, 2023

It would be great to merge this PR and release. We're using this code on production as well, but we had to depend on our fork for this.

Is there anything we can help with here to get this merged?

@theycallmeswift
Copy link
Copy Markdown

Maybe @richdawe-cio can help? It seems like he's been actively maintaining the gem recently

@richdawe-cio
Copy link
Copy Markdown
Contributor

Thanks for opening this PR, and providing this feature to other folks.

I'm just going to close and re-open it, so the latest version of the GitHub Actions are run on the PR.

@theycallmeswift I'm going to talk with people internally to see if we can integrate this into the client library.

@theycallmeswift
Copy link
Copy Markdown

@richdawe-cio any update on this?

@lukeasrodgers
Copy link
Copy Markdown

I'd also find this helpful.

@hownowstephen
Copy link
Copy Markdown
Contributor

Closing in favor of #137, which implements the same feature fresh against current main. Thanks to @MLH for the original contribution that inspired this — the broadcast trigger API is now supported in the gem.

hownowstephen added a commit that referenced this pull request May 7, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants