Customizing Information Content and Access > Adding a Custom Notification Handler
Adding a Custom Notification Handler
Two notification delivery methods are provided with the ThingWorx Apps: email and text (SMS) delivery. These delivery methods are enabled and configured in Configuration and Setup > Notification Delivery. By default, individual users must have their Notification Preference configured in Configuration and Setup > Users to be added as a recipient of an alert notification.
To use a different delivery method for notifications, you can create a new notification handler, and set it as the AdditionalAlertNotificationHandler on the Configuration page for the PTC.Factory.C_LaunchPointConfigurationThing_[ReleaseVersion]. Any user can then be added as a recipient on an alert.
To create a new notification handler:
1. Create a new Data Shape, for example MyNotificationHandlerContent, and click Save. This Data Shape is where, if needed, you can define content for your notification. For examples, see SMSContent and EmailContent.
2. Create a new Thing Template, for example MyNotificationHandlerTemplate, with a Base Thing Template of NotificationHandler.
3. On the MyNotificationHandlerTemplate, click Services, then click Add for the My Services table to add a new service with a Service Name of Notify. Under Inputs, add the following input parameters:
Name
Base Type
Data Shape
Infotable Type
definition
NOTIFICATIONDEFINITIONNAME
event
INFOTABLE
Event
Just Infotable
config
INFOTABLE
Select the Data Shape created in step 1, for example MyNotificationHandlerContent
Just Infotable
a. Click Add under Inputs.
b. On the New Input window, enter the properties for an input parameter, as shown in the table.
c. Click Done.
d. Repeat steps 3a through 3c for each input parameter.
Click Done to create the new service.
4. Click Save.
5. Create a new Thing, for example MyNotificationHandler, with the Thing Template set to the Thing Template created in step 2. Click Save.
6. Create a localization token for your notification handler Thing, notificationHandlers.MyNotificationHandler. For more information, see Localization Tables in the ThingWorx Help Center.
7. From the More menu at the top right of the Thing, select Export for Source Control.
8. Open the exported file in a text editor.
9. Locate the ConfigurationTable tags. Inside the ConfigurationTable tags, find the empty Rows tags.
10. Add the following content inside the Rows tags:
<Row>
<configuration><![CDATA[<DataShape>]]></configuration>
<handlerID><![CDATA[<UUID>]]></handlerID>
<localizedName><![CDATA[[[<TokenName>]]]]></localizedName>
<serviceName><![CDATA[<Service>]]></serviceName>
</Row>
Replace the variables as follows:
<DataShape>—Name of the Data Shape created in step 1.
<UUID>—A universally unique identifier (UUID). To generate UUID, use a UUID generator such as https://www.uuidgenerator.net.
<TokenName>—The localization token created in step 6.
<Service>—Service created in step 3.
For example:
<Row>
<configuration><![CDATA[MyNotificationHandlerContent]]></configuration>
<handlerID><![CDATA[90ded6fc-7fd7-4141-80ee-34aea5e6fb71]]></handlerID>
<localizedName><![CDATA[[[notificationHandlers.MyNotificationHandler]]]]></localizedName>
<serviceName><![CDATA[Notify]]></serviceName>
</Row>
11. Save the file.
12. In ThingWorx Composer, select Import/Export > Import > From File.
13. Click Choose File, and navigate to the updated export file.
14. Ensure that Entities is selected, and click Import.
15. Click Close.
16. Open PTC.Factory.C_LaunchPointConfigurationThing_[ReleaseVersion], and click Configuration.
17. For AdditionalAlertNotificationHandler, search for and select the Thing created in step 7, for example MyNotificationHandler. Click Save.
Now, when creating an alert, any user can be selected as an alert recipient, not only those users who have their Notification Preference configured. For more information, see Configuring Alerts.
Was this helpful?