Bot Failure Handler

This handler gets invoked when the actions returned in the other handlers fail to execute. Eg, when the message handler returns an action to forward the chat to an operator and if the operator is not available, the failure handler gets invoked.

InputsTypeDescription
visitorMapDetails of the website visitor
causeMapThe cause of the failure (code, desc)
failed_responseMapThe previous response for the object due to which the action had failed.
requestMapDetails of the request

Error Response Format:

In case of failure, the input params for failure handler will have the param map "cause" which contains information about the failure. It contains 2 keys namely the "code" (unique error code) and the "desc" (description of the error)

Action: Forward

1. Forward chat to the operator during offline hours:

This error occurs when bot tries to forward chat after business hours.

code: 1001 ,
desc: "offline_hours"
2. Operator unavailable during business hours:

This error occurs when the bot tries to forward the chat to the operators during business hours but no operator is available to take up the chat.

code: 1002,
desc: "operators_not_available"
3. Operator email address is invalid or inactive in the portal:

This error occurs when the bot tries to forward the chat and the given operator email address is invalid or not active in the portal.

code: 1003 ,
desc: "invalid_operators"

Action: Reply

4. Character limit exceeded in reply :

This error occurs when the chat reply length exceeds the character limit that is allowed, for example: If the character limit for a reply is 250 and the reply consists of 256 characters.

code: 1005 ,
desc: more_than_max_length
5. Connection timed out:

This error occurs when the execution takes more than 15 seconds and Zobot execution stops. You can handle this case inside the Failure handler.

code: 1007 ,
desc: "execution_failure"

Failure Handler in Zoho SalesIQ - Bot

To embed the failure handler script:

  • Navigate to Settings > Bot > Zobot, click Add.
  • Enter the name, choose the platform - SalesIQ Scripts and then choose the brand. 
  • The Deluge code builder will appear.
  • Then, choose the Failure Handler in the drop-down.
  • And then draft the script in the Failure handler section, click Save and Publish.

Note: The Failure handler code will be disabled by default but if you wish to set up failure responses you can enable it.

 

Sample Code:

Copiedresponse = Map();
code = cause.get("code");
if(code == 1007)
{
    response.put("action","reply");
	response.put("replies",{"May I take sometime to response","Can you please try later"});
}
if(failed_response.get("action").equalsIgnoreCase("forward"))
{
	code = cause.get("code").toNumber();
	if(code == 1002)
	{
		// operators_not_available
		response.put("action","reply");
		response.put("replies",{"All our agents are busy at the moment","Leave us a message and we will get back to you"});
	}
}
return response;
In this example, we have used a travel website called Zylker travels. And the bot acts as a travel assistant and guides the visitors visiting the website. Here, the failure handler will be invoked once the bot is configured to forward the chat to the operator, but currently, no operator is available to take the chat. So, a response stating the failure of the action is sent to the visitor.