ZohoSalesIQ.Chat.startWithTrigger()
The ZohoSalesIQ.Chat.startWithTrigger() API allows initiating a chatbot-triggered chat or using the specified chat ID.
Note:
- This API is supported from version 8.2.0-beta01.
- For this API to work, ensure the bot trigger is set (Settings > Zobot > Select the bot > Bot Configuration > When the bot should initiate the chat and enable > Performs a custom action) or trigger is set (Settings > Triggers > Initiate the trigger when the visitor > Performs a custom action).
- When the user matches the trigger criteria, this API immediately opens the chat window, bypassing any configured delay or trigger time.
- If you want to use the "Invoke JS API" trigger type based on a custom action or specific timing, consider using the performCustomAction() API instead.
Parameters
- customActionName (Optional) - The name of the custom action that should be executed during chat start.
- customChatId (Optional) - Unique ID of the conversation to trigger a chat.
- departmentName (Optional) - Department to which the chat should be routed.
- callback (Optional) - The callback to get the result.
Syntax
Copiedvoid startWithTrigger(@NonNull String customActionName, String customChatId, String departmentName, ZohoSalesIQResultCallback<VisitorChat> resultCallback)
//The syntax (supported on the v8.0.0) is deprecated
ZohoSalesIQ.Chat.startWithTrigger(String customChatId, String departmentName, ZohoSalesIQResultCallback<VisitorChat> callback)
Example
CopiedZohoSalesIQ.Chat.startWithTrigger("custom_action_name", "custom_chat_id", "department_name", result -> {
if (result.isSuccess()) {
// Handle success
} else if (result.getError() != null) {
switch (result.getError().getCode()) {
case 701:
case 702: {
ZohoSalesIQ.Chat.open("custom_chat_id");
}
default: {
// Handle other failures
}
}
}
});
CopiedZohoSalesIQ.Chat.startWithTrigger("custom_action_name", "custom_chat_id", "department_id") { result ->
if (result.isSuccess) {
// Handle success
} else if (result.error != null) {
when (result.error!!.code) {
701, 702 -> {
ZohoSalesIQ.Chat.open("custom_chat_id")
else -> {
// Handle other failures
}
}
}
}