Creating and Deploying Custom Functions | Zoho Desk

Creating and deploying custom functions

Custom functions allow extending Zoho Desk to handle scenarios that are more complex. They help automate custom actions and implement business-specific logic based on requirements. For example, if tickets need to be prioritized based on sales data from Zoho CRM, custom functions can be used to build this logic and update tickets accordingly.

Custom functions are written using Deluge script and run within Zoho Desk, without the need to manage servers or infrastructure. This makes it easier to create custom automations and handle complex workflows.

Custom functions can be triggered in different ways:
  1. Through workflow rules when defined conditions are met.
  2. As part of blueprint transitions.
  3. Using schedules at specific times or intervals.
By using custom functions, businesses can automate processes, reduce manual effort, and adapt the help desk to match their exact business needs.

Availability

Info Permission Required
Users with the Support administrator permission can create and deploy custom functions.
Check Feature Availability and Limits

Creating custom functions

Functions can be created using the Deluge Script Builder, which offers a drag-and-drop interface to construct scripts. This simplifies the process by allowing users to build functions without needing to learn or remember Deluge syntax and functions.

Generating deluge scripts using Zia

Zia Assistant can generate Deluge scripts for custom functions based on the prompt. Instead of writing code from scratch, users can simply explain what they need and Zia will generate an appropriate script. Earlier, building custom functions meant having hands-on experience with Deluge, writing the code, testing it, and validating everything before deployment. With Zia’s integration, that technical barrier is reduced, making automation creation faster and more accessible.

For example, if you want the customer’s email description to be extracted and auto-populated as the ticket description. Instead of manually writing a Deluge script, you can provide the following prompt to Zia Assistant which will generate a ready-to-use script: "Whenever a ticket is created from email channel, fetch the email body and the latest email thread content and update it in the ticket description field." Based on this requirement, Zia Assistant Bot generates a structured Deluge script that retrieves the most recent email thread and updates the ticket description automatically such as:

Enabling deluge assistant bot

Support administrators can enable Zia Deluge Assistant bot based on their requirements. Zia Deluge Assistant bot is disabled by default and must be enabled manually before it becomes available in Custom Functions.

Notes
Note:
  1. This setting is organization-specific. Enabling it will make the Deluge Assistant available only for the current organization.
  2. Zia Deluge Assistant is available only for custom functions within workflows.
To enable Zia deluge assistant bot
  1. Navigate to Setup > Zia > Generative AI.
  2. Under Feature Preferences, enable Zia Deluge Assistant.
  3. In the Data usage of disclosure for AI alert click Accept.


