Skip to main content

Helpshift Delegates

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

Note
  • All the public APIs in the SDK should be called after initializing the SDK via HelpshiftSdk.Install() API

  • Events invoked before setting Helpshift.SetHelpshiftEventsListener cannot be received agian.

Helpshift Events Listener/Delegate implementation

You can set IHelpshiftEventsListener implementation by calling the HelpshiftSdk.GetInstance().SetHelpshiftEventsListener() method.

Step 1: Implement the IHelpshiftEventsListener interface

public class HSEventsListener: IHelpshiftEventsListener
{
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
// all events
}

public void AuthenticationFailedForUser(HelpshiftAuthenticationFailureReason reason)
{
//auth failure event
}
}

Step 2: Set this implementation class by calling Helpshift API

using Helpshift;
//...
//...
private HelpshiftSdk help;
//..

void Awake(){
// install call here
help = HelpshiftSdk.GetInstance();
var configMap = new Dictionary<string, object>();
// add some config

help.Install(platformId, domainName, configMap);
}

void Start(){
// set the listener
help.SetHelpshiftEventsListener(new HSEventsListener());
}

Events

Helpshift session started event

This event gets fired when the Helpshift session starts

  • Event name: HelpshiftEvent.SDK_SESSION_STARTED
  • Event data: null
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if(eventName.Equals(HelpshiftEvent.SDK_SESSION_STARTED))
{
Debug.Log("Helpshift session started.");
}
}
//...
}

Helpshift session ended event

This event gets fired when the Helpshift session ends.

  • Event name: HelpshiftEvent.SDK_SESSION_ENDED
  • Event data: null
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if(eventName.Equals(HelpshiftEvent.SDK_SESSION_ENDED))
{
Debug.Log("Helpshift session ended.");
}
}
//...
}

Unread Message Count Event

This event gets fired when you call Helpshift.RequestUnreadMessageCount(shouldFetchFromServer) API to request unread messages count.

  • Event name: HelpshiftEvent.RECEIVED_UNREAD_MESSAGE_COUNT
  • Event data:
    • HelpshiftEvent.DATA_MESSAGE_COUNT
      • Type: int
    • HelpshiftEvent.DATA_MESSAGE_COUNT_FROM_CACHE
      • Type: boolean
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if(eventName.Equals(HelpshiftEvent.RECEIVED_UNREAD_MESSAGE_COUNT))
{
if(eventData.ContainsKey(HelpshiftEvent.DATA_MESSAGE_COUNT)) {
Debug.Log("Unread count: " + eventData[HelpshiftEvent.DATA_MESSAGE_COUNT]);
}
if(eventData.ContainsKey(HelpshiftEvent.DATA_MESSAGE_COUNT_FROM_CACHE)) {
Debug.Log("Is Unread count from cache: " + eventData[HelpshiftEvent.DATA_MESSAGE_COUNT_FROM_CACHE]);
}
}
}
//...
}

Conversation Status Event

This event contains information about the current ongoing conversation.

  • Event name: HelpshiftEvent.CONVERSATION_STATUS
  • Event data:
    • HelpshiftEvent.DATA_LATEST_ISSUE_ID
      • Type: string
    • HelpshiftEvent.DATA_LATEST_ISSUE_PUBLISH_ID
      • Type: string
    • HelpshiftEvent.DATA_IS_ISSUE_OPEN
      • Type: boolean
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if(eventName.Equals(HelpshiftEvent.CONVERSATION_STATUS))
{
if(eventData.ContainsKey(HelpshiftEvent.DATA_LATEST_ISSUE_ID)) {
Debug.Log("Issue ID : " + eventData[HelpshiftEvent.DATA_LATEST_ISSUE_ID]);
}
if(eventData.ContainsKey(HelpshiftEvent.DATA_LATEST_ISSUE_PUBLISH_ID)) {
Debug.Log("Publish ID : " + eventData[HelpshiftEvent.DATA_LATEST_ISSUE_PUBLISH_ID]);
}
if(eventData.ContainsKey(HelpshiftEvent.DATA_IS_ISSUE_OPEN)) {
Debug.Log("Is issue open : " + eventData[HelpshiftEvent.DATA_IS_ISSUE_OPEN]);
}
}
}
//...
}

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
      • Type: boolean
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if(eventName.Equals(HelpshiftEvent.WIDGET_TOGGLE))
{
if(eventData.ContainsKey(HelpshiftEvent.DATA_SDK_VISIBLE)) {
Debug.Log("Is SDK Visible " + eventData[HelpshiftEvent.DATA_SDK_VISIBLE]);
}
}
}
//...
}

