Chat

Add Real-Time Features to your Customer Care Chat

0 MIN READ • Darryn Campbell on Jul 10, 2025
Add Real-Time Features to Your Customer Care Chat

Customers expect instant access to support across multiple channels, whether it's through a website chat widget, a chat window in your mobile app, or messaging platforms like WhatsApp and SMS. PubNub is a real-time messaging platform trusted by global enterprises to build efficient, high-performance customer support apps.

Whether starting from scratch or enhancing your existing CRM or support tool, the PubNub Chat SDK provides robust cross-platform support, from web to iOS and Android. It allows you to build a secure, scalable customer care experience that delivers all your required chat features.

In this technical blog, I’ll explain how to build a full-featured customer support chat using PubNub’s Chat SDK, enhanced by AI capabilities including out-of-the-box moderation.

Chat app

Adding Chat Features

Some chat features are table stakes for any customer support application between support agents and customers. This section will explain how to deliver those essential features at scale with the PubNub Chat SDK.

Cross-Platform Support

Although examples are given in JavaScript, the SDK also supports Kotlin for Android and Swift for iOS, with a very similar API surface.

Real-Time Messaging

Real-time chat messages can be sent and received with very low latency.

Message Send messages with the sendText() API, which operates on the Channel object. Think of a Channel as the private communication mechanism between the support agent and the customer; you would have one Channel per support case.

Listen for new messages by connecting to the channel, and receive a callback whenever a new message is received:

Typing Indicators

Typing indicators help users see when someone is actively composing a message. The Chat SDK handles all the timing logic for you; you just need to tell the SDK whenever a keystroke happens in the message input.

Typing Indicator

Send and receive typing indicators as follows:

File Attachments

Easily share binary content such as images or documents via message metadata. Files are stored in PubNub File Storage for archiving and immediate retrieval.

Send files by either specifying the files parameter in the call to sendText(), or by adding the file to the more capable messageDraft object

File Attachments Files information associated with a message is contained within the received Message object, as follows:

Timestamps

Each message sent through the Chat SDK includes a unique timestamp, a serial identifier that can be used to guarantee message order.

Read Receipts

The PubNub Chat SDK supports being notified when the recipient reads your message. For group chats with multiple recipients, you will be told who has read the message, and who still has to read it.

Read Receipts If you wanted to mark a message as read whenever it is received on the active channel, the code would look as follows.

Note that the setLastReadMessageTimetoken API is invoked on a Membership object:

In practice, you have complete flexibility when deciding when a message is read, e.g. you might only mark it read when the recipient scrolls the message into view.

To receive notification that the message has been read use the streamReadReceipts() API:

Unread Message Count

Unread messages are designed to show how many messages have been missed whilst the user was offline.

Unread Message Count

The PubNub Chat SDK ties together the implementation of read receipts with unread messages. Provided you have invoked currentMembership?.setLastReadMessageTimetoken(message.timetoken), as described above when discussing read receipts, the SDK will consider the message as read and it will not appear in the unread count.

The API for retrieving unread messages is very flexible, including retrieving the last read message on a specific channel, or querying the count of messages across all channels, and full details can be found in the documentation for unread messages.

For example, when initially loading your application you can determine the count of unread messages for all channels as follows:

See the Chat SDK web demo for an example implementation of unread message counts.

AI-Powered Chat Features

PubNub offers many AI-powered features that can enhance your customer interactions.

AI Moderation

PubNub’s Auto Moderation feature enables real-time monitoring of chat content for toxicity, profanity, spam, and other unwanted behavior. We have integrated AI models and natural language processing directly into the message flow, enabling businesses to enforce community guidelines and protect their support teams without introducing manual review delays.

AI Moderation Auto Moderation supports profanity word masking and spam detection; messages can be blocked entirely, flagged as suspicious, or masked once detected.

Use AI Moderation in combination with PubNub messaging to:

  • Protect support agents by automatically detecting and suppressing harmful or offensive messages before they are seen.

  • Automate policy enforcement, ensuring company communication policies are applied consistently and objectively, even across thousands of concurrent chat conversations.

  • Ensure chatbot safety by verifying that messages originating from your AI chatbots stay appropriate and on-brand for your business.

Alternatively, you can define a custom AI pipeline including external providers for auto moderation using PubNub Functions, giving you complete flexibility over how messages are moderated.

Learn more about PubNub AI-powered auto moderation from our docs.

AI Powered Chatbots

Today, chatbots (or chat agents / live chat widgets) are ubiquitous for customer care apps, but most implementations rely on hardcoded decision trees and specific domain knowledge. Simultaneously, customer expectations are growing as the public becomes used to interacting daily with chatbots such as ChatGPT, Gemini, or CoPilot. These same LLMs make creating an AI chatbot powered by their platforms easier than ever by exposing APIs, such as the OpenAI API.

