Check Sending SMS Notification

Check Sending SMS Notification

This event hook is triggered when there is an SMS notification that is at a status of Sending. An addon that sends a pending SMS notification and updates a notification to a status of Sending needs to also implement the check to ensure a notification will properly be updated to Sent or Failed.

Event Hook Name: CheckSMSSending

Input Parameters

MobilePhone

The mobile phone number that the message should be sent to.

Message

The message that should be delivered.

NVTGC

The NVTGC that is associated with the user who is receiving the notification.

Username

The username associated with the notification.

TransactionNumber

The transaction number associated with the notification. This may be null if the notification is a user account type of notification not associated with a request.

Date

The date the notification was generated.

Output Parameters

Handled

A boolean value to indicate if the addon has handled the SMS Notification. If no addon handles the SMS notification will be updated to a status of Not Handled so it will not be triggered for delivery again.

DO NOT explicitly set this to false even if your addon ignored the pending notification; doing so may cause the addon to not be flagged appropriately if another addons
successfully handled the notification.

Status

A value to indicate the state of the notification after being handled. Allowed values are Sending, Sent, and Failed. The Status parameter will only be used when the Handled parameter is set to True. The default is Sent.

  • Sent should be used when the SMS notification was successfully sent.

  • Failed should be used when the SMS notification encountered errors when being delivered.

  • Sending should be used when the SMS notification is still being sent. This is useful in situations where an immediate status cannot be provided from the SMS notification API. Notifications that remain in the Sending status will trigger the CheckSMSSending trigger.

AllowRetry

A boolean value to indicate if the addon will attempt to resend the notification. The default is False.

Note

A note that can be associated with the notification. Any previous notes set will be available in this parameter as input as well.

This value is only used if Handled is true. If AllowRetry is on, the note will be modified to indicate the number of retries that have occurred. This is an optional parameter.

Example

The following is an example of the syntax used to register for the SMSNotification event hook:

function Init() RegisterSystemEventHandler("CheckSMSSending", "CheckNotification"); end function ProcessNotification(smsNotificationEventArgs) --If multiple addons are registered for the PendingSMSNotification event, you --should verify that another addon has not already handled the notification if (smsNotificationEventArgs.Handled) then LogDebug("The notification was already handled in another addon. Skipping processing for Notification " .. smsNotificationEventArgs.ID); return; end --In a Shared Server environment you may want to limit which NVTGCs the addon --will handle if (smsNotificationEventArgs.NVTGC = 'ILL') then local sentInExternalSystem; local errorMessage; --Assuming the note field was used to store a unique --id for the external API sentInExternalSystem, errorMessage = CheckExternalApi (smsNotificationEventArgs.Note); smsNotificationEventArgs.Handled = true; if (sentInExternalSystem) smsNotificationEventArgs.Status = "Sent"; else smsNotificationEventArgs.Status = "Failed"; end; smsNotificationEventArgs.Note = errorMessage; end end function CheckExternalApi(externalNotificationId) --The details of implementing a call to check an external API for SMS status --is outside the scope of this example. For the purposes of this example this  --check will always return true. return true, "";end