Messaging APIs - Generating URL Preview
When you send a URL link as part of the message text or set URL using the
setContent() API, the mesibo can generate a rich URL preview with a title, description, thumbnail image, etc. before sending it. This feature allows users to share links including tweets, Instagram posts, YouTube videos, news articles, etc with a preview so that the recipient knows about the link before opening it.
To generate a URL preview, mesibo needs to open the website, download the content and then generate a preview from it. Depending on the network speed, the process may take small time, often unnoticeable.
There are two ways mesibo can generate a preview, locally generated at the user end or requesting the server (cloud or on-premise) to generate the preview. You can use either, both, or none as per the privacy and security requirements of your app, as described later in this document.
mesibo API generates a preview only if the title, subtitle, description, thumbnail, and image fields are not set. Also, URL preview will not work with websites requiring login or protected somehow (for example, some Facebook posts).
You can enable or disable the URL preview feature per Message by setting
urlPreview properties of
To enable or disable URL preview,
msg.urlPreview = false;
To enable server-side URL preview,
msg.urlPreviewServer = true;
If you are using mesibo cloud, note that,
Since the mesibo cloud server needs to download the web content and images from the URL to generate a preview, the bandwidth consumed by the server will be added to your bandwidth usage. mesibo server maintains a preview cache for some time and hence bandwidth consumption will not be charged if the content is already cached.
For security, mesibo cloud generates previews from selected websites only. While we have included popular websites in the list, you can suggest if you would like to add other websites.
However, if you are using mesibo on-premise, the above points do not apply. Also, you can generate previews from unrestricted websites or from websites of your choice.
Note that server-side preview may not work in some cases and you may or may not want to fall back to local preview generation. For example, if the server is in a different country and the URL is not available in that country. One common example is the Netflix movie link when the movie is not available in the server region.
mesibo APIs can automatically extract URL and set them if it was not already set. You can disable URL extraction by setting
extractUrlFromMessage properties of
To disable URL extraction,
msg.extractUrlFromMessage = false;
mesibo API can also try to generate a preview from the file URL (image, video, etc). It needs to download the file and save it locally before it can generate the preview. You can modify the following properties to change the default behavior.
|If the URL points to an image file, save it locally and extract the thumbnail (if applicable)
sameImageUrl described above but for video file
sameImageUrl described above but for audio file
sameImageUrl described above but for all types of file
|save file only if the size is less than urlTransferSize
mesibo API can cache the preview at the user end so that it does not need to regenerate if the same URL is sent again. Caching is enabled by default.
To disable URL extraction,
msg.urlPreviewCache = false;
mesibo API will always use the cached preview if available. However, you can force the mesibo API to generate a new preview instead of using a cached preview if the preview is older than certain seconds.
For example, to set cache expiry to 7 days,
msg.urlPreviewExpiry = 3600*24*7;
Please consider the following Privacy and Regulatory implications using the URL preview feature in your apps. You can disable the feature completely or selectively per region as per applicable regulations.
- When a local URL preview is generated, mesibo API needs to connect to the website to download the content for preview, and hence the IP address of the user will be disclosed to the website.
- Even if end-to-end encryption is enabled, opening the link to generate the local preview may disclose the URL contained in the message to the eavesdropper.
- Privacy laws in some countries/continents may not allow or may require you to inform your users about privacy implications.
A counter-argument is that when a user shares a link, the user might have already visited the website. However, we leave it to your security policies to decide whether to use local or server-side URL previews.
Note that, mesibo will only generate a URL preview when sending a message and not when receiving the message to protect the recipient from the IP address leak.