Triggers

CronStep

Use CronStep to start the workflow on a periodic schedule. Scheduler

Inputs

ParameterTypeDescription
cronstring*The cron expression of the schedule for this trigger, from seconds to weeks.
Example: 0 0 9 * * * (every day at 9:00 AM)
timezonestringThe timezone to use for the cron expression, expressed as an IANA timezone string. Defaults to America/Los_Angeles.
Example: Etc/Universal (UTC)

Example

/**
 * Example: Scheduler Trigger configured to run a workflow every day at 9am PST.
 */
const triggerStep = new CronStep({
  cron: '0 0 9 */1 * *',
  timeZone: 'America/Los_Angeles',
});

Outputs

The CronStep does not produce any usable output.

EndpointStep

Use EndpointStep to trigger this workflow via an HTTP request. Request

Inputs

ParameterTypeDescription
allowArbitraryPayloadboolean*If true, this Request trigger will accept any type of request. If false, this Request trigger will require headerValidations, bodyValidations, and paramValidations to be defined.
headerValidationsHeaderValidation[]An array of validations to use on the headers for requests to this Request trigger. This can be used to validate the presence of required headers to inbound requests.
Example: [{ key: "X-Tasklab-Id", required: true }]
bodyValidationsBodyValidation[]An array of validations to use on body fields for requests to this Request trigger. This can be used to validate the presence or type of data in the body of inbound requests.
Example: [{ key: "userId", dataType: "STRING", required: true }]
paramValidationsParamValidation[]An array of validations to use on the URL parameters for requests to this Request trigger. This can be used to validate the presence of required parameters to inbound requests.
Example: [{ key: "query", required: true }]

Example

/**
 * Example: Request Trigger configured with parameter, header, and body validations.
 */
const triggerStep = new EndpointStep({
  allowArbitraryPayload: false,
  paramValidations: [
    {
      key: 'key',
      required: true,
    },
  ] as const,
  headerValidations: [
    {
      key: 'Content-Type',
      value: 'application-json',
    },
  ] as const,
  bodyValidations: [
    {
      key: 'email',
      dataType: 'STRING',
      required: true,
    },
    {
      key: 'first_name',
      dataType: 'STRING',
      required: true,
    },
    {
      key: 'last_name',
      dataType: 'STRING',
      required: true,
    },
  ] as const,
});

Outputs

Access the output of a Request trigger with requestTrigger.output.request. The below fields are fields of the .request property.

FieldTypeDescription
headersobjectAn object of the HTTP headers received in the request. Access these properties in lowercased format, e.g. requestTrigger.output.request.headers['content-type'].
bodyanyAn object or string of the HTTP body received in the request. The body will be an object when the Content-Type is application/json, multipart/form-data, or application/x-www-form-urlencoded. Otherwise, it will be attempted to be parsed as a string or File (see below).
paramsobjectAn object of the URL parameters received in the request.
fileFileValue / undefinedIf the HTTP body refers to a file, the file contents will be available as a FileValue object. Otherwise, this property will resolve to undefined.

EventStep

Use EventStep to trigger this workflow with an App Event.

Inputs

To construct an App Event Trigger, first import your App Event into the Workflow:

import taskCreated from '../../../events/newTask';

Then, pass this import to the constructor of EventStep:

const trigger = new EventStep(taskCreated);

Because App Events can be shared across different workflows and integrations, they are required to be defined in the src/events folder of your Paragraph project.

Example

/**
 * Example: App Event Trigger configured with an event and object mapping.
 */
const triggerStep = new EventStep(event, {
  objectMapping: ``,
});

Outputs

Access the output of an App Event trigger with appEventTrigger.output. The output will match the schema of the App Event that this trigger uses.

IntegrationEnabledStep

Use IntegrationEnabledStep to trigger this workflow when a user enables the integration.

Inputs

This trigger does not use any parameters.

Example

/**
 * Example: Integration Enabled Trigger with default configuration.
 */
const triggerStep = new IntegrationEnabledStep();

Outputs

The IntegrationEnabledStep does not produce any usable output.

Steps

ConditionalStep

A Conditional branching step to allow for control flow in Workflows.

Inputs

