Create a callback

The basic callback flow is illustrated by this process.

[
  {
  "name": "anchor",
  "script": "stepTypeCallback",
  "next": {
    "create": "call",
    "complete": "complete",
      "*": false
    }
  },
  {
    "name": "call",
    "script": "stepTypeCall",
    "config": {
      "callAction": "run",
    "background": true,
    "callback": true,
"callParams": false
    },
    "next": false
  },
  {
  "name": "complete",
    "script": "stepTypeSet",
    "config": {
      "show": false,
      "createEvent": true,
    "description": "Complete"
    },
    "next": false
  },
  {
    "name": "run",
    "script": "stepTypeRunScript",
    "config": {
      "script": "application.sleep(10);"
    },
    "next": false
  }
]

To start the flow, the callback step type is called to create the callback. This step is known as the anchor step because it is the step to which callback will be made. The abchor action stores information about the callback, and creates a callback token that can be used to return to the anchor step.

The callbackAction of "anchor" is the default action, so it can be omitted.

The anchor step provides two "next" branches.

  • A "create" flow that indicates that the callback has been created. In the example above, this routes to the "call" step.
  • A "complete" flow that is used when the background 

The create flow is linked to a call flow. This initiates the background execution, passing two additional parameters:

  • background set to true, to indicate that the call should run in the background (i.e. not wait).
  • callback set to true, to indicate that callback information (from the prepare step) should be passed. This information is know as the callback token.

The call starts a long running task (in this case the "run" action in the same process flow) and returns immediately.

When the long-running task is complete, the complete flow from the anchor step is invoked - in this case just an event showing that is has completed.