Desk SDKs JavaScript v1
Desk SDKs JavaScript
Desk SDKs
JavaScript
Version 1

When a customer sends a message from a client app that includes a link, Link preview enables to provide a preview text or a thumbnail image of the link. In this way, a sender and a receiver of the message can be aware of what they're going to see before they open the link.


To provide a link preview by updating a message, every user message sent from a customer's client app should be checked if it includes any URLs.

Implement the following code snippet to extract the URL from a customer's message. Use the getUrlPreview() method to pass the extracted URL to Sendbird server. When the server sends the parsed data, set it as a JSON object and stringify the object. Then, pass the stringified JSON object as an argument to a parameter in the updateUserMessage() method.

As a result, the original message is updated with a link preview through the onMessageUpdated() method of the channel event handler, and a sender and a receiver of the message can see a link preview on their app or a web.

In the onMessageUpdated() method of the channel event handler, you can find the data for a link preview in the message.data property as below: