Skip to main content
This tutorial explains three techniques for creating triggers:
  • Polling: Periodically call endpoints to check for changes.
  • Webhooks: Listen to user events through a single URL.
  • App Webhooks (Subscriptions): Use a developer app (using OAuth2) to receive all authorized user events at a single URL (Not Supported).
to create new trigger run following command,
  1. Piece Folder Name: This is the name associated with the folder where the trigger resides. It helps organize and categorize triggers within the piece.
  2. Trigger Display Name: The name users see in the interface, conveying the trigger’s purpose clearly.
  3. Trigger Description: A brief, informative text in the UI, guiding users about the trigger’s function and purpose.
  4. Trigger Technique: Specifies the trigger type - either polling or webhook.

Trigger Structure

It’s important to note that the run method returns an array. The reason for this is that a single polling can contain multiple triggers, so each item in the array will trigger the flow to run.

When the hooks run

  • A failing onDisable is logged and ignored, so the flow still turns off. A failing onEnable fails the publish or the turn-on.
  • A patch upgrade in the builder (e.g. 0.5.1 → 0.5.3) keeps the trigger’s inputs. A minor or major upgrade resets them to the new version’s defaults. Which row applies depends on the inputs that get published: if they match the running flow, context.isRepublish is still true; if they differ, the trigger starts fresh. Don’t rely on an upgrade to clear stored state.
  • context.isRepublish is true only in the rows that say so. Use it to keep stored state that is still valid, rather than starting fresh. See Polling Trigger → Republishing a running flow.
  • A polling trigger’s onDisable still runs when the flow is turned off or deleted, but not on an upgrade, because the trigger keeps running. If onEnable creates something outside the store, save its id in the store and, when context.isRepublish is true and the id exists, reuse it instead of creating another. If the trigger needs to register and unregister with every version, make it a webhook trigger: those run both hooks on every republish.
  • test runs when the user loads sample data in the builder, and run runs on every poll or incoming event. Neither is part of turning the flow on or off.

Context Object

The Context object contains multiple helpful pieces of information and tools that can be useful while developing.
App Webhooks (Not Supported) Certain services, such as Slack and Square, only support webhooks at the developer app level. This means that all authorized users for the app will be sent to the same endpoint. While this technique will be supported soon, for now, a workaround is to perform polling on the endpoint.