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

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.

# By Fetching

# API

# fetchUnreadMessageCount

Calling this method allows you to actively retrieve the unread message count for the current user.

AIHelpSupport.fetchUnreadMessageCount();

You can call these APIs at any time to query the unread message count for the current user, but please note:

  1. This method has a frequency limit:

Repeated calls within the limit period will return the result of the previous query. During development, you can check the logs to see the time until the next valid call.

  1. This method will return 0 in the following situations to notify the caller that the current user has no unread messages:
  • When the user has no ongoing complaints or tasks.
  • After the user has opened the customer service conversation window, or checked all unread tasks.

# Event

Subscribe to the messageArrival events to receive notifications about unread message changes for the current user.

AIHelpSupport.registerAsyncEventListener("messageArrival", function(jsonData) {
  // `jsonData`: { "msgCount": 1 }
});

# URL

This feature can not be implemented by the URL scheme.

The URL scheme opens the page by opening a link. However, none of AIHelp's code can get executed before the link is clicked by the user, let alone the every-5-minutes polling.

So, this feature can not be implemented through the URL scheme.

Last Updated: 7/26/2024, 6:29:04 AM