Overview
The objective of this service is to create a common point to manage all the SMS notifications being sent out of the platform. Notification SMS service consumes SMS from the kafka notification topic and process them to send it to an third party service. Modules like PT, TL, PGR etc make use of this service to send messages through the Kafka Queue.
Pre-requisites
Before you proceed with the documentation, make sure the following pre-requisites are met -
Prior Knowledge of Java/J2EE
Prior Knowledge of SpringBoot
Prior Knowledge of Third party API integration
Prior Knowledge of REST APIs and related concepts like path parameters, headers, JSON etc
Prior Knowledge of Kafka and related concepts like Producer, Consumer, Topic etc.
Key Functionalities
Provide common platform to send SMS notification to user
Support localised SMS.
Easily configurable with different SMS service provider.
Interaction Diagram
...
Configuration Details
This service is a consumer, which means it reads from the kafka queue and doesn’t provide facility to be accessed through API calls, there’s no REST layer here. The producers willing to integrate with this consumer will be posting a JSON onto the topic configured at ‘kafka.topics.notification.sms.name’. The notification-sms service reads from the queue and sends the sms to the mentioned phone number using one of the SMS providers configured.
...
The implementation to be used can be configured by setting sms.provider.class
.
Console
The Console
implementation just prints the message mobile number and message to the console
Generic implementation
This is the default implementation, which can work with most of the SMS Provider. The generic implementation supports below
...
So if you use sms.config.map={'u':'$username', 'p':'password'}
. Then the API call will be passed <url>?u=<$username>&p=password
Message Success or Failure
Message success delivery can be controlled using below properties
...
If you want to verify some text in the API call response set sms.verify.response=true
and sms.verify.responseContains
to the text that should be contained in the response.
Blacklisting or Whitelisting numbers
It is possible to whitelist or blacklist phone numbers to which the messages should be sent. This can be controlled using below properties:
...
sms.blacklist.numbers=5*,9999999999,88888888XX
will blacklist any phone number starting with 5
, or the exact number 9999999999
and all numbers starting from 8888888800
to 8888888899
Prefixing
Few 3rd party require a prefix of 0
or 91
or +91
with the mobile number. In such a case you can use sms.mobile.prefix
to automatically add the prefix to the mobile number coming in the message queue.
Error Handling
There are different topics to which the service will send messages. Below is a list of the same:
...
Property | Value | Remarks |
egov.core.notification.sms | It is the topic name to which the notification sms consumer would subscribe. Any module wanting to integrate with this consumer should post data to this topic only. | |
sms.provider.class | Generic | This property decides which SMS provider is to be used by the service to send messages. Currently, Console, MSDG and Generic have been implemented. |
sms.provider.contentType | application/x-www-form-urlencoded | To configure form data or json api set sms.provider.contentType=application/x-www-form-urlencoded or sms.provider.contentType=application/json respectively |
sms.provider.requestType | POST | Property to configure the http method used to call provider |
sms.provider.url | URL of the provider. This will be given by the SMS provider only. | |
sms.provider.username | egovsms | Username as provided by the provider which is passed during the API call to the provider. |
sms.provider.password | abc123 | Password as provided by the provider which is passed during the API call to the provider. This has to be encrypted and stored |
sms.senderid | EGOV | SMS sender id provided by the provider, this will show up as the sender on receiver’s phone. |
sms.config.map | {'uname':'$username', 'pwd': '$password', 'sid':'$senderid', 'mobileno':'$mobileno', 'content':'$message', 'smsservicetype':'unicodemsg', 'myParam': '$extraParam' , 'messageType': '$mtype'} | Map of parameters to be passed to the API provider. This is provider-specific. $username maps to sms.provider.username $password maps to sms.provider.password $senderid maps to sms.senderid $mobileno maps to mobileNumber from kafka fetched message $message maps to the message from the kafka fetched message $<name> any variable that is not from above list, is first checked in sms.category.map and then in application.properties and then in environment variable with full upper case and _ replacing -, space or |
sms.category.map | {'mtype': {'*': 'abc', 'OTP': 'def'}} | replace any value in sms.config.map |
sms.blacklist.numbers | 5*,9999999999,88888888XX | For blacklisting, a “,” separated list of numbers or number patterns. To use patterns use X for any digit match and * for any number of digits match |
sms.whitelist.numbers | 5*,9999999999,88888888XX | For whitelisting, a “,” separated list of numbers or number patterns. To use patterns use X for any digit match and * for any number of digits match |
sms.mobile.prefix | 91 | add the prefix to the mobile number coming in the message queue |
Deployment Details
Add the variables present in the above table in particular environment file
Deploy the latest version of egov-notification-sms service.
Integration
Integration Scope
Notification SMS service consumes SMS from the kafka notification topic and process them to send it to an third party service. Modules like PT, TL, PGR etc make use of this service to send messages through the Kafka Queue.
Integration Benefits
Provide interface to send notification SMS on user mobile number.
Support SMS in various language.
Steps to Integration
To integrate, create the SMS request body given in the example below.
Provide the correct mobile number and message in the request body
and send it to the kafka topic:- egov.core.notification.smsCode Block { "mobileNumber": "9480411228", "message": "Hey, how you doing?" }
The notification-sms service reads from the queue and sends the sms to the mentioned phone number using one of the SMS providers configured.
Reference Docs
Doc Links
Title | Link |
SMS Template Approval Process |
...