# Unread Message Count

When the customer service replies user's message, user can receive a notification of unread messages, even if the AIHelp page is not currently displayed.

You can implement this function either by every-5-minutes' polling or by third-party push.

TIP

This feature is disabled by default, please contact us before your integration.

# By Polling

WARNING

By default, AIHelp uses a randomly generated deviceId as userId to poll for the count of unread messages.

So, until you sync the correct userId to AIHelp, the unread message count may be inaccurate.

# API

# StartUnreadMessageCountPolling()

Call this method to start a polling job for the count of unread messages. Please ensure that you are calling this method after the initialization is finished.








 


 






private void Awake()
{
    AIHelpSupport.SetOnAIHelpInitializedCallback(OnAIHelpInitializedCallback);
}

public void OnAIHelpInitializedCallback() {  
    // Sync userId info to AIHelp via updateUserInfo API
    AIHelpSupport.UpdateUserInfo(new UserConfig.Builder().setUserId("uid").build());
    
    // Start polling
    AIHelpSupport.StartUnreadMessageCountPolling(OnMessageCountArrivedCallback);
}

public void OnMessageCountArrivedCallback(int msgCount) {  
    // write your code here
}

The count of unread messages is pulled every 5 minutes within the function, the result will be returned to the caller in the following conditions:

  1. When user with ongoing tickets receives a new message, accumulated number of unread messages will be returned;
  2. When users open AIHelp session, a returning with number 0 indicates they have read all messages.

# Definition

# onUnreadMessageCountCallback

  • Type: OnMessageCountArrivedCallback
  • Detail: Required. Callback for unread message count.
Last Updated: 12/19/2023, 3:49:07 AM