User Click On Action Event

This event is triggered when the user clicks on the link or call action of an action card message.

  • Event Name : HelpshiftEvent.ACTION_CLICKED
  • Event data:
    • HelpshiftEvent.DATA_ACTION
    • HelpshiftEvent.DATA_ACTION_TYPE
    • HelpshiftEvent.DATA_ACTION_TYPE_CALL
    • HelpshiftEvent.DATA_ACTION_TYPE_LINK
Key (Constant)Key (Raw)Type
HelpshiftEvent.ACTION_CLICKEDuserClickOnActionString
HelpshiftEvent.DATA_ACTIONactionTypeString
HelpshiftEvent.DATA_ACTION_TYPEactionDataString
HelpshiftEvent.DATA_ACTION_TYPE_CALLcallString
HelpshiftEvent.DATA_ACTION_TYPE_LINKlinkString
Note

The key constants are available from SDK X 10.3.0 onwards. For older SDK X versions, please use the raw keys instead.

public class HSEventsListener : IHelpshiftEventsListener
{
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
if (eventName.Equals(HelpshiftEvent.ACTION_CLICKED)) {
// With Key Constants
String actionType = (String) eventData[HelpshiftEvent.DATA_ACTION_TYPE];
String actionData = (String) eventData[HelpshiftEvent.DATA_ACTION];

-------------------- OR --------------------

// With Key Raw Values
String actionType = (String) eventData["actionType"];
String actionData = (String) eventData["actionData"];

// `Utils.isEmpty` is null and empty Check
if (Utils.isEmpty(actionType) || Utils.isEmpty(actionData)) {
Debug.Log("Event Received for " + eventName + " with actionType or action Data as empty");
return;
}

Debug.Log("Event Received for " + eventName + " action type " + actionType + " actionData " + actionData);
}
}

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
      • Type: string
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if (eventName.Equals(HelpshiftEvent.CONVERSATION_START))
{
if(eventData.ContainsKey(HelpshiftEvent.DATA_MESSAGE)) {
Debug.Log("Conversation started with text: " + eventData[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
      • Values: HelpshiftEvent.DATA_MESSAGE_TYPE_ATTACHMENT , HelpshiftEvent.DATA_MESSAGE_TYPE_TEXT
    • HelpshiftEvent.DATA_MESSAGE_BODY
      • Type: string
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if (eventName.Equals(HelpshiftEvent.MESSAGE_ADD))
{
if(eventData.ContainsKey(HelpshiftEvent.DATA_MESSAGE_BODY)) {
Debug.Log("New message added with body: " + eventData[HelpshiftEvent.DATA_MESSAGE_BODY]);
}
if(eventData.ContainsKey(HelpshiftEvent.DATA_MESSAGE_TYPE)) {
Debug.Log("New message added with type: " + eventData[HelpshiftEvent.DATA_MESSAGE_TYPE]);
}
}
}
//...
}

Agent Message Received Event

This event is triggered when the user receives any message from an agent in a conversation. This delegate is not triggered for bot messages or messages sent via automations.

  • Event name : HelpshiftEvent.AGENT_MESSAGE_RECEIVED

  • Event data:

    KeyTypeValue
    HelpshiftEvent.DATA_PUBLISH_IDStringConversation ID of the ongoing issue
    HelpshiftEvent.DATA_MESSAGE_TYPEStringMessage Type of the message
    HelpshiftEvent.DATA_MESSAGE_BODYStringThe actual message sent by the agent or empty
    HelpshiftEvent.DATA_CREATED_TIMELongUnix epoch timestamp in ms
    HelpshiftEvent.DATA_ATTACHMENTSDictionary<String, Object>>Attachments, if they are present
    HelpshiftEvent.DATA_URLStringURL of the attachment
    HelpshiftEvent.DATA_CONTENT_TYPEStringMIME type of the attachment
    HelpshiftEvent.DATA_FILE_NAMEStringFile name of the attachment
    HelpshiftEvent.DATA_SIZEIntegerSize of the attachment in bytes
Note
  • This delegate is available from 10.3.0 and above versions
  • The attachments key is only present if the agent has sent attachments.
  • Since attachments sent by agents may not have the necessary MIME type or name, it is possible that HelpshiftEvent.DATA_CONTENT_TYPE is absent from the payload. For such cases, file type can be inferred from extension from file name
  • HelpshiftEvent.DATA_MESSAGE_TYPE has following types :
    • HelpshiftEvent.DATA_MESSAGE_TYPE_APP_REVIEW_REQUEST
    • HelpshiftEvent.DATA_MESSAGE_TYPE_SCREENSHOT_REQUEST
    • HelpshiftEvent.DATA_MESSAGE_TYPE_TEXT
public class HSEventsListener : IHelpshiftEventsListener
{
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
if (eventName.Equals(HelpshiftEvent.AGENT_MESSAGE_RECEIVED)) {
String publishId = (String) eventData[HelpshiftEvent.DATA_PUBLISH_ID];
String type = (String) eventData[HelpshiftEvent.DATA_MESSAGE_TYPE];
String body = (String) eventData[HelpshiftEvent.DATA_MESSAGE_BODY];
long createdTs = (long) eventData[HelpshiftEvent.DATA_CREATED_TIME];

// Utils.isEmpty() is null and empty Check
if (Utils.isEmpty(publishId) && Utils.isEmpty(type) && Utils.isEmpty(body) && createdTs == 0) {
Debug.Log(TAG, "Received no data");
return;
}

Debug.Log("publishId " + publishId + " type " + type + " body " + body + " createdTs " + createdTs);
List<object> attachments = (List<object>)eventData[HelpshiftEvent.DATA_ATTACHMENTS];

if (Utils.isEmpty(attachments)) {
Debug.Log("No attachments received in message");
} else {

for (int i = 0; i < attachments.size(); i++) {
Dictionary<String, object> attachment = (Dictionary<String, object>) attachments.get(i);

String url = (String) attachment[HelpshiftEvent.DATA_URL];
String contentType = (String) attachment[HelpshiftEvent.DATA_CONTENT_TYPE];
String fileName = (String) attachment[HelpshiftEvent.DATA_FILE_NAME];
int size = (int) attachment[HelpshiftEvent.DATA_SIZE];

if (Utils.isEmpty(url) && Utils.isEmpty(fileName) && size == 0) {
Debug.Log("Received no data for attachment " + (i + 1));
continue;
}

if (Utils.isEmpty(url) || Utils.isEmpty(fileName) || size == null) {
Debug.Log("Received incomplete data for attachment " + (i + 1));
continue;
}

Debug.Log("Attachment No. : " + (i + 1) + ", url: " + url + ", contentType: " + contentType + ", fileName: " + fileName + ", size: " + size);
}
}
}
}

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
      • Type: int
    • HelpshiftEvent.DATA_ADDITIONAL_FEEDBACK
      • Type: string
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if (eventName.Equals(HelpshiftEvent.CSAT_SUBMIT))
{
if(eventData.ContainsKey(HelpshiftEvent.DATA_CSAT_RATING)) {
Debug.Log("CSAT submitted with rating: " + eventData[HelpshiftEvent.DATA_CSAT_RATING]);
}
if(eventData.ContainsKey(HelpshiftEvent.DATA_ADDITIONAL_FEEDBACK)) {
Debug.Log("CSAT submitted with rating: " + eventData[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
  • Event Data: null
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if (eventName.Equals(HelpshiftEvent.CONVERSATION_END))
{
Debug.Log("Conversation Ended");
}
}
//...
}

Conversation Rejected Event

This event is triggered when an agent rejects the conversation.

  • Event name: HelpshiftEvent.CONVERSATION_REJECTED
  • Event data: null
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if (eventName.Equals(HelpshiftEvent.CONVERSATION_REJECTED))
{
Debug.Log("Conversation Rejected");
}
}
//...
}

Conversation Resolved Event

This event is triggered when an agent resolves the conversation.

  • Event name: HelpshiftEvent.CONVERSATION_RESOLVED
  • Event data: null
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if (eventName.Equals(HelpshiftEvent.CONVERSATION_RESOLVED))
{
Debug.Log("Conversation Resolved");
}
}
//...
}

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
  • Event data: null
public class HSEventsListener : IHelpshiftEventsListener
{
// ...
public void HandleHelpshiftEvent(string eventName, Dictionary<string, object> eventData)
{
if (eventName.Equals(HelpshiftEvent.CONVERSATION_REOPENED))
{
Debug.Log("Conversation Reopened");
}
}
//...
}

User Authentication Failed Event

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

Reason type :

  • HelpshiftAuthenticationFailureReason.INVALID_AUTH_TOKEN
  • HelpshiftAuthenticationFailureReason.AUTH_TOKEN_NOT_PROVIDED
  • HelpshiftAuthenticationFailureReason.UNKNOWN
public class HSEventsListener: IHelpshiftEventsListener
{
// HandleHelpshiftEvent

public void AuthenticationFailedForUser(HelpshiftAuthenticationFailureReason reason)
{
Debug.Log("Authentication Failed for reason " + reason.ToString());
}
}