Integrate With SMS Providers
Overview
Steps
2
3
Replace placeholders with real data in the code
if (messageForEmployee != null) { messageForEmployee = messageForEmployee.replace("{complaint_type}", localisedComplaint); messageForEmployee = messageForEmployee.replace("{id}", serviceWrapper.getService().getServiceRequestId()); messageForEmployee = messageForEmployee.replace("{date}", date.format(formatter)); messageForEmployee = messageForEmployee.replace("{download_link}", appLink); } if (messageForEmployee.contains("{emp_name}")) { messageForEmployee = messageForEmployee.replace("{emp_name}", fetchUserByUUID( request.getWorkflow().getAssignes().get(0), request.getRequestInfo(), request.getService().getTenantId() ).getName()); }
4
Send the notification
if (!StringUtils.isEmpty(finalMessage)) {
if (config.getIsUserEventsNotificationEnabled() != null && config.getIsUserEventsNotificationEnabled()) {
for (Map.Entry<String, List<String>> entry: finalMessage.entrySet()) {
for (String msg: entry.getValue()) {
EventRequest eventRequest = enrichEventRequest(request, msg);
if (eventRequest != null) {
notificationUtil.sendEventNotification(tenantId, eventRequest);
}
}
}
}
}if (config.getIsSMSEnabled() != null && config.getIsSMSEnabled()) {
// Loop through each recipient group (CITIZEN or EMPLOYEE)
for (Map.Entry<String, List<String>> entry : finalMessage.entrySet()) {
if (entry.getKey().equalsIgnoreCase(CITIZEN)) {
// Send SMS to CITIZEN
for (String msg: entry.getValue()) {
List<SMSRequest> smsRequests = new ArrayList<>();
smsRequests = enrichSmsRequest(citizenMobileNumber, msg);
if (!CollectionUtils.isEmpty(smsRequests)) {
notificationUtil.sendSMS(tenantId, smsRequests);
}
}
} else {
// Send SMS to EMPLOYEE or other recipients
for (String msg: entry.getValue()) {
List<SMSRequest> smsRequests = new ArrayList<>();
smsRequests = enrichSmsRequest(employeeMobileNumber, msg);
if (!CollectionUtils.isEmpty(smsRequests)) {
notificationUtil.sendSMS(tenantId, smsRequests);
}
}
}
}
}Checklist - Summary
Last updated
Was this helpful?