Sending

Attributes of a Notification

  • id (string): ordered UUID
  • title (string): The notification’s title
  • message (string): The notification’s body
  • type (string): One of info, warning, error, progress, or a custom value.
  • icon (string): Image URL
  • image (string): Image URL
  • actions (list<dict>): Array of action dictionaries, rendered as action buttons.
    • action (string): Action identifier
    • title (string): Action title
    • icon (string): Action icon URL
  • data (dict): Custom data, as key-value pairs
  • entity (Entity): Entity appendix
  • worfklow (Workflow): Originator workflow of the notification

Workflow elements

Notify (action/notify)

Sends a notification to the notification center and over Web push, if available.

notification

Options

Below are the available options for creating notifications:

  • recipients: Specifies the recipient of the notification, which can be a user, a list of users, a role slug, or a list of role slugs. If this field is omitted, the notification will be sent to the current user. If set to null in recipe mode, the notification will not be sent to anyone.

  • title: Specify the title of the notification.

  • message: The message of the notification.

  • entity: Append an entity, such as a File entity, to the notification using this field.

  • type: The type of notification, which can be one of info, warning, or error.

  • icon: The icon to be displayed in the notification. You can provide an absolute URL or a virtual path pointing to a Brezel file (e.g., /static/icon.png). If you use a virtual path, a permanent public absolute URL to the file will be generated, containing a share token. If you are in recipe mode, you can also use a file entity, with the same sharing behavior as the virtual path.

  • image: The image to be displayed in the notification. You can provide an absolute URL, a virtual path, or a file entity.

  • actions: Provide a list of action buttons to display in the notification. You can provide a tokenized list of action names (e.g., “Accept, Deny”), an array of action identifiers (in recipe mode), or an array of action dictionaries (in recipe mode), where each dictionary specifies the action button properties.

action/notify

Outputs

  • action: fired when the user clicks on an action, with the selected action identifier as the data.

Progress (cast/progress)

Sends or updates a progress notification to the notification center and over Web push, if available.

cast/progress

Options

Below are the available options for creating progress notifications:

  • recipients: Specifies the recipient of the notification, which can be a user, a list of users, a role slug, or a list of role slugs. If this field is omitted, the notification will be sent to the current user. If set to null in recipe mode, the notification will not be sent to anyone.

  • process: Name of the process, used for identifying the current progress notification to update if there are multiple separate progresses in one workflow. Defaults to the workflow title.

  • progress: The current progress of the notification (integer). If empty, this value is incremented each time a cast/progress element with the same process is called.

  • total: The number of progress steps achievable (integer). Required.

  • title: Specify the title of the notification.

  • message: The message of the notification.

  • status_message: The status message, displayed below the progress bar.

  • entity: Append an entity, such as a File entity, to the notification using this field.

  • async: Whether to queue this notification. If selected, the workflow runs faster and is not affected much by the sending of notifications, however notifications can severely lag behind. Defaults to false.

PHP

Example

Sending notifications:

$notification = new CenterNotification('Title', 'Message');
$notification->data(['key' => 'value']);
$user->notify($notification);

Updating notifications, where $id is the ID of the notification to update:

$notification = new CenterNotification('Updated title', 'Message');
$notification->updates($id); // Specify the notification that should be updated
$notification->data(['key' => 'value']);
$user->notify($notification);