ParameterTypeDescription
ifConditionalInput*The condition to evaluate for determining whether or not to proceed into the “true” or “false” branch beneath this step.
Learn more about defining ConditionalInputs: Conditional logic

Example

/**
 * Example: Conditional Step to check if an item is in a list using operators.
 */
const itemInListStep = new ConditionalStep({
  if: Operators.Or(
    Operators.And(Operators.StringContains('["a","b","c"]', 'a')),
    Operators.And(
      Operators.StringContains('["a","b","c"]', 'c'),
      Operators.StringDoesNotContain('["a","b","c"]', 'd'),
    ),
  ),
  description: 'Item in List?',
});

Outputs

ParameterTypeDescription
selectedChoice"Yes" / "No"The branch that was chosen when this ConditionalStep was evaluated.

DelayStep

A step to pause the workflow for a fixed amount of time.

Inputs

ParameterTypeDescription
valuenumber*How long to pause the workflow for, measured by the unit parameter.
unit"SECONDS" / "MINUTES" / "HOURS" / "DAYS"The unit of time to use when delaying the workflow. Defaults to "MINUTES".

Example

/**
 * Example: Delay Step delaying a workflow execution for 5 minutes
 */
const delayStep = new DelayStep({
  unit: 'MINUTES',
  value: 5,
  description: 'Delay workflow for 5 minutes',
 });

Outputs

The DelayStep does not produce any usable output.

FanOutStep

A step to map over a set (array) of data in parallel, for e.g. data transformation or batch uploads.

Inputs

ParameterTypeDescription
iteratorany[]A set of data to iterate over in the Fan Out.
/**
 * Example: Fan Out step iterating through each item in an array from a previous step.
 */
const eachItemStep = new FanOutStep({
  description: 'Each Item',
  iterator: functionStep.output.result,
});

Outputs

Access one instance of a Fan Out step with fanOutStep.output.instance. This can only be used by steps that are in this Fan Out’s branch (see: Fan out branches).

FieldTypeDescription
instanceanyAn item of the iterator property that is being processed in this branch.

FunctionStep

A JavaScript function step.

Inputs

ParameterTypeDescription
codeFunction*The function to run. This function must have the signature function(parameters, libraries) and must be self-contained, meaning that it cannot reference JavaScript values outside of the function body. To pass execution data through this step, use the parameters object.
The list of libraries can be found in: JavaScript Libraries
parametersobject*Parameters from other step outputs to inject into the function.

Example

/**
 * Example: Function Step using IFunctionStepParameters.
 * Here the function code is provided as a string, which will be dynamically executed.
 */
const functionStepParams: IFunctionStepParameters = {
  id: 'funcStep',
  name: 'String Code Function',
  code: `
    function execute(params, libraries) {
      // Example: Reverse a given string.
      return params.input.split('').reverse().join('');
    }
    module.exports = execute;
  `,
  parameters: [{ key: 'input', value: 'reverse me' }],
  autoRetry: false,
  continueWorkflowOnError: false
};

Outputs

Access the result of an Function step with functionStep.output.result.

FieldTypeDescription
resultanyThe return result of code after evaluation with parameters.
Note: If code returns a Promise, the Function step will automatically await this Promise and return the unwrapped result.

IntegrationRequestStep

A step to send a custom request to the integration’s API, without needing to provide auth details.

Inputs

ParameterTypeDescription
method"GET" / "POST" / "PATCH" / "PUT" / "DELETE"*The HTTP method to use for this API request. If you select POST, PUT, or PATCH methods, the body and bodyType parameters will be required.
urlstring*The relative path of the API request, with respect to the base URL provided by the integration. Specifying a full URL is also supported.
bodyType"json" / "form-data" / "x-www-form-urlencoded" / "xml" / "raw"Select the type of request body that should be sent. Paragon will automatically encode the payload and set the correct Content-Type headers.
bodyobject / string / (pageToken: string) => object / string)An object or string representing the request body to be sent. If using Request Step Pagination, you can specify a function that returns the body of the request with respect to the Page Token.
headersobject / (pageToken: string) => objectAn object of the HTTP headers sent in the request. Integration Request Steps will automatically include the user’s authentication details for the request.
paramsobject / (pageToken: string) => objectAn object of the URL parameters sent in the request. Parameters can be specified either here or in the url property.
pagination(step) => PaginationOptionsIf using Request Step Pagination, you can define the options used in this function. Use the step parameter of the pagination function to access the output.