Why create an AI-powered chatbot?

One obvious use for chatbots is for self-service support during hours when live agents are unavailable; chatbots can take over, greet the user, and answer frequently asked questions (FAQs). Chatbots also play a significant role in pre-agent triage, initiating the conversation, gathering all required information, and streamlining the agent workflow.

Beyond the customer-facing chatbot, some solutions are starting to include chatbots designed solely to assist the support agent. The chatbot can pull user information such as purchase history, CRM records, support ticket status, ongoing conversation history with the Customer, and knowledge base articles to suggest how the issue could be resolved in real-time. This is a powerful use case, but it requires the conversation history as context to make any suggestions.

How to build an AI-powered chatbot with PubNub

It is trivial to develop an AI-powered chatbot using a combination of PubNub Functions and an LLM API. Since PubNub functions allow you to run serverless code at scale whenever a message is sent over the chat, you can use this to call out to the desired LLM API.

I previously wrote a guide to building a chatbot with PubNub and OpenAI, so please refer to that article for the implementation details.

Your architecture will be as follows:

PubNub Chatbot architecture You can provide as much context of the conversation to the LLM API as you desire. However, at minimum you should provide the ongoing conversation history between the agent and customer, retrieved from PubNub. You could also include contextual information such as user location, ticket status or loyalty tier, but it depends on the kind of questions you need to answer.

The following code, taken from the previously mentioned guide will interface with the OpenAI API from a PubNub function:

AI Conversation Summaries

When customer support agents rotate shifts or hand off cases, catching up on previous chat messages can result in delays and inconsistent responses. Using AI to summarize conversations ensures that the next agent has a clear, concise overview of the conversation so far, drastically reducing onboarding time and improving response quality.

With PubNub, you can retrieve the message history from any conversation and pass that history to an AI model to generate a digest summary.

AI Message Summary By handling this within a PubNub function, you ensure your solution can scale, and you are not making direct calls to the LLM API from your clients.

AI Message Summary Architecture This approach is similar to how you could create an LLM-powered chatbot, described previously, but the message summary would require less context to complete the request (only needing the history of the conversation, available from PubNub).

Within your PubNub ‘after-publish’ Function, which executes asynchronously after each message has been sent, you should retrieve the conversation history using the PubNub Module as follows:

Scalability that Grows with Your App

As your customer base expands, your support system becomes more complex. You need a platform that manages higher traffic volume without sacrificing performance, availability, or user experience. PubNub is designed to meet these needs, providing strong scalability, redundancy, and performance across our global network.

Proven Scale

PubNub is a trusted provider of real-time communication for some of the world’s largest brands, spanning industries such as e-commerce, gaming, healthcare, fintech, and transportation. We transmit billions of messages daily across our global data centers and simultaneously support hundreds of millions of devices. Our infrastructure is designed to provide seamless support during high-demand events like flash sales, product launches, or global marketing campaigns.

Infrastructure Savings

Developing a scalable messaging infrastructure from the ground up demands substantial time, resources, and engineering investment, particularly when factoring in redundancy, failover, and performance assurances. PubNub addresses these challenges by offering a serverless, globally accessible messaging backbone with high reliability, up to 99.999% uptime, and inherent resilience.

With PubNub, developers can focus on their application's core capabilities, sending and receiving real-time messages, managing customer state, and synchronizing case data with minimal backend logic. This approach significantly lowers the total cost of ownership (TCO) and allows you to scale your support team without a proportional increase in operational overhead.

On-Demand Elasticity

Customer support must scale instantly to handle demand surges, whether they are caused by a product release, a social media campaign, or a holiday traffic spike. PubNub offers on-demand elasticity and dynamic scaling to support high concurrency without requiring any intervention from your engineering team.

For instance, an e-commerce platform might experience a tenfold increase in live chat sessions during a Black Friday sale. Still, PubNub will automatically absorb this spike, preventing message delivery delays, dropped conversations, and service degradation.

Elasticity also facilitates the rapid onboarding of new support agents, external vendors, or AI-powered services during peak seasons or in response to service-level escalations.

Final Thoughts

PubNub provides scalable, real-time live chat support with AI automation and advanced features, ensuring faster response times, personalized experiences, and greater customer satisfaction. Businesses can use the Chat SDK to enhance support channels, improve satisfaction, and future-proof their strategy across the web, Android, and iOS.

Ready to enhance the chat for your call center solution? Start building now with PubNub by signing up for a free account, reaching out to us, or contacting our DevRel team directly.