Skip to product menu
Skip to main content

KnowledgeBase.addListener()

The ZohoSalesIQ.KnowledgeBase.addListener API provides resource event callbacks, allowing you to monitor various visitor actions related to the resources. These actions includes opening, closing, liking and disliking a resource.

Events Invoked when
RESOURCE_OPENEDa resource is opened
RESOURCE_CLOSEDa resource is closed
RESOURCE_LIKEDa resource is liked
RESOURCE_DISLIKEDa resource is disliked

Example

Copied    const { Event } = ZohoSalesIQ.KnowledgeBase;
    ZohoSalesIQ.KnowledgeBase.addListener(({event, body}) => {
      switch (event) {
        case Event.RESOURCE_OPENED:
          console.log(body.resource, 'EVENT_RESOURCE_OPENED');
          console.log(body.type, 'EVENT_RESOURCE_OPENED');
          break;

        case Event.RESOURCE_CLOSED:
          console.log(body.resource, 'EVENT_RESOURCE_CLOSED');
          console.log(body.type, 'EVENT_RESOURCE_CLOSED');
          break;
        case Event.RESOURCE_LIKED:
          console.log(body.resource, 'EVENT_RESOURCE_LIKED');
          console.log(body.type, 'EVENT_RESOURCE_LIKED');
          break;
        case Event.RESOURCE_DISLIKED:
          console.log(body.resource, 'EVENT_RESOURCE_DISLIKED');
          console.log(body.type, 'EVENT_RESOURCE_DISLIKED');
          break;
        default:
          break;
      }
    });