Sending notifications from Citeck BPMN (Camunda)
General Description
To send notifications from a BPMN process, the Send Task element is used — a special component of the Citeck platform.
Despite the name, Send Task in Citeck is not a standard BPMN Send Task: its behavior is entirely defined by Citeck extensions and implements sending notifications via the ecos-notifications microservice.
Notifications are sent via ecos-notifications.
Do not send notifications directly from microservice code or process scripts, bypassing ecos-notifications.
Important
Currently, only the EMAIL_NOTIFICATION notification type is supported in BPMN Send Task. Specifying any other type will cause an error when saving or publishing the process.
See the description of the Notifications component
XML Representation of Send Task
In the XML BPMN file, Send Task is described via the <bpmn:sendTask> element with attributes from the ecos: namespace (xmlns:ecos="http://www.citeck.ru/ecos/bpmn/1.0").
Example — notification with role-based recipients:
<bpmn:sendTask
id="Activity_notify_initiator"
name="Уведомление инициатору"
ecos:notificationType="EMAIL_NOTIFICATION"
ecos:notificationTemplate="notifications/template@ecos-contract-approval-notification-template"
ecos:notificationLang="ru"
ecos:notificationTo="["initiator"]"
ecos:notificationToExpression="[]"
ecos:notificationCc="[]"
ecos:notificationCcExpression="[]"
ecos:notificationBcc="[]"
ecos:notificationBccExpression="[]"
ecos:notificationSendCalendarEvent="false"
ecos:notificationAdditionalMeta="{}">
</bpmn:sendTask>
Example — notification with a dynamic recipient from a process variable:
<bpmn:sendTask
id="Activity_notify_confirmer"
name="Уведомление согласующему"
ecos:notificationType="EMAIL_NOTIFICATION"
ecos:notificationTemplate="notifications/template@ecos-contract-approval-notification-template"
ecos:notificationLang="ru"
ecos:notificationTo="[]"
ecos:notificationToExpression="["${confirmer}"]"
ecos:notificationCc="[]"
ecos:notificationCcExpression="[]"
ecos:notificationBcc="[]"
ecos:notificationBccExpression="[]"
ecos:notificationSendCalendarEvent="false"
ecos:notificationAdditionalMeta="{}">
</bpmn:sendTask>
Example — notification with an explicit sender specified from ecos-config:
<bpmn:sendTask
id="Activity_notify_with_from"
name="Уведомление инициатору о создании заявки"
ecos:notificationType="EMAIL_NOTIFICATION"
ecos:notificationTemplate="notifications/template@sd-request-create"
ecos:notificationLang="ru"
ecos:notificationFrom="${Config.getNotNull("app/service-desk$send-sd-email-from").asText()}"
ecos:notificationTo="["initiator-role"]"
ecos:notificationToExpression="[]"
ecos:notificationCc="[]"
ecos:notificationCcExpression="[]"
ecos:notificationBcc="[]"
ecos:notificationBccExpression="[]"
ecos:notificationSendCalendarEvent="false"
ecos:notificationAdditionalMeta="{}">
</bpmn:sendTask>
Send Task Attributes
Main Attributes
Attribute |
Description |
|---|---|
|
Notification type. Only |
|
Reference to the notification template in the format |
|
Email subject directly (without a template). Static text only, no dynamic variables. |
|
Email body directly (without a template). Static text only. |
|
Template language: |
|
Outgoing sender address. Can be specified directly or via an expression. If not specified, the default value from ecos-notifications settings is used. Supported formats:
|
|
A JSON object with additional variables available in the template. A value starting with |
Recipients
Recipients are defined as JSON arrays of strings. The *To, *Cc, *Bcc attributes accept role names of the document; the *ToExpression, *CcExpression, *BccExpression attributes accept expressions (username, email, recordRef, or ${variable}).
Attribute |
Description |
|---|---|
|
JSON array of recipient roles. The platform resolves the email of all users in the role. Example: |
|
JSON array of expressions for recipients. Example: |
|
JSON array of roles for carbon copy (CC). |
|
JSON array of expressions for carbon copy. |
|
JSON array of roles for blind carbon copy (BCC). |
|
JSON array of expressions for blind carbon copy. |
Roles and expressions can be combined: static roles in *To, dynamic ones in *ToExpression.
Recipient formats in *Expression attributes:
ivan.petrov— usernameivan.petrov@company.com— email address directlyGROUP_company_accountant— group (the first email is selected)emodel/authority-group@company_accountant— group recordRefemodel/person@ivan— user recordRef${someVariable}— a process variable containing any of the above values${someService.getEmails()},petya.voks— multiple values separated by a comma
Calendar Invitation (iCal)
Send Task supports sending an iCal attachment (calendar invitation) together with the email.
<bpmn:sendTask
id="Activity_meeting_invite"
name="Приглашение на встречу по согласованию"
ecos:notificationType="EMAIL_NOTIFICATION"
ecos:notificationTemplate="notifications/template@contract-meeting-notification"
ecos:notificationTo="["initiator"]"
ecos:notificationToExpression="[]"
ecos:notificationCc="[]"
ecos:notificationCcExpression="[]"
ecos:notificationBcc="[]"
ecos:notificationBccExpression="[]"
ecos:notificationLang="ru"
ecos:notificationSendCalendarEvent="true"
ecos:notificationCalendarEventSummary="Встреча по согласованию договора"
ecos:notificationCalendarEventDescription="Необходимо согласовать договор №${docNum}"
ecos:notificationCalendarEventOrganizer="{"role":"initiator"}"
ecos:notificationCalendarEventDate="${meetingDate}"
ecos:notificationCalendarEventDuration="PT1H"
ecos:notificationAdditionalMeta="{}">
</bpmn:sendTask>
Attribute |
Description |
|---|---|
|
Enable sending a calendar invite: |
|
Calendar event title. Supports expressions: |
|
Event description. Supports expressions: |
|
Organizer. A JSON object with a
If the role contains multiple users, the first email is used. |
|
Event start date. A process variable of type |
|
An alternative to |
|
Event duration in ISO 8601 format. Examples: |
|
An alternative to |
Notification Template
The template reference is specified in the ecos:notificationTemplate attribute in the format:
notifications/template@<template-id>
Where <template-id> is the template identifier matching the artifact directory name.
For details on creating templates, see Notification Templates.
Template Variables
The following are available in the template:
Document attributes — resolved via the
modelfield of the template meta file.Process variables — via
$process.<variable name>inmodel.Event variables (for event sub-processes) — via
$process.event.<attribute>.Contextual variables:
Expression in
modelDescription
$nowCurrent date and time.
$userCurrent system user.
$process.webUrlProcess URL.
$process.someVarProcess variable
someVar.
$process.event.textAttribute of the event that triggered the notification. For example, the comment text.
$process.event._meta.idEvent ID.
$process.event._meta.typeEvent type.
$process.currentRunAsUserThe user on whose behalf the process is running.
$str.<CONSTANT>A string constant without evaluation. Example:
$str.APPROVED→"APPROVED".
Example model for a notification triggered by a comment-added event:
{
"documentDisp": ".disp",
"documentCreated": "_created",
"now": "$now",
"user": "$user",
"commentText": "$process.event.text",
"eventType": "$process.event._meta.type",
"currentRunAsUser": "$process.currentRunAsUser"
}
To attach attachments from the event (e.g., files from a comment):
{
"_attachments": "$process.event.attachments[]._as.ref._content{bytes,meta:?json}"
}
Additional Model (additional meta)
Via ecos:notificationAdditionalMeta, additional data can be passed to the template without extracting it from the document or process via model.
The key is the name of the variable available in the template.
Value:
If it starts with
!str_, the characters after the prefix are passed as a string constant.Otherwise, the string is treated as a recordRef, and the platform attempts to load attributes by this ref.
Example:
{
"myConstant": "!str_someValue",
"relatedDoc": "emodel/some-type@some-id"
}
In the template, ${myConstant} will return someValue.