Scheduled Workflows

Learn how to configure Scheduled Workflows for your app. This page includes descriptions and examples for defining scheduled and scheduling workflows in a Kustomer app.

In Kustomer, you can create workflows, or automations, that can schedule, or be scheduled by, other workflows. Scheduled workflows allow teams to take advantage of powerful time-based conditional logic in their workflows-based automations.

As a developer, you can create apps that can configure both a scheduling workflow and a scheduled workflow to leverage time-based conditional logic for automations. Common use cases include setting a timeframe or delay between a trigger event and a workflow action.

Learn more about scheduled workflows in the Kustomer Help Center.

Scheduled workflows format in the app definition

A scheduling workflow references the workflow to schedule based on the ID of the scheduled workflow.

The Kustomer Apps Platform generates a unique ID for an app-created workflow when the app is installed. With workflows, you can define the workflow ID of the scheduled workflow when you define scheduling workflow / scheduled workflow pairs for an app.

👍

Define a workflow ID for the scheduled workflow

When you define the id of the scheduled workflow to reference in the scheduling workflow, keep the following in mind:

  • The workflow ID must be a string and unique in the context of your app definition. Example: "id": "5f8e148232731d0015c14657"

  • You must include the workflow ID in the eventName property for the scheduled workflow. Example: "eventName": "kustomer.workflow.<id>.call"

  • If you create your workflow with the visual workflow editor in Kustomer, select Edit Workflow JSON and use the generated IDs for your definition.

When you register and install your app, the Kustomer Apps Platform will replace any workflow IDs you defined in the workflow with an ID that is globally unique for the whole Kustomer platform.

Scheduled workflows definition example

The following sample JSON app definition includes a workflows property definition for an app that creates and configures two workflows:

  • a scheduling workflow named appConfiguredSchedulingworkflow
  • a scheduled workflow named appConfiguredScheduledworkflow

The appConfiguredSchedulingworkflow scheduling workflow definition specifies the name, steps, and triggers. Inside the steps property, the scheduling workflow calls the workflowId of the scheduled workflow.

You'll notice that the definition for the appConfiguredScheduledworkflow schedule workflow also includes the workflow id in addition to name, steps, and trigger. The scheduled workflow definition must include the same id in the eventName property: "eventName": "kustomer.workflow.5f8e148232731d0015c14657.call".

In the example, the id is defined as 5f8e148232731d0015c14657 and is referenced as the workflowId inside the steps property of the scheduling workflow.

...
"workflows": [
  {
    "name": "appConfiguredSchedulingworkflow",
    "steps": [
      {
        "transitions": [],
        "id": "egu-awuO4",
        "action": "kustomer.app.scheduler.schedule-workflow",
        "params": {
          "runAt": {
            "value": 60,
            "type": "relative"
          },
          "workflowId": "5f8e148232731d0015c14657",
          "inputs": {
            "foo": "/#steps.1.name"
          }
        },
        "appVersion": "scheduler-^1.0.1"
      }
    ],
    "trigger": {
      "transitions": [
        {
          "target": "egu-awuO4",
          "condition": {
            "op": "true",
            "values": [
              true
            ]
          }
        }
      ],
      "eventName": "kustomer.customer.update",
      "id": "1",
      "appVersion": "kustomer-^1.4.8"
    }
  },
  {
    "id": "5f8e148232731d0015c14657",
    "name": "appConfiguredScheduledworkflow",
    "steps": [
      {
        "transitions": [],
        "id": "2md61qrCP",
        "action": "kustomer.rest-api.json",
        "params": {
          "uri": "https://en2ol9xpbk9mi.x.pipedream.net",
          "method": "POST",
          "json": true
        },
        "appVersion": "kustomer-^1.4.8"
      }
    ],
    "trigger": {
      "transitions": [
        {
          "target": "2md61qrCP",
          "condition": {
            "op": "true",
            "values": [
              true
            ]
          }
        }
      ],
      "id": "1",
      "callable": true,
      "schema": {
        "properties": {
          "foo": {
            "type": "string"
          }
        },
        "required": []
      },
      "eventName": "kustomer.workflow.5f8e148232731d0015c14657.call"
    }
  },
],
...

Scheduled Workflows properties

See Workflows properties to view properties for workflows.