Event Hooks help developers to introduce their own middlewares in the execution flow of certain UI actions.
Like events, developers need to subscribe to these event hooks to control the execution of UI action by allowing or terminating the flow.
For instance, let us consider that you are creating an extension for a bug-tracking software. The extension can record Zoho Desk tickets as issues in the bug-tracking software.
Now say a support agent tries to close a Zoho Desk ticket that has been recorded as an issue in the bug-tracking software. If the issue is not resolved in the third-party tool, but the ticket is closed in Zoho Desk, it would lead to a mismatch of status, causing confusion.
To prevent such a scenario, you can configure the extension to subscribe to the Zoho Desk hook defined for the close ticket event. With this hook in place, you can further configure your extension such that when an agent tries to close the ticket, the extension checks if the corresponding issue in the third-party tool is resolved. If it is resolved, the extension can give a go-ahead to close the ticket in Zoho Desk, else the ticket close event will not be executed and a relevant message will be displayed.
Zoho Desk currently supports hooks for the following events:
- Reopening a ticket
- Closing a ticket
- Adding a ticket comment
- Editing a ticket comment
- Changing the status of a ticket
- Sending a ticket response
- Closing a ticket on sending ticket response
Extensions can pause the outcome of events by passing either boolean values or promises in the event handler.
- If the boolean value TRUE is passed, the event will be executed
- If the boolean value FALSE is passed, the event will be terminated.
Similarly, if the extension resolves the promise, the event will be executed, and if the extension rejects the promise, the event will be terminated. The reason for terminating the event can be displayed as an error message to end-users.
Extensions with subscriptions to hooks must respond within 30 seconds of the event getting triggered. If this time is exceeded, control provided to the extension will be lost and the event will be executed.
Multiple extensions can subscribe to a single hook. In such a scenario, the event will be executed only if all extensions subscribed to the event pass TRUE or resolve the promise. If even one extension passes FALSE or rejects the promise, the event will be terminated.
Hook to Use When a Ticket is Reopened