ReferenceFor engineers

The onEvent function

The function called when a care flow activates a custom action, with its payload, its callbacks, and the helpers available to it.

onEvent is called whenever orchestration, or a design-time preview, activates a custom action. Awell publishes a message, the extension server receives it, finds the right custom action, and calls its onEvent.

export const myAction = {
  // …
  onEvent: async ({ payload, onComplete, onError, helpers }) => {
    // Do something here
  },
};

What the payload carries

  • the values of the extension's settings
  • the values of the action's fields
  • patient and care flow data

Every action must call onComplete or onError

onComplete and onError hand control back to the design preview or the orchestration engine.

An action that returns without calling either leaves the care flow waiting on an activity that never finishes, and the patient waits with it. Wrap the logic so every path, including a thrown exception, ends in one of the two.

Helpers: HTTPS requests and the Awell SDK

  • httpsAgent makes outbound HTTPS requests.
  • AwellSdk talks back to Awell's own API.

onEvent replaced onActivityCreated

onActivityCreated has been deprecated since 1 September 2024. Older extensions may still call it; see onActivityCreated.

Next steps

Next: Test your extension.

On this page