Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Adapt Program Notification Template to new API [DHIS2-17502] #1394

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions src/developer/web-api/tracker.md
Original file line number Diff line number Diff line change
Expand Up @@ -2861,3 +2861,64 @@ See an example payload below:
}
```

## Program Notification Template

The Program Notification Template feature enables you to create message templates that can be triggered by various types of events. These templates, including both the message and subject, will be dynamically translated into actual values and sent to a configured destination. Depending on whether the notification recipient is external or internal, each template will be transformed into either a `MessageConversation` object or a `ProgramMessage` object. These intermediate objects will only contain the translated message and subject text.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the intermediate objects? Is that important for users to know?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these templates metadata?

If so we would not need to add Retrieving and deleting Program Notification Template apart from a parameters table for the ones we add on top of the CrudController. It would be enough to add something like

Since working lists are metadata refer to metadata on how to create, update and delete metadata.


There are multiple configuration parameters within the Program Notification Template that are essential for the correct functioning of notifications. These parameters are explained in the table below.

POST /api/programNotificationTemplates

```json
{
"name": "Case notification",
"notificationTrigger": "ENROLLMENT",
"subjectTemplate": "Case notification V{org_unit_name}",
"displaySubjectTemplate": "Case notification V{org_unit_name}",
"notifyUsersInHierarchyOnly": false,
"sendRepeatable": false,
"notificationRecipient": "ORGANISATION_UNIT_CONTACT",
"notifyParentOrganisationUnitOnly": false,
"displayMessageTemplate": "Case notification A{h5FuguPFF2j}",
"messageTemplate": "Case notification A{h5FuguPFF2j}",
"deliveryChannels": [
"EMAIL"
]
}

```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline

The fields are explained in the following table.


Table: Program Notification Template payload

| Field | Required | Description | Values |
|---|---|---|---|
| name | Yes | name of Program Notification Template | case-notification-alert |
| notificationTrigger | Yes | When notification should be triggered. Possible values are ENROLLMENT, COMPLETION, PROGRAM_RULE, SCHEDULED_DAYS_DUE_DATE| ENROLLMENT |
| subjectTemplate | No | Subject template string | Case notification V{org_unit_name} |
| messageTemplate | Yes | Message template string | Case notification A{h5FuguPFF2j} |
| notificationRecipient | YES | Who is going to receive notification. Possible values are USER_GROUP, ORGANISATION_UNIT_CONTACT, TRACKED_ENTITY_INSTANCE, USERS_AT_ORGANISATION_UNIT, DATA_ELEMENT, PROGRAM_ATTRIBUTE, WEB_HOOK | USER_GROUP |
| deliveryChannels | No | Which channel should be used for this notification. It can be either SMS, EMAIL or HTTP | SMS |
| sendRepeatable | No | Whether notification should be sent multiple times | false |

NOTE: WEB_HOOK notificationRecipient is used only to POST http request to an external system. Make sure to choose HTTP delivery channel when using WEB_HOOK.

### Retrieving and deleting Program Notification Template

To retrieve a list of all Program Notification Templates:

GET /api/programNotificationTemplates

To retrieve a specific Program Notification Template by UID:

GET /api/programNotificationTemplates/{uid}

To retrieve a filtered list of Program Notification Templates:

GET /api/programNotificationTemplates/filter?program=<uid>
GET /api/programNotificationTemplates/filter?programStage=<uid>

To delete a specific Program Notification Template by UID:

DELETE /api/programNotificationTemplates/{uid}