Triggers
Triggers cause a Job Run to start. Webhooks and polling are the most relevant for integrations.
Polling triggers aren’t currently supported. They will allow triggers to be built for APIs that don’t have webhooks, like Notion.
Webhooks AKA ExternalSource
Webhooks are added to an Integration by using ExternalSource
.
An example: Stripe onPriceCreated
You can subscribe to many different events using our Stripe integration.
We’re going to run through the steps required to create the onPriceCreated event.
Here’s an example Job using it, you should create Jobs like this while you’re developing so you can test your trigger. See the integration testing guide for more info.
Creating Tasks that list/create/delete/update webhooks
We need to create Tasks that will be used to register webhooks. These will be used in the ExternalSource.
These are created just like normal Tasks, which we’ve already covered. In this case we’re creating three tasks:
io.stripe.webhookEndpoints.create
io.stripe.webhookEndpoints.update
io.stripe.webhookEndpoints.delete
io.stripe.webhookEndpoints.list
Creating events
An event is something that happens in the external system. In this case, it’s a price being created. We use EventSpecification
s to define events.
We have many events exported from this file, but here’s the one we care about:
Adding a Trigger
We import all the events from the file above, and then we can add a trigger for the event we want.
Creating the ExternalSource
The ExternalSource is response for registering webhooks and processing the data when it’s received.
Handling the webhook payload
When a webhook is received, we need to validate the signature, parse the payload, and return the events. Each event will turn into a payload that can trigger a Job run.
Was this page helpful?