# 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.








 


 






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:25:21 AM