Chat Actions

Chat Actions allows you to define and perform custom actions within your app from bot cards in chat. To receive event callbacks, an event listener is to be added using the addEventListner API to be notified when an action is to be executed. 

Usage:
In the below example, we register a new action using the registerChatAction API and add a new event listener to receive events when a new action is to be performed. We use the sendEvent() API to set the completion status for the action once it is triggered. The UI will be in a loading state until the completeChatAction API is called.

Note:
The action button will have a loading state until the sendEvent() API is called.

//Register an action
ZohoSalesIQ.registerChatAction("bookTicketAction");

//Add event listener
ZohoSalesIQ.addEventListener(ZohoSalesIQ.EVENT_PERFORM_CHATACTION, (actionDetails) => {
  // your code goes here
  if (actionDetails.clientActionName == "bookTicketAction") {
    if (userLoggedIn) {
      bookTicket(); // your custom function here.
      ZohoSalesIQ.sendEvent(ZohoSalesIQ.Event.COMPLETE_CHAT_ACTION, actionDetails.uuid, true, "Your tickets are booked!");
    } else {
      ZohoSalesIQ.sendEvent(ZohoSalesIQ.Event.COMPLETE_CHAT_ACTION, actionDetails.uuid, false, "Please login to continue");
    }
  } else {
    // By default, the chat action will get timed out after 30 seconds if the chat action is in pending state. 
    // Refer - https://www.zoho.com/salesiq/help/developer-section/react-native-sdk-setChatActionTimeout.html
  }
});

The details of the triggered action are received as an object, and it contains the following information:

keyvalue
nameValue corresponding to the "name" key used in bot script.
clientActionNameName of the action with which it was registered.
elementIDElement ID of card.
labelLabel value of the button.
uuidUnique ID for the action.