# Unread Message

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 proactively fetching or by third-party push.

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 / FetchUnreadTaskCount

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

FAIHelpForUEModule::Get().GetAIHelp()->FetchUnreadMessageCount();
FAIHelpForUEModule::Get().GetAIHelp()->FetchUnreadTaskCount();

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 MESSAGE_ARRIVAL and UNREAD_TASK_COUNT events to receive notifications about unread message changes for the current user.

FAIHelpForUEModule::Get().GetAIHelp()->RegisterAsyncEventListener(EventType::MESSAGE_ARRIVAL,
    [](const char *jsonData, Acknowledge ignored) {
        // `jsonData`: { "msgCount": 1 }
    }
);
FAIHelpForUEModule::Get().GetAIHelp()->RegisterAsyncEventListener(EventType::UNREAD_TASK_COUNT,
    [](const char *jsonData, Acknowledge ignored) {
        // `jsonData`: { "taskCount": 1 }
    }
);

# By Third-Party Push

Please refer to Android or iOS documentation for more information.

Last Updated: 7/25/2024, 4:33:52 AM