Callback State

Parameter
Description
Type
Required

name

Unique State name. Must follow the Serverless Workflow Naming Convention

string

yes

type

State type

string

yes

action

Defines the action to be executed

object

yes

eventRef

References an unique callback event name in the defined workflow events

string

yes

timeouts

State specific timeout settings

object

no

eventDataFilter

Callback event data filter definition

object

no

stateDataFilter

State data filter definition

object

no

onErrors

States error handling and retries definitions

array

no

transition

Next transition of the workflow after callback event has been received

string or object

yes (if end is not defined)

end

Is this state an end state

boolean or object

yes (if transition is not defined)

compensatedBy

Unique name of a workflow state which is responsible for compensation of this state

string

no

usedForCompensation

If true, this state is used to compensate another state. Default is false

boolean

no

metadata

Metadata information

object

no

Example:

JSON
YAML
{
        "name": "check-credit",
        "type": "callback",
        "action": {
            "functionRef": {
                "refName": "call-credit-check-microservice",
                "arguments": {
                    "customer": "${ .customer }"
                }
            }
        },
        "eventRef": "credit-check-completed-event",
        "timeouts": {
          "stateExecTimeout": "PT15M"
        },
        "transition": "evaluate-decision"
}
name: check-credit
type: callback
action:
  functionRef:
    refName: call-credit-check-microservice
    arguments:
      customer: "${ .customer }"
eventRef: credit-check-completed-event
timeouts:
  stateExecTimeout: PT15M
transition: evaluate-decision

Serverless orchestration can at times require manual steps/decisions to be made. While some work performed in a serverless workflow can be executed automatically, some decisions must involve manual steps (e.g., human decisions). The Callback state allows you to explicitly model manual decision steps during workflow execution.

The action property defines a function call that triggers an external activity/service. Once the action executes, the callback state will wait for a CloudEvent (defined via the eventRef property), which indicates the completion of the manual decision by the called service.

Note that the called decision service is responsible for emitting the callback CloudEvent indicating the completion of the decision and including the decision results as part of the event payload. This event must be correlated to the workflow instance using the callback events context attribute defined in the correlation property of the referenced Event Definition.

Once the completion (callback) event is received, the Callback state completes its execution and transitions to the next defined workflow state or completes workflow execution in case it is an end state.

The callback event payload is merged with the Callback state data and can be filtered via the "eventDataFilter" definition.

If the defined callback event has not been received during this time period, the state should transition to the next state or end workflow execution if it is an end state.

The timeouts property defines state specific timeout settings. Callback states can define the stateExecTimeout, actionExecTimeout, and eventTimeout properties. For more information on workflow timeouts reference the Workflow Timeouts section.

Note that transition and end properties are mutually exclusive, meaning that you cannot define both of them at the same time.

Last updated