Skip to main content
The flow() function defines a single flow within a code-native integration. A flow has a trigger (webhook, schedule, or polling) and a main execution function. Flows are passed as an array to the flows field of integration().

Function signature

export const flow = <
  TInputs extends Inputs,
  TActionInputs extends Inputs,
  TPayload extends TriggerPayload = TriggerPayload,
  TAllowsBranching extends boolean = boolean,
  TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>,
  TTriggerPayload extends TriggerPayload = TriggerPayload,
  T extends Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload>
    = Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload>,
>(
  definition: T,
): T
A Flow is a union of StandardFlow (webhook or scheduled trigger) and PollingFlow (polling trigger). The triggerType field determines which variant applies.

Parameters

definition
Flow
required
An object that defines the flow. All base fields apply to both standard and polling flows.

Queue config variants

The queueConfig field accepts one of the following shapes:
All requests are processed simultaneously with no limits.
queueConfig: {
  type: "parallel",
}

Return type

flow
T
The same flow definition object passed in, unchanged. The function is used for type-checking and inference.

Examples

import { flow } from "@prismatic-io/spectral";

const syncFlow = flow({
  name: "Sync Records",
  stableKey: "sync-records",
  description: "Processes incoming webhook payloads.",
  isSynchronous: false,
  endpointSecurityType: "customer_optional",
  retryConfig: {
    maxAttempts: 3,
    delayMinutes: 5,
    usesExponentialBackoff: true,
  },
  onExecution: async (context, params) => {
    const payload = params.onTrigger.results;
    context.logger.info("Received payload", { payload });
    return { data: null };
  },
});
  • integration() — The parent function that accepts an array of flows.
  • configPage() — Define config wizard pages referenced in flows.
  • componentManifest() — Register components whose actions are available in context.components.