Sending
3 minute read
Attributes of a Notification
id (string)
: ordered UUIDtitle (string)
: The notification’s titlemessage (string)
: The notification’s bodytype (string)
: One ofinfo
,warning
,error
,progress
, or a custom value.icon (string)
: Image URLimage (string)
: Image URLactions (list<dict>)
: Array of action dictionaries, rendered as action buttons.action (string)
: Action identifiertitle (string)
: Action titleicon (string)
: Action icon URL
data (dict)
: Custom data, as key-value pairsentity (Entity)
: Entity appendixworfklow (Workflow)
: Originator workflow of the notification
Workflow elements
Notify (action/notify)
Sends a notification to the notification center and over Web push, if available.
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 tonull
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 aFile
entity, to the notification using this field.type
: The type of notification, which can be one ofinfo
,warning
, orerror
.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.
actions
is given and non-empty, this element checkpoints!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.
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 tonull
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 acast/progress
element with the sameprocess
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 aFile
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 tofalse
.
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);