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!

Link Preview

Learn how you can show a preview of the web page for links.

The Link Preview extension will help you show a preview of the web page for every link in your message. We generate metadata for every link mentioned in a message.

Say, for example, a user shares a Facebook link in their message, then our extension will query the link for the details that you need to build a preview.

"@injected": {
  "extensions": {
    "link-preview": {
      "links": [
          "description": "Create an account or log into Facebook. Connect with friends, family and other people you know. Share photos and videos, send messages and get updates.",
          "favicon": "",
          "image": "",
          "title": "Facebook - Log In or Sign Up",
          "url": ""

Using this metadata, you can build a preview box similar to the one you seen in Slack.

At the recipients' end, in the message object, you can fetch the metadata by calling the getMetadata() method. Using this metadata, you can fetch the URL information to generate the preview.

var metadata = message.getMetadata();
if (metadata != null) {
    var injectedObject = metadata.getJSONObject["@injected"];
    if (injectedObject != null && injectedObject.hasOwnProperty("extensions")) {
        var extensionsObject = injectedObject.getJSONObject["extensions"];
        if (extensionsObject != null && extensionsObject.hasOwnProperty("link-preview")){
            var linkPreviewObject = extensionsObject["link-preview"];
            var description =linkPreviewObject["description"];
            var favicon = linkPreviewObject["favicon"];
            var image = linkPreviewObject["image"];
            var title = linkPreviewObject["title"];
            var url = linkPreviewObject["url"];

Links that take more than a second to resolve will be automatically skipped to keep in-flight transit time to a minimum.

Link Preview

Learn how you can show a preview of the web page for links.

Suggested Edits are limited on API Reference Pages

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