To create a function:
  1. Navigate to Setup ( > Automations > Workflows > Custom functions.
  2. Click New Functions.
  3. Under Basic Information:
    1. Enter a Name and Description for the function.
    2. Select the Module in which the function needs to be triggered.
  4. Under Argument Mapping, do the following:
    1. Provide the Method Name.
    2. To map the function to a custom value, enter the Argument Name and select the corresponding value.
    3. Click the Add (  icon to add more arguments, and repeat the same steps as required.
  5. Write the required logic in the Deluge Script Editor.
  6. Deluge script can be written manually or generate it using the Zia Deluge Assistant Bot.
    1. Click the Zia icon at the bottom-right corner of the Deluge Script Editor.
    2. Enter your requirement as a prompt and click the Send icon.
    3. Once satisfied with the generated script, click the Copy icon at the top-right corner of the script window.
    4. Paste the copied script into the Deluge Script Editor.

  7. Click Save to edit or execute the script later.
  8. Click Save & Execute Script to validate and run the code.

Info

Limitations

  1. Function Executions - 50000 calls/day
  2. Statements - 200000 statements/function
  3. Integration Tasks - 500000 API calls/month
  4. Invoke URL - Unlimited calls
  5. Send Email - 2500 emails/day
  6. Custom function execution is limited to two iterations to maintain system performance, prevent unnecessary API calls, and avoid potential data issues.
Alert

Error messages and details

Here is the list of failure messages you might encounter while using custom functions:
  1. Error executing email task - A 'send mail' task could not be executed.
  2. Error evaluating invoke api task : {0} - API calls could not be executed.
  3. Wrong DataType specified. The Template Variable {0} should be of type {1} - You had mentioned a data type as string but had provided an integer value in the 'set variable' task.
  4. Error in executing {0} task - An integration task could not be called under the 'call function'.
  5. Unable to update template variable {0} - An expression could not be executed.
  6. Error evaluating INVOKE URL Function - Either the configured parameters are wrong or there is no proper response from the URL.

Deploying custom functions in workflow rules

Custom functions can be deployed within workflow rules after they are tested and validated. For example, a function can be created to automatically set ticket priority based on customer type. Once the function is tested, it can be attached to a workflow rule so that whenever a ticket is created for a premium customer, the function runs and updates the priority to high automatically.

To associate a function to a workflow rule
  1. Navigate to Setup > Automation > Workflows.
  2. Click Create Rule on the Workflow Rules page.
  3. Enter the basic information about the workflow and click Next.
  4. In the following page, specify the action for execution and rule criteria.
  5. Under Actions, click the Add icon  ( .
  6. Select an existing custom function.
  7. Click Save.


Deploying custom functions in schedules

Custom functions can be deployed and scheduled to be executed which allows tasks to be executed automatically at specific times or on a recurring basis. Learn more on Creating and Managing Schedules.

Viewing Execution logs

Execution logs provide a detailed record of custom function executions, including both successful and failed runs. These logs are generated when a function is triggered through an automation, such as a workflow rule, and executed on records like tickets based on defined criteria.

The following details can be viewed in execution logs:

  1. Execution status and details
  2. Argument values passed to the function
  3. Output from print statements
Execution logs help in monitoring how custom functions behave during execution and provide better visibility into automated processes.

Execution logs help to:

  1. Debug issues when a function fails.
  2. Identify the root cause of errors.
  3. Review successful executions to understand expected behavior.
Notes
Note:
  1. Execution logs are available for both successful and failed function executions.
  2. Logs are generated only after a function is executed and are accessible to users with Helpdesk Automation permissions.
  3. Logs for successful executions are retained for 24 hours.
  4. Logs for failed executions are retained for 30 days.

To view execution logs for a custom function:
  1. Navigate to Setup ( ) > Automation > Workflows.
  2. Click Custom Functions under the Workflows.
  3. Click Execution Log.
  4. In the Execution Log list page, scroll to the bottom to find the Execution logs section.

Info
If execution logs are not being generated:
  1. Execution logs will not be available if no custom function has been executed.
  2. Manually refresh the page to see the newly added log data.
While working with execution logs:
  1. When the custom function execution limit is reached, log generation pauses and resumes the next day.
  2. There is no limit on the number of logs that can be displayed.
  3. Refresh the page to view logs for recently executed custom functions.

Working with Deluge Script Builder

The Deluge Script Builder helps you to program the custom functions using drag and drop user interface and execute the function within Zoho Desk. It enables you to convert the complex application logic into simple deluge code, without remembering the syntax and custom functions of Deluge Script. It contains the following components:
  1. Deluge Script Code
  2. Deluge Tasks
    1. Conditions
    2. Miscellaneous
    3. Debug
    4. List Manipulation
    5. Map Manipulation
    6. Web Data
    7. XML Manipulation
  3. Code Execution

Predefined credentials in Deluge

The Deluge editor allows users to specify only two predefined credentials:
  1. loginUserId: Refers to the user currently logged into the portal.
  2. adminUserId: Refers to the DRE admin.
The portal user who initially creates or executes a custom function or a new connection will be designated as the DRE admin.

To execute the command in the Deluge editor:

Using adminUserId in CF Scripts

When adminUserId is used in custom function scripts, such as setting the From address in a send mail Deluge task, the recipient will see the email as sent from the current DRE admin’s username.


Updating adminUserId in CF Scripts

The adminUserId cannot be modified directly within the Deluge editor. If it needs to be updated to another portal user, a request must be raised with the support team along with the required details.
      Current value:
            Email : abc@zylkers.com
            ZUID : 12345
      New value:
            Email : xyz@zylkers.com
            ZUID : 98765
Once the data provided is validated, the update process will be initiated. 

List of Deluge Tasks