When an Alarm Rule is configured in Zoho IoT, you define the condition under which the alarm should be raised. As part of this configuration, you can specify a custom function to run as the end action. Each time the alarm is triggered, the associated alarm rule custom function is executed.
Alarm rule custom functions must be written using the Deluge scripting language.
This document describes the steps to create one, how to associate it with an alarm rule, and an example script demonstrating its use.
Creating an Alarm Rule Custom Function
To create a command custom function,
Click Add Custom Function.

Select Alarm Rules in the Category field.

Provide the required values in the appropriate fields.Example -Language : DelugeModel/Module: Home Sensor (Select the model on which the device, asset, or location is based on)Display Name: Create Service Order (Provide a name of your choice)Function Name: create_service_order (Provide a name of your choice)Description: A custom function that creates a service order when a particular alarm is triggered.

Click Save. This will open the Code Editor. 
Provide the required code.

Click
Save and Close.

Alarm Rule Custom Function Code Example
Below is an example of a custom function that creates a service record using the asset for which the alarm was raised and the temperature value at the time of the alarm. The temperature threshold and the alarm condition are defined in the alarm rule, so this function is executed automatically whenever the alarm is raised.
current_time = zoho.currenttime;
postBody = Map();
moduleData = Map();
moduleData.put("Name",assetName + "_" + current_time);
moduleData.put("Temperature",temperature);
postBody.put("service_order",moduleData);
post_response = invokeurl
[
url :moduleUrl
type :POST
parameters:postBody.toText()
connection:"app-link"
];
info post_response;
Note: In this custom function a connection is used for authentication. Refer to this document to learn more.Associating with an Alarm Rule
Once the custom function is created, it becomes available during alarm rule configuration for instances of the selected model. You can associate the custom function in the Configure Actions step when creating or editing an alarm rule.
While in the configure action step,
Click Add Action.

Select Custom Function from the dropdown list.

Select the required custom function and click Associate. For this illustration, Create Service Order is selected.

You can see the custom function added as the action.

Click Finish to save.

The custom function will now be associated with the selected alarm rule.
See Also