Solution for
Sending SMS when loan application's status change
What we want
Notifies users when the status of loan application changes
Problem
Listening to changes of status on applications table
Proposed solution
The service that we use is:
SpeedSMS
Input for SpeedSMS
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
Authorization for SpeedSMS
is Token
'Authorization': 'Basic ' + this.token
SpeedSMS Success response
{
"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
SpeedSMS
Error response
{
"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
Listening to changes
Listening to changes
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
Demo
Solution for Sending SMS on loan application'sstatus change
By dannguyencoder
Solution for Sending SMS on loan application'sstatus change
Solution for Sending SMS on loan application'sstatus change
- 348