Skip to main content
Smart Replies enable the retrieval of an AI-generated response message within a conversation.

Before you begin

1

Configure AI settings

Set up AI in the CometChat dashboard as detailed in the Overview.
2

Enable Smart Replies

Go to ChatFeatures, under AI User Copilot, enable Smart Replies.
3

Use v4 Chat SDKs

Implement chat using CometChat v4 Chat SDKs.

How does it work?

CometChat AI goes through the messages of a conversation to understand the context of a conversation & provide relevant replies. It returns three replies: positive, negative & neutral. The CometChat SDK has a method to fetch the smart replies in a conversation. It returns an object of three replies with keys: positive, negative & neutral. The number of messages used to generate smart replies is configurable. By default, CometChat AI uses the latest 1000 messages. You can also use timestamps.
  • lastNMessages: Fetch a specific number of recent messages.
  • fromTimestamp: Fetch messages from a particular timestamp.
  • toTimestamp: Fetch messages up to a particular timestamp.
  • unreadOnly: Fetch only unread messages.
While using any configuration mentioned above a maximum of only 1000 messages will be fetched.

Implementation

SDKs

To implement Smart Replies in the platform of your choice, you may utilize the following code samples:
const receiverId = "UID/GUID";
const receiverType = "user/group";
const configuration = { lastNMessages: 100 };

CometChat.getSmartReplies(receiverId, receiverType, configuration).then(
  (smartReplies) => {
    const { positive, negative, neutral } = smartReplies;
    console.log("Positive Reply", positive);
    console.log("Negative Reply", negative);
    console.log("Neutral Reply", neutral);
  },
  (error) => {
    console.log("An error occurred while fetching smart replies", error);
  }
);

UI Kits

Assuming the necessary prerequisites are met, Smart Replies function seamlessly starting from v4 of the Chat UI Kits. In v4, Smart Replies are accessible manually, whereas in v5, they work automatically.