Skip to main content

Recreatex documentation

SMS notification plugin

The plugin extends the functionality of the Recreatex application to handle the sending of SMS messages. It runs within the Recreatex application at a company level.

Name: SAG.Plugin.SMSNotification.SMSNotificationPlugin

Configuration

The setup and activation of the plugin are done in the SydAdmin application with the assistance of your Vintia consultant.

SMS_NotificationPlugin_Config.png

In the configuration provide the following details:

  • Bearer token: is needed to allow the plugin to use the Spryng SMS Gateway. Enter the token and click Test to verify the connectivity and validity of the token.

  • Originator: This identifier can be used in the reporting tools on the Spryng website. The value can be up to 11 characters long.

  • Default prefix: Default international dialling code is mandatory. If needed, this code will be applied during the phone number validation and formatting process.

  • Error email message: Choose an email template for reporting message-sending errors.

  • Error email address: Enter the recipient of the error email messages.

  • Route: The processing route the message will follow in Spryng, default option is business.

How the plugin operates

The plugin performs 2 distinct operations:

  1. Sending

    • Receiving SMS: An SMS arrives in the database with the status Unsent.

    • Processing unsent SMS: A plugin gathers all unsent SMS messages to process them.

    • Deciding the SMS content:

      • If the SMS record has text in the “Message” column, that text is used as the SMS body.

      • If not, the plugin uses the “LanguageId” and “TemplateId” fields to find a predefined template for the SMS body.

    • Sending SMS: Each SMS is sent to the Spryng service, marked with a reference ID matching the SMS ID in the database. This ID is used later on in the verification call.

    • Status updates:

      • Pending: The SMS was successfully sent to Spryng for processing.

      • Error: There was an issue sending the SMS. The error is logged and included in an error email.

    • Error handling: SMS messages with the status Error, will not be retried in future plugin runs.

  2. Verification

    The plugin will check the SmsMessage table for SMS messages with the status Pending. It will then contact the Spryng SMS Gateway using each SMS ID to get the status of the message.

    There are 3 possible statuses we receive from Spryng:

    • Delivered: The SMS is marked as Sent in the database, indicating success.

    • Failed: Indicates issues, e.g. an incorrect phone number or a full inbox. The SMS is marked as Failed and will not be retried.

    • Pending: The message is still being processed by Spryng, so no action is required from the plugin.

    SMS messages start as Unsent. After processing, they move to the state Pending or Error. From the state Pending, they can transition to Sent if successful or Failed if there are delivery issues.

MSISDN validation and formatting

The plugin formats phone numbers into valid MSISDNs (Mobile Station International Subscriber Directory Numbers) for sending SMS messages. Here are the main steps:

  1. Clean the input: Remove invalid characters using a regex pattern.

    • CLEANUP_PATTERN: [^\d+]|(?<!^)\+

  2. Replace "00" with "+": If the number starts with "00", it is replaced with "+".

  3. Check for valid MSISDN: If the cleaned number starts with "+" and matches the MSISDN pattern, it is considered valid.

    • MSISDN_PATTERN: ^\+?\d+$

  4. Try Belgian format: If the number matches the Belgian pattern, it is reformatted with the +32 prefix.

    • BELGIAN_PATTERN: (^\+32|0032)?4\d{2}\d{2}\d{2}\d{2}$

  5. Try French format: If the number matches the French pattern, it is reformatted accordingly.

    • FRENCH_PATTERN: (^\+33|0033)?0[7]\d{2}\d{3}\d{3}$

  6. Use Default prefix: If none of the above conditions are met, a default prefix is added after removing the leading zeros.

    The default prefix is included in the plugin configuration.

Example: If the default prefix is "+66" and the number is "0532372778", the formatted number will be +66532372778.