1

I'm using Zapier Platform CLI and I'm having issues with firing the correct triggers.

I'm working with a legacy codebase. When you create a webhook, all events go to the URL you've provided. You can't subscribe to just one event.

With this in mind, I've created a RESTHook-style controller in our app. You can preform CRUD actions on webhooks, but you still get subscribed to every event. However, each event has it's name in the response, like so:

{ "event": "user.create", "id": 0, // ... }

In short, here's what I'm wondering:

What is the preferred way to filter events so that each trigger only responds to the appropriate event? I wouldn't want the order.create trigger firing on user.update.

I've looked in the examples and the docs, but I couldn't find anything that touches on this. Any advice or links are appreciated!

Thank you!

Kieran E
  • 3,616
  • 2
  • 18
  • 41

1 Answers1

0

David here, from the Zapier Platform team. Sorry for the slow circle here.

The easiest way to do this is in the perform function for your hook (there's an example here).

Your code would have something like

if (bundle.cleanedRequest.event !== 'order.create') {
  return [] // noop
}

// process hook into order
return [order]

Hope that clears it up. ​Let me know if you've got any other questions!

xavdid
  • 5,092
  • 3
  • 20
  • 32