.sendEvent()
This API is used to send events to the SDK for several returning callbacks.
Events
OPEN_URL
This event allows you to open a URL when invoked. When using this event followed by a URL, this will open the mentioned URL.
COMPLETE_CHAT_ACTION
This event will complete the chat action as a success or failure, with or without a message.
Syntax (OPEN_URL)
CopiedZohoSalesIQ.sendEvent(eventName: ZohoSalesIQ.Event, url: string);
Example
The below example code opens the URL only when the the URL doesn't starts with "https://zylkerhomes.com".
Reference - EVENT_HANDLE_URL in addEventListener() url click callbacks.
CopiedZohoSalesIQ.addEventListener(ZohoSalesIQ.EVENT_HANDLE_URL, (chat) => {
if (!chat.url.startsWith("https://zylkerhomes.com")) {
ZohoSalesIQ.sendEvent(ZohoSalesIQ.Event.OPEN_URL, chat.url);
} else {
// Handled by self
}
});
Syntax (COMPLETE_CHAT_ACTION)
CopiedZohoSalesIQ.sendEvent(eventName: ZohoSalesIQ.Event, uuid: string, success: boolean, message: string);
Example
Parameters:
- uuid - unique ID for the chat action
- success(Optional) - The default value is true
- message(Optional) - The message to be displayed on the chat action button
Reference - Implementation for Chat actions.
Note: completeChatAction() and completeChatActionWithMessage() were deprecated.
CopiedZohoSalesIQ.addEventListener(ZohoSalesIQ.EVENT_PERFORM_CHATACTION, (actionDetails) => {
ZohoSalesIQ.sendEvent(ZohoSalesIQ.Event.COMPLETE_CHAT_ACTION, actionDetails.uuid, true, "Chat action has been completed successfully");
});