Skip to main content
Skip table of contents

Monosign - Notification SMS Troubleshoot

How to remove “+“ from the Phone Number before sending an SMS

Some SMS Providers don’t allow you to use “+” with the phone number. And it would help if you trimmed that value before sending an SMS. If you use the SMS option to send OTP codes or any reminder of Password Change with SMS, you can change the flow as you wish.

If you want to change your SMS Phone Number before sending an SMS for some cases, you can use the Notification Hooks. Go to the Management Portal > System and Configurations to configure it, then go to the Notification (1) section. Navigate to the Notification Hook (2) tab, Enable (3) it and click the Show Editor (4) button.

Type the following code to change the recipient's Phone Number before you send an SMS.

C#
if(notificationEvent.ChannelName == "SMS")
{
    if(notificationEvent.Recipient.StartsWith("+"))
    {
        notificationEvent.Recipient = notificationEvent.Recipient.Substring(1);
    }
}

If you want to clear all spaces in the phone number; you can use an improved version of that code like the following;

C#
if(notificationEvent.ChannelName == "SMS")
{
    // This will remove "+" if the phone number starts with it.
    if(notificationEvent.Recipient.StartsWith("+"))
    {
        notificationEvent.Recipient = notificationEvent.Recipient.Substring(1);
    }
    // This will remove all spaces in the phone number
    notificationEvent.Recipient = notificationEvent.Recipient.Replace(" ", "");
}

📋 Other articles may be related to this topic

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.