Sending SMS when loan application's status change
Notifies users when the status of loan application changes
Listening to changes of status on applications table
The service that we use is:
1. to: array of numbers
2. content: SMS content
3. SMS type:
{
"to":[
"phone number1",
"phone number2"
],
"content":"sms content",
"sms_type":"type of sms
(advertisement, brand name,...)",
"sender":"brandname or deviceId"
}
2 - customer care
4 - sms with default brandname: Notify
4. sender: only set if sms_type = 3 or 5
3 - is sms with company's brand
5 - is sms from Android app or personal phone number
is Token
'Authorization': 'Basic ' + this.token
{
"status":"success",
"code":"00",
"data":{
"tranId":"transaction id number",
"totalSMS":"total sms number",
"totalPrice":"total price number",
"invalidPhone":"array of phone numbers"
}
}
1. tranId: used to further checking of status
2. totalSMS: the total number of sms has sent
3. totalPrice: the price of total sms sent
4. invalidPhone: the array of invalid phone numbers
{
"status":"error",
"code":"error code",
"message":"error description"
}
1. status: the status code
2. code: the error code
3. message: the message of the error
Now, all applications are stored on applications collection on Firestore
We will listen to the changes of the STATUS field on all applications' documents
To do this, we use Trigger feature of Firebase
Trigger flow
STATUS of an applications' document changes
Get clientId of the document
Get get client document from clientId
Get get phoneNumber of the client
Firebase Trigger listens -> start our code
With phoneNumber of the client, we send the SMS:
"Your loan application's status has changed from X to Y"
X: the previous status of the application
Y: the updated status of the application