feature/IO-3182-Phone-Number-Consent - Checkpoint
This commit is contained in:
@@ -12,6 +12,11 @@ const { phone } = require("phone");
|
||||
const { admin } = require("../firebase/firebase-handler");
|
||||
const InstanceManager = require("../utils/instanceMgr").default;
|
||||
|
||||
/ TWILLIO KEYWORDS;
|
||||
// Note: When we handle different languages, we might need to adjust these keywords accordingly.
|
||||
const optInKeywords = ["START", "YES", "UNSTOP"];
|
||||
const optOutKeywords = ["STOP", "STOPALL", "UNSUBSCRIBE", "CANCEL", "END", "QUIT", "REVOKE", "OPTOUT"];
|
||||
|
||||
/**
|
||||
* Receive SMS messages from Twilio and process them
|
||||
* @param req
|
||||
@@ -58,9 +63,6 @@ const receive = async (req, res) => {
|
||||
const messageText = (req.body.Body || "").trim().toUpperCase();
|
||||
|
||||
// Step 2: Check for opt-in or opt-out keywords
|
||||
const optInKeywords = ["START", "YES", "UNSTOP"];
|
||||
const optOutKeywords = ["STOP", "STOPALL", "UNSUBSCRIBE", "CANCEL", "END", "QUIT"];
|
||||
|
||||
if (optInKeywords.includes(messageText) || optOutKeywords.includes(messageText)) {
|
||||
// Check if the phone number is in phone_number_opt_out
|
||||
const optOutCheck = await client.request(CHECK_PHONE_NUMBER_OPT_OUT, {
|
||||
|
||||
Reference in New Issue
Block a user