pagination Example:

new IntegrationRequestStep({
  method: "GET",
  url: "/opportunities",
  params: (pageToken) => ({
    pageToken
  }),
  pagination: (step) => {
    return {
      outputPath: step.output.response.body.data,
      pageToken: step.output.response.body.nextPageToken,
      stopCondition: Operators.Or(
        Operators.And(
          Operators.DoesNotExist(step.output.response.body.nextPageToken)
        )
      )
    }
  },
});

Example

/**
 * Example: Integration Request step configured to pull contacts.
 */
const integrationRequestStep = new IntegrationRequestStep({
  autoRetry: false,
  continueWorkflowOnError: false,
  description: 'Get Contacts through API',
  method: 'GET',
  url: `/[email protected]`,
  params: { email: '[email protected]' },
  headers: {},
});

Outputs

Access the output of an Integration Request step with requestStep.output.response.

FieldTypeDescription
headersobjectAn object of the HTTP headers received in the response.
bodyanyAn object or string of the HTTP body received in the response.
statusCodenumberThe HTTP status code of the response.

RequestStep

A step to send an HTTP request from a workflow.

Inputs

ParameterTypeDescription
method"GET" / "POST" / "PATCH" / "PUT" / "DELETE"*The HTTP method to use for this API request. If you select POST, PUT, or PATCH methods, the body and bodyType parameters will be required.
urlstring*The full URL of the HTTP request to send.
bodyType"json" / "form-data" / "x-www-form-urlencoded" / "xml" / "raw"Select the type of request body that should be sent. Paragon will automatically encode the payload and set the correct Content-Type headers.
bodyobject / stringAn object or string representing the request body to be sent.
headersobjectAn object of the HTTP headers sent in the request.
paramsobjectAn object of the URL parameters sent in the request. Parameters can be specified either here or in the url property.
authorizationAuthorizationConfigChoose between Basic authentication, Bearer token authentication, and OAuth 2.0 Client Credentials for handling the authorization of this request.

authorization Example:

new RequestStep({
  method: 'GET',
  url: 'https://myapp.io/api',
  authorization: {
    type: 'basic',
    username: 'paragon-user',
    password: context.getEnvironmentSecret("API_SECRET"),
  },
});

Outputs

Access the output of a Request step with requestStep.output.response.

FieldTypeDescription
headersobjectAn object of the HTTP headers received in the response.
bodyanyAn object or string of the HTTP body received in the response.
statusCodenumberThe HTTP status code of the response.

Example

/**
 * Example: POST Request with JSON body
 */
const postRequestStepInit: IRequestStepInit = {
  id: 'step2',
  name: 'POST Request Example (JSON)',
  url: 'https://api.example.com/items',
  method: 'POST',
  bodyType: 'json',
  body: {
    item: 'newItem',
    quantity: 10,
  },
  params: { verbose: 'true' },
  headers: { 'Content-Type': 'application/json' },
  authorization: {
    type: 'bearer',
    token: 'abcdef123456',
  },
  ignoreFailure: false,
  autoRetry: false,
  continueWorkflowOnError: false
};

ResponseStep

A step (for use in Request-triggered workflows only) to send an HTTP response from a workflow.

Inputs

ParameterTypeDescription
responseType"JSON" / "FILE"*The type of Response to send to the HTTP Request that triggered the workflow. Choose between a JSON-encoded response or a raw File type.
bodyobject / FileValue*If using a JSON responseType, provide an object to send in the response. If using a File responseType, provide a FileValue to send in the response.
statusCodenumber*The status code to send in the Response to the HTTP Request that triggered the workflow.

Example

/**
 * Example: Response step returning a 201 status code with a message.
 */
const send201Step = new ResponseStep({
  description: 'Send 201',
  statusCode: 201,
  responseType: 'JSON',
  body: { message: 'Contact Created!' },
});

Was this page helpful?