Helpshift Delegates

The Helpshift SDK provides delegate callbacks to help app developers track a user's activities within the help section.

Helpshift Events Listener/Delegate implementation

You can set HelpshiftEventsListener by calling the Helpshift.setHelpshiftEventsListener() method.

For example:

 Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
  @Override
  public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
    switch(eventName){
      case HelpshiftEvent.CONVERSATION_START:
        //your code here
      break;
      // and so on...
      //the list of events is given below
    }
  }

  @Override
  public void onUserAuthenticationFailure(String reason) {
    // your code here
  }
});

Class Implementation: You have to define a class which implements HelpshiftEventsListener
and then set this event listener instance using Helpshift.setHelpshiftEventsListener() method.

class MyEventListener implements HelpshiftEventsListener{

  @Override
  public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
    switch(eventName){
      case HelpshiftEvent.CONVERSATION_START:
        //your code here
      break;
      // and so on...
      //the list of events is given below
    }
  }

  @Override
  public void onUserAuthenticationFailure(String reason) {
    // your code here
  }
}

MyEventListener listener = new MyEventListener();
Helpshift.setHelpshiftEventsListener(listener);

Events

Conversation Status Event

This event contains information about the current ongoing conversation.

  • Event name: HelpshiftEvent.CONVERSATION_STATUS
  • Event data:
  • HelpshiftEvent.DATA_LATEST_ISSUE_ID
  • HelpshiftEvent.DATA_LATEST_ISSUE_PUBLISH_ID
  • HelpshiftEvent.DATA_IS_ISSUE_OPEN
    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case HelpshiftEvent.CONVERSATION_STATUS:
            Log.d(TAG, data.get(HelpshiftEvent.DATA_LATEST_ISSUE_PUBLISH_ID));
        }
      }
      // ...

Widget Toggle Event

This event is triggered when the user opens or exits the chat screen. This event is triggered with a boolean value of "visible" key. For your reference, see the below example:

  • Event name: HelpshiftEvent.WIDGET_TOGGLE
  • Event data: HelpshiftEvent.DATA_SDK_VISIBLE
    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case HelpshiftEvent.WIDGET_TOGGLE:
            Log.d(TAG, data.get(HelpshiftEvent.DATA_SDK_VISIBLE));
        }
      }
      // ...

Conversation Start Event

This event triggers when the user sends the first message in a conversation. The event data object has a key, message, which includes the message string the end-user sent to start the conversation. For your reference, see the below example.

  • Event name: HelpshiftEvent.CONVERSATION_START
  • Event data: HelpshiftEvent.DATA_MESSAGE
    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case HelpshiftEvent.CONVERSATION_START:
            Log.d(TAG, data.get(HelpshiftEvent.DATA_MESSAGE));
        }
      }
    // ...

Message Add Event

This event is triggered when the user adds a message in a conversation. It might be a text message, response via bot input, or an attachment. The event data object has type and body keys, which indicates the type and body of the message added by the user. For your reference, see the below example.

  • Event name: HelpshiftEvent.MESSAGE_ADD
  • Event data:
  • HelpshiftEvent.DATA_MESSAGE_TYPE
  • HelpshiftEvent.DATA_MESSAGE_BODY
  • HelpshiftEvent.DATA_MESSAGE_TYPE_ATTACHMENT
  • HelpshiftEvent.DATA_MESSAGE_TYPE_TEXT
    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case HelpshiftEvent.MESSAGE_ADD:
            Log.d(TAG, data.get(HelpshiftEvent.DATA_MESSAGE_BODY));

            if(data.get(HelpshiftEvent.DATA_MESSAGE_TYPE).equals(HelpshiftEvent.DATA_MESSAGE_TYPE_ATTACHMENT)){
              Log.d(TAG, "user sent an attachment");
            }
        }
      }
    // ...

CSAT Submit Event

This event is triggered when the user submits a CSAT rating after the conversation ends. The event data object has rating and additionalFeedback keys, which indicates the (star) rating and the additional comments provided by the user with the CSAT form. For your reference, see the below example.

  • Event name: HelpshiftEvent.CSAT_SUBMIT
  • Event data:
  • HelpshiftEvent.DATA_CSAT_RATING
  • HelpshiftEvent.DATA_ADDITIONAL_FEEDBACK
    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case "HelpshiftEvent.CSAT_SUBMIT":
            Log.d(TAG, data.get(HelpshiftEvent.DATA_CSAT_RATING));

            Log.d(TAG, data.get(HelpshiftEvent.DATA_ADDITIONAL_FEEDBACK));

        }
      }

