CometChat Pro Documentation

You'll find comprehensive guides and documentation to help you start working with CometChat as quickly as possible. Let's jump right in!

Smart Reply

Learn how to show quick reply options to respond to a message.

The Smart Reply extension allows you to show quick reply options to a user so that they can easily respond to a message. We will always suggest 3 options; one positive, one neutral and one negative. We also add a category, in case you want to skip some suggestions.

When a user sends a message, our Smart Reply extension will add metadata while the message is in-flight. The recipient will receive the message with metadata suggesting the response.

Here is a sample response that you will receive in the metadata of the message.

"@injected": {
  "smart-reply": {
    "reply_positive": "This is awesome!",
    "reply_neutral": "That's fine",
    "reply_negative": "This is awful",
    "category": "how_is_it"
  }
}

You can use this information to build a UI like this:

How to show smart replies in your UI

How to show smart replies in your UI

At the recipients' end, from the message object, you can fetch the metadata by calling the getMetadata() method. Using this metadata, you can fetch suggested responses for the message.

var metadata = message.getMetadata();
if (metadata != null) {
    var injectedObject = metadata["@injected"];
    if (injectedObject != null && injectedObject.hasOwnProperty("extensions")) {
        var extensionsObject = injectedObject["extensions"];
        if (extensionsObject != null && extensionsObject.hasOwnProperty("smart-reply")){
            var smartReplyObject = extensionsObject["smart-reply"];
            var reply_positive = smartReplyObject["reply_positive"];
            var reply_neutral = smartReplyObject["reply_neutral"];
            var reply_negative = smartReplyObject["reply_negative"];
            var category = smartReplyObject["category"];
        }
    }
}

Smart Reply


Learn how to show quick reply options to respond to a message.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.