diff --git a/api/blueprints/common/otp/timed_otp.py b/api/blueprints/common/otp/timed_otp.py index 54cf3a4..e0bb4f8 100644 --- a/api/blueprints/common/otp/timed_otp.py +++ b/api/blueprints/common/otp/timed_otp.py @@ -230,8 +230,17 @@ async def generate_otp( ) # Format the message: + phone_no = regex.replace( + text = inbound_data.recipientNo, + pattern = r"[^\d]", + substitute_text = "" + ) + if ( + not phone_no.startswith("0") and + not phone_no.startswith("254") + ): phone_no = "0" + phone_no sms_message = SavvyBulkSMSKenyaMessage( - recipientNo = inbound_data.recipientNo, + recipientNo = phone_no, text = inbound_data.smsText.replace(inbound_data.smsReplace, str(otp_response.data)) )