Conversation End Event

This event is triggered when the conversation ends (resolved or rejected) and it cannot be reopened.

  • Event name: HelpshiftEvent.CONVERSATION_END
    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case "HelpshiftEvent.CONVERSATION_END":
            //data will be empty
        }
      }
    // ...

Conversation Rejected Event

This event is triggered when an agent rejects the conversation.

  • Event name: HelpshiftEvent.CONVERSATION_REJECTED
    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case "HelpshiftEvent.CONVERSATION_REJECTED":
            //data will be empty
        }
      }
    // ...

Conversation Resolved Event

This event is triggered when an agent resolves the conversation.

  • Event name: HelpshiftEvent.CONVERSATION_RESOLVED
    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case "HelpshiftEvent.CONVERSATION_RESOLVED":
            //data will be empty
        }
      }
    // ...

Conversation Reopened Event

When resolution question is enabled, the users are asked if they're satisfied with the resolution. If the user rejects it and sends a new message, then the conversation is reopened and the Conversation Reopened event is triggered.

  • Event name: HelpshiftEvent.CONVERSATION_REOPENED
    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case "HelpshiftEvent.CONVERSATION_REOPENED":
            //data will be empty
        }
      }
    // ...

User Authentication Failed Event

If you have user authentication feature enabled on the Dashboard and if you pass an invalid token in the Helpshift.login(userDataMap), then you will receive this event with reason string. Check here for more info

Reason type :

  • HelpshiftAuthenticationFailureReason.REASON_INVALID_AUTH_TOKEN
  • HelpshiftAuthenticationFailureReason.REASON_AUTH_TOKEN_NOT_PROVIDED
  • HelpshiftAuthenticationFailureReason.UNKNOWN
     // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
       @Override
      public void onUserAuthenticationFailure(HelpshiftAuthenticationFailureReason reason) {
        Log.e(TAG, reason);
      }
    }
    // ...

User Authentication Failed Event

If you have user authentication feature enabled on the Dashboard and if you pass an invalid token in the Helpshift.login(userDataMap), then you will receive this event with reason string. Check here for more info

Reason type :

  • HelpshiftAuthenticationFailureReason.REASON_INVALID_AUTH_TOKEN
  • HelpshiftAuthenticationFailureReason.REASON_AUTH_TOKEN_NOT_PROVIDED
  • HelpshiftAuthenticationFailureReason.UNKNOWN
     // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
       @Override
      public void onUserAuthenticationFailure(HelpshiftAuthenticationFailureReason reason) {
        Log.e(TAG, reason);
      }
    }
    // ...

Helpshift session delegates

Helpshift Session Started

If you want to keep track of when helpshift session starts in your app, you can implement this delegate callback. The delegate will get fired every time the Helpshift session starts.

  • Event Name: HelpshiftEvent.SDK_SESSION_STARTED
    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case HelpshiftEvent.SDK_SESSION_STARTED:
            //sdk session started
        }
      }
    // ...    

Helpshift Session Ended

If you want to keep track of when helpshift session ends in your app, you can implement this delegate callback. The delegate will get fired every time the Helpshift session ends.

  • Event Name: HelpshiftEvent.SDK_SESSION_ENDED
    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case HelpshiftEvent.SDK_SESSION_ENDED:
            //sdk session ended
        }
      }
    // ...    

Unread Message Count

If you want a count of all new messages received in an existing conversation, you can call this API requestUnreadMessageCount(final boolean shouldFetchFromServer). The count of the number of messages will be conveyed to your app via this event. You can also use this event to keep your badge counts updated.

  • Event Name: HelpshiftEvent.RECEIVED_UNREAD_MESSAGE_COUNT
  • Event Data: HelpshiftEvent.DATA_MESSAGE_COUNT HelpshiftEvent.DATA_MESSAGE_COUNT_FROM_CACHE
    // call requestUnreadMessageCount() api first

    Helpshift.requestUnreadMessageCount(true);

    // ...
    Helpshift.setHelpshiftEventsListener(new HelpshiftEventsListener() {
      @Override
      public void onEventOccurred(@NonNull String eventName, Map<String, Object> data) {
        switch(eventName){
          case HelpshiftEvent.RECEIVED_UNREAD_MESSAGE_COUNT:
            int count = (int) data.get(HelpshiftEvent.DATA_MESSAGE_COUNT);
            boolean fromCache = (boolean) data.get(HelpshiftEvent.DATA_MESSAGE_COUNT_FROM_CACHE);
            Log.d(TAG, "Message Count : " + count + ", From Cache: " + fromCache);
        }
      }
    // ...