Pending SMS Notification
This event hook is triggered when there is a pending SMS Notification that needs to be sent.
Event Hook Name: PendingSMSNotification
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. 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 addon successfully handled the notification. |
|---|---|
NotificationSent | A boolean value to indicate if the addon has successfully sent an SMS notification. This value is only used if handled is true. |
AllowRetry | A boolean value to indicate if the addon will attempt to resend the notification Default: 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("PendingSMSNotification", "ProcessNotification");
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;
sentInExternalSystem, errorMessage = SendUsingExternalApi
(smsNotificationEventArgs.MobilePhone,
smsNotificationEventArgs.Message);
smsNotificationEventArgs.Handled = true;
smsNotificationEventArgs.NotificationSent = sentInExternalSystem;
smsNotificationEventArgs.Note = errorMessage;
end
end
function SendUsingExternalApi(phone, message)
--The details of implementing a call to an external API to send SMS
--notifications is outside the scope of this example. For the purposes
--of this example this check will always return true and "Awaiting My
--System Processing"
return false, "SMS API is not available";
end