The Notifications Mediator service allows external tools to setup and schedule notifications for clients. This notifications act as reminders, so the user are aware of future activities. This, together with the Communication Mediator Service, allows the sending of the notifications through different communication channels.
...
Missing information here
...
Schedule Notification
POST /notification/schedule
Schedule Notification endpoint allows the creation and scheduling a notification. The service then receives requests containing the required parameters, analyzes the provided information and, upon verification, saves the notification in a data persistence tool.
...
Code Block |
---|
{ //"project": string. LAC_HIV/ LAC_FP // not implemented //"clientId": string. DHIS2 TEI or Mongo ID // not implemented "teiclientId": "" "msg": "", "channel": "", "to": string. "", "templateId": "", "templateParams": "", "eventDate": "", "sendNow": false } |
Parameter Name | Type | Description |
---|---|---|
teiclientId | string | Could be:
|
msg | string | Message to be linked to the notification. |
channel | string | Way of communication where the scheduled message will be sent: Current supported values:
|
to | string | Identifier used by the specified channel to send the message. |
templateID | string | Identifier used by the specified channel to use a pre-defined template. |
templateParams | string | Parameters to be used in the template specified. |
eventDate | string | Date on which the notification will be sent. |
sendNow | boolean | Parameter to specify if the notification should be sent on creation time. |
Request body SMS
Code Block |
---|
{ "teiclientId": "cMyjKYJtgSI",// add project, change to clientID "channel": "SMS", "templateId": "template_3", "msg": "hi", "to": "+26658636836", "templateParams": "", "eventDate": "2024-02-23T13:18:30.800Z" } |
...
Code Block |
---|
{ //project id "teiclientId": "cMyjKYJtgSI", // change for client id "channel": "facebook", "templateId": "template_3", "templateParams": "{'quick_replies':[{'content_type':'text','image_url':'http://example.com/img/red.png','payload':'<POSTBACK_PAYLOAD>','title':'Red'},{'content_type':'text','image_url':'http://example.com/img/green.png','payload':'<POSTBACK_PAYLOAD><','title':'Green'}],'text':'Pick a color:'}", "to": "1234jdj204", "eventDate": "2023-11-23T13:18:30.800Z", "sendNow": true } |
...
Code Block |
---|
{ "notifications": [ { //project --> to be added "teiclientId": "cMyjKYJtgSI", // replace by id "msg": "hi", "channel": "facebook", "to": "+26658636836", "templateId": "1", "templateParams": "", "eventDate": "2023-11-23T13:18:30.800Z" }, { "teiclientId": "cMyjKYJtgSI", "msg": "hi", "channel": "facebook", "to": "+26658636836", "templateId": "3", "templateParams": "", "eventDate": "2023-11-23T13:18:30.800Z" } ] } |
...
Code Block |
---|
{ "notifications": [ { 200 sucsess - notification scheduled "teiclientId": string. DHIS2 TEI, // to be discontinue (replaced by id)mongoDB _id, "msg": string. Message text to send, "channel": string. Accepted values: facebook whatsapp SMS, "to": string. It could be a phoneNumber or facebook/whatsapp ID, "templateId": string. The template ID. This ID is used for sending FBM/WA as well as for rquesting a reminder cancelation (see below), "templateParams": string. Template parameter. Needs parse to string the value, "eventDate": String. The datetime. You can check the format in the below example, "sendNow": boolean "status": scheduled } ] } |
...
Cancel Notification
POST /notification/cancel
Cancel Notification endpoint allows to update the status of a notification to ‘cancelled’. Canceling by Track Entitiy ID, we will cancel all the TEI clientId events. Canceling by event ID, we will cancel a single event.
...
Code Block |
---|
{ //project --> to be added "tei": "", "templateId": "", "eventId": "" "clientId": "" } |
Parameter Name | Type | Description |
---|---|---|
teiclientId | string | ID associated to a DHIS2 TrackedEntityInstance or _id associated to a MongoDB client document. |
templateId | string | Identifier used by the specified channel to use a pre-defined template. |
eventId | string | Id assigned to a notification. |
clientId | string | Id assigned to a client. |
...
Code Block |
---|
{ //project --> to be added "teiclientId": "019283SFD", // replace by id "templateId": ["template_3","appointment"], } |
...
Code Block |
---|
{ //project --> to be added "teiclientId": "019283SFD", // replace by id "templateId": "template_3", } |
...
This cancel-notification
endpoint allows for the cancellation of notifications either by the Track Entity ID or by the Event ID, providing flexibility in managing and removing notifications from the system. Adjust the specifications or examples as needed to align with your service implementation.
...
Notification Status
POST/notification/status/{project}/{clientId}
...
Name | Type | Description |
---|---|---|
event | string | Id assigned to a notification. |
status | string | Status of the current notification |
templateId | string | ID of notification template used to scheduled a message to a client. |
...
Send Notifications → move to a dedicated page
POST /dhis2/send-notifications
Triggered by a cron job, this Send Notification endpoint retrieves all scheduled messages based on date ranges and the event status up to the time the endpoint is called and where the notification status is set as 'scheduled'. ' It This endpoint prepares message content to be sent to a messaging service Communication Mediator Service. After sending the messages, this service updates the event notification status and adds . Additional notes are included in the notification in case of message delivery failure or errors encountered within the messaging service. We are using the cron service
This endpoint is meant to be triggered by a cron job provided by OpenHIM.
...
However, Send Notifications endpoint is exposed so the users can manually trigger the sending of notifications
There are two main reasons to do it by date ranges are both:
DHIS2 endpoints restrictions
We get the notifications pending to send before the current minute and after the previous 7 days. In this This way, if for some reason we have notifications pending to send for any reason (the server was down, DHIS2 was not working in the previous hours…) we can send the previous notifications.
...
Scheduled Notifications
Trigger the cron job to send scheduled notifications by sending a POST
request to {openHIM-env}/dhis2/send-notifications
. Executing this, we will send the notifications until the current minute. We don’t need to add any information on the payload