Creating Functions - Zoho Desk Knowledgebase

Creating Functions in Zoho Desk

Functions are pluggable workarounds that let you accomplish tasks that is not doable out-of-the-box. For example, let' s assume that you want to prioritize customer tickets based on their sales probability in Zoho CRM. However, this option cannot be accomplished in Zoho Desk. So how do you do it? Your solution: Functions

Info Permission Required
Users with the Support Administrator permission profile can access this feature.
Check Feature Availability and Limits

All about functions

Functions are an implementation of serverless architectures where Zoho Desk dynamically manages the provisioning of servers. You can write functions using the Deluge script and run the code (proprietary within Zoho Desk) without worrying about deploying it in servers. This provides you with ideal business implementations, which sounds quite pleasant to the ears and probably light on the budget as well. 

Why Functions?

  1. Provides immense flexibility of accomplishing tasks when met with specific criteria or automatically on a daily, weekly, monthly, or yearly intervals.
  2. Empowers you to explore alternative ways of solving a help desk problem.
  3. Eliminates the need to wait for a feature to be built into the product. You have more control over what you want to get done. After all, requirements differ from business to business.

Using Functions

Functions can be used in 3 places, namely:
  1. Workflow rules
  2. Blueprints
  3. Schedules
In workflow rules, you can set up functions such that when it matches certain criteria, Zoho Desk automatically triggers the function and updates the corresponding record. Similarly, when used in blueprints, functions can be triggered by completing a transition. In schedules, functions can be triggered either at a particular time or on a recurring basis.

Generating deluge script with 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 

Zia 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.
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.

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.

Creating Functions

Functions can be created using the Deluge Script builder that provides a drag-and-drop user interface to add Deluge scripts without the need to learn or remember the Deluge syntax and functions.

To create a function:
  1. Navigate to Setup > Automations > Workflows > Custom functions 
  2. Click New Function in the top-right corner.
  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:
    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 + 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.


  9. In the New Function page, do the following:
    1. Give a Name and Description (optional) for the function.
    2. Choose the Category where the function is meant to be added.
      If the function is going to be added in workflows or blueprints, choose 
      Automation; otherwise, choose Schedules.
    3. Select the Module for which you want to trigger the function.
      This option is available only when you select Automation in Step 6.



    4. Click the Edit Arguments icon (  ).
      This option is available only when you select Automation in Step 6.
    5. In the Edit Arguments window, set the arguments to be used in the script, with field name or custom value in the respective module.
    6. Write your required function in the Deluge Script Editor.
    7. Click Save & Execute Script to validate your code.
  10. Click Save.
    The function gets listed in the List View of the
    Functions page.
NotesNote: The functions specified to be used at a particular location cannot be used elsewhere. For example: a function configured for automation cannot be used in Schedules.

Deploying Functions in Workflow Rules

As a Zoho Desk administrator, you can deploy thoroughly tested custom functions in workflow rules.

To associate a custom function to a workflow rule:
  1. Click the Setup icon (  ) in the top bar.
  2. Click Workflows under Automation.
  3. Click Create Rule on the Workflow Rules page.
  4. Enter the basic information about the workflow and then click Next.
  5. In the following page, specify the action for execution and rule criteria.
  6. Under Actions, click the Add icon (  ) and then select Existing corresponding to Custom Functions.
  7. Select an existing custom function.
  8. Click Save.

Deploying Functions in Schedules

As a Zoho Desk administrator, you can deploy thoroughly tested custom functions in schedules. To learn more about this, click here.

Custom Function: Execution logs

The execution log feature provides a detailed record of both failed and successful executed custom functions. It operates as an action linked to an automation rule, applying the rule to entities like 'Tickets' based on predefined criteria.
The following details can be viewed:
  1. Execution details
  2. Argument values that have been passed
  3. Print statements

Info
Info: Execution logs can be viewed for both successful and failed custom function executions.

Why use execution logs in custom functions?

Execution logs provide valuable data that can be used to:

  • Debug issues related to custom function execution failures.
  • Identify the root cause of the said failures.
  • Analyze successful executions to understand what works.

Info
Info: Execution logs will be available once the custom function is executed, provided the user has Helpdesk Automation permissions.

To view execution logs for a custom function:

  1. Click the Setup icon (  ) in the top bar.
  1. Click Workflows under the Automation menu.
  2. Click Custom Functions under the Workflows sub-menu.
  3. In the Custom Functions page, click the Execution Log subtab.
  4. In the Execution Log list page, scroll to the bottom to find the Execution logs section.
Info
Info:
  1. The execution logs for'success' cases will be available for 24 hours.
  2. The execution logs for 'failure' cases will be available for 30 days.
Notes
Points to note if execution logs are not being generated:
  1. There has been no custom function execution made.
  2. Make sure to manually refresh the page to see the newly added log data.
Points to be noted while working with execution logs:
  1. Once the custom function execution limit is reached, execution logs will also pause and will resume the next day when execution restarts.
  2. There is no limit on the number of execution logs that can be displayed at a time.
  3. Refresh the page to view logs for newly executed custom functions.