Push Triggers
Push triggers allow Rollout partners to send data directly to Rollout, typically through an HTTP request. Push triggers are the easiest option for getting started with Rollout, as their implementation requires neither the potentially complex logic of polling nor a pre-existing webhook infrastructure.
Defining a Push Trigger#
Push Triggers are defined using the definePushTrigger
function.
Unlike polling or webhook triggers, push triggers don't require defining any functions. Defining the payload and input schemas, and optionally UI for configuring the Trigger, is all that is required.
Creating Trigger Events#
/api/trigger-push-event
endpoint#
The simplest way to create a trigger event is to POST to the /api/trigger-push-event
endpoint. The body of the request should specify the trigger's appKey
, triggerKey
and provide a payload
which conforms to the trigger's payload schema. As an Authorization
header, pass the same Rollout JWT used when rendering the UI components.
handlePushTriggerEvent
function#
Alternatively, you can call the handlePushTriggerEvent
function from an HTTP endpoint.
In order to wait for execution of the created Automation Run and get the result, getAutomationRun
can be used:
import { handlePushTriggerEvent } from "@rollout/framework";// In an http handler// Handle a trigger event, creating a pending Automation Runconst { automationRun } = await handlePushTriggerEvent({ automationId, payload });// Wait for the Automation Run executionconst { executions } = await getAutomationRun({where: { automationRunId: automationRun.id },waitFor: "any-execution",});console.log(executions[0]);