How do I develop an event source when the API supports webhooks?

This topic was automatically generated from Slack. You can find the original thread here.

SERW2039 : so just confirming for developing sources, in this cases I am tackling Mailgun’s sources. They offer webhooks, which are setup on their control panel. The user is expected to enter a URL where Mailgun posts events, the user then has to be able to process the events, by receiving calls from Mailgun with the event payload. They also offer an Event API, where information about events can be pulled. In this case, for developing Pipedream users, we would pull the events from Mailgun APi, and emmit from there, correct? Or is there some proxy URLs as Pipedream account at Mailgun could be used for Maulgun’s webhooks, and then just forward the events to the user? (which I see less likely) Please advice.

SERW2039 : I am coming for taking a look at the User manualspecifically at the events/webhook sections. In the API reference there’s a section for said Events API Events — Mailgun API documentation

SERW2039 : This is the relevant section for events in the User Manual, where webhooks and event api are said to be exposed by Mailgun

Dylan Sather (Pipedream) : Mailgun also supports the creation (and deletion) of webhooks programmatically: Webhooks — Mailgun API documentation .

So in this case you’ll want to create the webhook as a part of the source creation process, passing the URL of the event source’s HTTP endpoint as the url you pass in the POST request on webhook create.

Take a look at pipedream/common-webhook.js at master · PipedreamHQ/pipedream · GitHub for an example - see how the webhook is created in the activate() hook and deleted in the deactivate() hook.

Dylan Sather (Pipedream) : That way, Mailgun will deliver events directly to the source. We call these “subscription” webhooks. When the API supports the management of webhooks, it really benefits us, since it affords real-time delivery of events to Pipedream with no manual webhook work for the user.

SERW2039 : Oh, that’s amazing, supporting the creation of webhooks, which Pipedream would use on behalf of the user having connected a Mailgun account. Great to know, ok I will take a look to all this and go ahead. Thanks for input. Yeah I see the real-time event delivery beneffit as well.