Bot Call Handler

Timely communication makes a huge difference during a crisis. Whether notifying the IT team about a server crash or alerting a doctor about a patient's emergency, immediate assistance is necessary in critical scenarios! Cliq's Bot Calls guarantees top priority attention in crucial cases. Get ready to learn how to set up bot calls.

Bot Calls in Zoho Cliq

Enabling Bot Calls

You can enable bot calls while creating or modifying an existing bot.

Enabling Bot calls during new bot creation
  1. Click on your profile picture, then select Bots and Tools.

  2. Check the box to enable bot calls, then click Save Bot.

Enabling bot calls during creation of bot 
 

Enabling / Disabling Bot calls to an existing bot
  • For Developers (the bot's creator)

    • Click on your profile picture, select Bots and Tools, and navigate to the bot to which bot calls need to be enabled.

    • Navigate to your bot's configuration page, then toggle the checkbox to turn bot calls on or off and save the changes.

      Enabling or Disabling bot calls to an existing bot by the developer

  • For Users (bot subscribers)

    • Click on your profile picture, select "Bots and Tools", and navigate to the bot to which bot calls need to be enabled/disabled.

    • Switch the toggle for bot calls to turn on/off based on the requirements.

       

      Enabling or disabling bot calls for bot users i.e subscribers

     

  • For Admins

    Admins can enable/disable bot calls for the whole organization via the Resource Management in the Cliq Admin Panel.

    • Click on your profile picture and navigate to the Admin Panel under the My Organization section.

    • Hover to the Resource Management option and choose Internal Tools.

    • Under the internal tools section, navigate to the bot to which bot calls must be enabled or disabled.

    • Under Permissions for the selected bot, you can enable, disable, or lock the permissions for users to enable or disable the bot calls for the whole organization.

       

      Bot calls management in Admin Panel


Note :

Admins can disable the call setting (i.e. calls will be restricted) and mandate the call (i.e. even if a user turned off their call notification, they'll still receive it).All calls will override users Do Not Disturb settings and ensure they receive notifications. 
 

Call Handler

The Call Handler lets you control how your bot responds to different call states and events. By editing the Call Handler, you can customize the bot's behavior based on specific call events, defining the bot's responses accordingly. The Call Handler triggers specific call events such as ringing, declining, or answering.

Call Handler navigation in Edit Handlers 
 

Call handler attributes  

The list of attributes that are passed when the call handler is triggered is given below:

Attribute

Value 

Description

operation

String

Expected Values : 
ringing | answered | ended | declined | missed | offline | busy

The operation attribute defines the specific event or action that occurs during a bot call.

dataMap

Details of the call event. which contains the call ID ( unique ID of the triggered call in Java UUID format ), time of execution (in Unix timestamp format) and retry count.

userMapDetails of the user for whom the call was triggered
environmentMapDetails of the data center to which the user belongs.
accessMap

Details of the user's web client.

Example response of data attribute in call handler : 

{"call_id":"5c1cbd04-1396-42ba-aed1-4056a0350148","time":1728036292030,"retry":1}
 
The operation attribute  

The operation attribute defines the specific event or action that occurs during a bot call. It allows you to control the bot's response to each event, helping you customize its behavior based on the call's state. The bot's call handler is triggered by the following operations:

Operation type

Description

ringing

When the call starts ringing.

answered

When the call is answered by the user.

ended

When the call is ended by either party.

declined

When the user declines the call.

missed

When the user misses the call without answering.

offline

When the user is offline and cannot receive the call.

busy

When the user is engaged in another call

How to trigger a bot call? 

To trigger a bot call, you need to use Cliq REST API to send a voice alert to specific users via bot.

POST
https://cliq.zoho.com/api/v2/bots/{BOT_UNIQUE_NAME}/calls


Quota Limit :  The quota limit for this API is 10 calls for 5 minutes.The lock period is 30 minutes.

Authentication : This API can be accessed with the OAuth scope : ZohoCliq.Webhooks.CREATE or zapikey.

Parameters: 
The following parameters are passed when a voice alert is triggered:

Request Body :

Attribute

Value

Description

text*

String 

Max Length : 500

The message to be dictated during the call.

user_ids

Json Array 
Max Size : 1 - 10

List of user ZUIDs or emails.

retry

Integer 
Max Tries : 3

Number of retries if the user misses the call (we call again in 2 mins) 

loop

Integer 
Max Tries : 3

Number of times the message will be dictated during the call.

actions

Json Array 
Max Limit : 5

List of actions to be displayed as buttons during the call. Each action includes a label and a specific action.

* Mandatory inputs

 Action Button Attributes 

Attribute Name

Value

Description

label

String

Maximum number of characters allowed : 20

Display text of the button. 

hint

String 
Maximum number of characters allowed : 100

A tool tip indicating the button's function while hovering over. 

icon

 

Icon to indicate the action button

type*

Allowed values: invoke.function | system.api | open.url

Specify the type of action the button should perform. 

 Trigger Bot Call - Deluge Task

The zoho.cliq.triggerBotCall task can be used to trigger bot calls. This task requires you to provide the bot's unique name, message to be dictated as voice, and connection name.

Syntax: zoho.cliq.triggerBotCall(<bot_unique_name>, <bot_call_payload_map>, <connection_name>);


Example :

alertInfo = Map();
alertInfo.put("retry",1);
alertInfo.put("loop",2);
alertInfo.put("text","Alert! Immediate attention required to restore critical services.");
zoho.cliq.triggerBotCall("serveroutagealert",alertInfo,"oauthforbotcalls")


Usecase

Here’s a practical example of bot calls and call handlers in real life. 

Bot calls can be used to trigger an emergency alert if maintenance engineers are unavailable in the event of server outages or network disruptions. This process ensures that the responsible engineer is notified quickly, acknowledges the critical issue, and immediately resolves it, preventing further damage.

Server Outage Alert bot

  • A developer or user can execute the /notifyseveroutage slash command during downtime.  This command triggers a bot call to notify a randomly selected engineer from a database named Engineer details, which contains details such as the engineer's name and ID.

    Slash command to notify server outage with platform database

 

/notifyseveroutage  - Slash Command

Pre-requisite

Before beginning to script the code below, we must create a connection in Cliq. You can use created connection in Deluge integration tasks and invoke URL scripts to access data from the required service. Create a Zoho Oauth default connection with a unique name - oauthforbotcalls , with the scope - ZohoCliq.Webhooks.CREATE.

response = Map();
chatId = chat.get("id");
alertInfo = Map();
alertInfo.put("retry",1);
alertInfo.put("loop",2);
alertInfo.put("text","Alert! Server outage detected. Immediate attention required to restore critical services.");
actionButtons = List();
acknowLedgetButton = {"label":"Acknowledge","hint":"Confirming your availability for assistance.","icon":"tick","action":{"type":"invoke.function","data":{"name":"serveralertbuttonfunction"}},"key":chatId};
delegateButton = {"label":"Delegate","hint":"Redirect to another available server support engineer immediately.","icon":"headset","action":{"type":"invoke.function","data":{"name":"serveralertbuttonfunction"}}};
escalateButton = {"label":"Escalate","hint":"Escalate the alert to senior engineers or the next-level team","icon":"team","action":{"type":"invoke.function","data":{"name":"serveralertbuttonfunction"}}};
viewReportButton = {"label":"View Incident Report","hint":"View detailed report to understand the nature of the outage.","icon":"preview","action":{"type":"invoke.function","data":{"name":"serveralertbuttonfunction"}},"key":chatId};
triggerBackupButton = {"label":"Trigger Backup","hint":"Trigger backup systems to minimize downtime until the issue is resolved","icon":"add","action":{"type":"invoke.function","data":{"name":"serveralertbuttonfunction"}}};
actionButtons.add(acknowLedgetButton);
actionButtons.add(delegateButton);
actionButtons.add(escalateButton);
actionButtons.add(viewReportButton);
actionButtons.add(triggerBackupButton);
alertInfo.put("actions",actionButtons);
triggerBotCallAPI = invokeurl
[
 url :" https://cliq.zoho.com/api/v2/bots/serveroutagealert/calls"
 type :POST
 parameters:"" + alertInfo
 connection:"oauthforbotcalls"
];
info triggerBotCallAPI;
return response;

Bot calls across all devices

  • When the engineer answers the call, they'll receive an automated explanation of the server outage. Throughout the call, the engineer can use action buttons to:

    • Acknowledge : The maintenance engineer can click this button to confirm that they’ve received the alert and are working on the issue.

    • Delegate : If the engineer is unavailable,they can use this button to assign the task to another engineer.

    • Escalate : If the issue is critical and requires higher-level support,clicking this button can escalate the alert to senior engineers or the next level team.

    • View Incident Report : This button posts a detailed incident report,helping the team understand the nature of the outage.

    • Trigger Backup Systems : If configured,the maintenance team can click this button to automatically trigger backup systems to minimize downtime while resolving the issue.

Action buttons in Bot calls for tailored operations during and after a bot call

  • Use action buttons with clear,intuitive icons tailored to specific use cases and user interfaces. Copy and paste the icon ID into your code to render them. For further information,please refer to the Icons in Cliq.

Icons in Cliq for Developer tools

Actions initiated by clicking a button can be specified within a Cliq button function. Example: `serveralertbuttonfunction` in this case.

serveralertbuttonfunction - Button Function

key = arguments.get("key");
if(target.get("name").equalsIgnoreCase("Acknowledge"))
{
 response = {"text":"The IT team is working on resolving the server outage and restoring service as soon as possible.","card":{"title":"Alert acknowledged","thumbnail":"https://cdn.dribbble.com/users/662779/screenshots/5122311/server.gif","theme":"prompt"}};
 zoho.cliq.postToChat(key,response);
}
else if(target.get("name").equalsIgnoreCase("Escalate"))
{
 response = {"text":"The maintenance engineer is currently unavailable. The server outage case has been reassigned to another available engineer for assistance","card":{"thumbnail":"https://i.imgur.com/Y2Nf4zS.png","theme":"prompt"}};
 zoho.cliq.postToChat(key,response);
}
else if(target.get("name").equalsIgnoreCase("Delegate"))
{
 response = {"text":"The issue has been escalated to senior engineers for immediate attention. A response team is now assigned to handle the critical case.","card":{"thumbnail":"https://i.imgur.com/Y2Nf4zS.png","theme":"prompt"}};
 zoho.cliq.postToChat(key,response);
}
else if(target.get("name").equalsIgnoreCase("View Incident Report"))
{
 response = {"text":"A critical outage was detected on Server 12. This affected core services, including user authentication and data storage access. The system experienced a sudden CPU overload leading to service failure.","card":{"title":"🌐 Incident Report - Server Outage","theme":"modern-inline"},"slides":{{"type":"table","title":"","data":{"headers":{"Incident Report","Details"},"rows":{{"Incident Report":"Incident ID","Details":"#1023"},{"Incident Report":"Date/Time","Details":"October 4 , 2024"}}}},{"type":"text","title":"⚙️ Root Cause","data":"Preliminary investigation indicates a spike in CPU usage due to a misconfigured scheduled task. The task led to an unhandled process overload, consuming excessive resources and resulting in server crash."}}};
 zoho.cliq.postToChat(key,response);
}
else if(target.get("name").equalsIgnoreCase("Trigger Backup Systems"))
{
 // Insert code to trigger backup systems
}
return Map();
  • The call handler manages responses based on the user's actions during a bot call, such as declining or answering. Suppose the engineer is offline or declines the call. In that case, a message will be posted to notify you that the case has been reassigned to another available engineer. You can also configure it to trigger another bot call in case the engineer is unavailable.

     

Call Handler - Server Outage Alert Bot

if(operation.equalsIgnoreCase("answered"))
{
}
else if(operation.equalsIgnoreCase("declined") || operation.equalsIgnoreCase("missed") || operation.equalsIgnoreCase("offline"))
{
 response = {"text":"The maintenance engineer is currently unavailable. The server outage case has been reassigned to another available engineer for assistance","card":{"thumbnail":"https://i.imgur.com/Y2Nf4zS.png","theme":"prompt"}};
 zoho.cliq.postToBot("serveroutagealert",response);
}

 

The above workflow ensures a timely response, helping to avert downtime crises by efficiently utilizing Cliq platform components.

Call Management

To manage your bot calls:

 

  1. Navigate to History > Direct Calls to view your call logs.

  2. Here, you can track, review, and manage all bot calls. You can also access detailed transcripts and call recordings for further analysis.

  3. Use the available action buttons to perform specific tasks related to each call.

  4. After a bot call concludes, you can access the call transcript and use the action buttons to respond accordingly.