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


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



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.

  1. Please ensure you've enabled this function by contacting AIHelp when you're integrating this feature;
  2. Add a listener callback for message event to receive the count of unread messages:


<script src="https://cdn.aihelp.net/webchatv4/aihelp.js"></script>
    (function () {
      let initConfig = {
        appKey: "THIS IS YOUR APP KEY",
        domain: "THIS IS YOUR APP DOMAIN",
        appId: "THIS IS YOUR APP ID",
        entranceId: "THIS IS YOUR ENTRANCE ID"
      window.addEventListener("message", function (event) {
        const { data } = event;
        // data -> { type: 'newChatCount', count: 3 }

The count of unread messages is pulled every 5 minutes within the SDK, 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.


This feature can not be implemented by the URL scheme.

AIHelp implemented this feature by polling under the hood, so in order to make the polling started, you need to ensure that AIHelp is initialized when the app starts.

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: 12/19/2023, 3:25:21 AM