Preview handler
The preview handler is used to expand the link to display a richer data format. The preview handler will be triggered either when a user enters the link in the composer or after they send it in the chat. A map with unfurl card details will be returned in the response.
You will get the following attributes when the preview handler is executed.
Attribute | Description |
domain | Domain which matches the one handled by the extension |
url | Link sent by the user |
chat | Details of the chat where the link was entered or sent |
user | Details of the user who entered or sent the link |
The unfurled card response can have the following attributes
Attribute | Type | Description |
title* | String | Title for the unfurled card (max length : 500) |
type* | String | The type of unfurl. Allowed Values: link | photo | video | rich |
provider_url* | String | Resource provider url. (max length: 1000) |
description | String | Description for the unfurl card, maximum length 3000 |
provider_name | String | Resource provider name. (max length: 100) |
favicon_url | String | Resource provider fav icon. (max length: 1000) |
thumbnail_url | String | Thumbnail url. (max length: 1000). Supported for link, richand video type |
actions | Array | Butons actions in unfurl card. Supported for link and rich type |
dynamic_actions | Boolean | Used to add menu icon to the unfurl card. Allowed values: True | False. Supported for link and rich type |
fields | JSON Object | Option to render fields in unfurl card. |
Attribute | Type | Description |
type* | String | The type of action. Allowed value: button |
label* | String | Button label. (max length : 100) |
hint | String | Button hint. (max length: 250) |
style | String | To denote the style(positive/negative) of the button. Allowed values: + | - |
confirm | JSON Object | Properties of the confirmation dialog box before the action is executed. It can be included based on the requirement. |
params | JSON Object | Dynamic key value pair for reference. A Maximum of 10 keys with 100 character value can be passed. |
Attribute | Type | Description |
label* | String | Field label. (max length : 100) |
value* | String | Field value. (max length: 500) |
Attribute | Type | Description |
short* | Boolean | Option to short the given fields based on key |
Types specific additional mandatory keys:
Rich, Video:
Attribute | Type | Description |
iframe_url* | String | Iframe url to play video or render webpage. (max length: 1000) |
Photo:
Attribute | Type | Description |
url* | String | Image url. (max length: 1000) |
Sample code:
return {
"title": "Graphics Artist | Notion",
"type": "link",
"provider_url": "https://www.notion.so/",
"faviconlink": "https://www.notion.so/front-static/favicon.ico",
"thumbnail_url": "https://images.unsplash.com/photo-1613909207039-6b173b755cc1?ixlib=rb-4.0.3&q=85&fm=jpg&crop=entropy&cs=srgb",
"description": "Notion - A new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team",
"fields": {
"data": [
{
"label": "Parent Database",
"value": "[Vendor Management](https://www.notion.so/demoid1234)"
},
{
"label": "Type",
"value": "Page"
},
{
"label": "Created By",
"value": "John Doe (john.doe@zoho.com)"
}
]
},
"actions": [
{
"hint": "Add a Block of information to the Page.",
"style": "+",
"label": "Add Block",
"type": "button",
"params": {
"page_id": "demopageid123"
}
},
{
"hint": "Add a subpage to the page",
"label": "Add Subpage",
"type": "button",
"params": {
"page_id": "demopageid124"
}
}
],
"dynamic_actions": true
};