Triggering Workflows

Triggering workflows in Paragon

All Paragon workflows start with a trigger, which determines when the workflow will run and how data is passed into the workflow. Available workflow trigger types include:

  • ​App Event - triggered by an event sent from your application via the Paragon SDK or API

  • Scheduler - runs automatically at a scheduled time or interval

In this section, we'll walk through common use cases for each trigger type and how you should use them.‌

App Events

App Events are custom events that are sent programmatically from your application via the Paragon SDK or API to trigger Workflows. In general, App Events are useful for triggering workflows that map data from your application to your users' apps.

For example, you might send a "Contact Created" App Event from your application to trigger a Workflow that creates a matching contact in your users' Salesforce CRM.

Once defined, an App Event can be used to trigger multiple workflows. This is useful in cases where you may want the same event to trigger similar workflows across different integrations.

For example, the same "Contact Created" event in the above example could trigger one workflow that creates a contact in Salesforce, and another workflow that creates a contact in HubSpot. This allows you to easily provide the same integration functionality across different providers without any additional engineering.

Creating an App Event

To create an App event, select the App Event trigger type in the Workflow editor and choose "Create new app event" in the menu under Choose an App Event.

Next, enter the name and event schema of your App Event. The event schema that you enter here should be an example payload sent from your application to Paragon. The event schema defined here will be used as test data for any workflows triggered by this App Event.

The event schema must be a valid JSON object, and can contain any arbitrary JSON.

Sending an App Event

App Events can be sent from your application using the Paragon SDK or REST API. In both cases, you must pass two parameters:

  • name - the event name defined in your App Event

  • payload - the event payload that should match the event schema defined in your App Event

See the code examples below for how to send App Events using the Paragon SDK or API.

JavaScript SDK
REST API
JavaScript SDK
var eventName = "Contact Created";
var eventPayload = { "name": "Brandon", "email": "b@useparagon.com" };
// Called once during your user's session
paragon.authenticate("project-id", <Paragon User Token>)
// Trigger the "Contact Created" App Event
paragon.event(eventName, eventPayload)
REST API
// Trigger the "Contact Created" App Event
POST https://api.useparagon.com/projects/<Paragon Project ID>/sdk/events/trigger
Authorization: Bearer <Paragon User Token>
Content-Type: application/json
{
"name": "Contact Created",
"payload": {
"name": "Brandon",
"email": "b@useparagon.com"
}
}

When sending live events from your application, Paragon will not validate that your event payload matches the defined event schema.

Managing App Events

If you need to edit your App Events' name or event schema, you can visit the App Events tab in your Paragon dashboard to view and manage your app events.

Scheduler

The Scheduler trigger is used for workflows that should run automatically at a scheduled time or interval.

The Scheduler trigger provides the following scheduling options:‌

  • Seconds (e.g. every 5 seconds)

  • Minutes (e.g. every 30 minutes)

  • Hourly (e.g. every hour at 15 minutes past the hour)

  • Daily (e.g. every 2 days at 9:00 am)

  • Weekly (every Monday at 12:00 pm)

Once deployed, the workflow will run automatically at the designated time for all users who have activated the workflow in their Connect Portal.