Button Object for Message Cards
The button object is categorized under the Message Object. There are two different types of buttons
A button added in a message card will be structured with the button object.
The button object can have the following attributes. The mandatory fields are indicated by a *
| Attribute | Type | Description |
| label* | string | The display name of the button. Maximum number of characters allowed: 20 |
| hint | string | A tool tip indicating the button's function while hovering over. Maximum number of characters allowed : 100 |
| type* | string | The type + denotes a button with green outline , type - denotes button with red outline. |
| key | string | Unique key set for each button. This key can be defined to easily identify and differentiate the buttons clicked and execute the functionality. Maximum number of characters allowed : 100 |
| action* | JSON Object | An object containing the type of action the button should perform. |
The action object attributes:
| Attribute | Type | Description |
| type* | string | The action type for a button. Allowed values: invoke.function | system.api | open.url | preview.url | copy | invoke.form |
| data* | JSON Object | An object with properties for each action type. |
| confirm | JSON Object | Properties of the confirmation dialog box before the action is executed. It can be included based on the requirement. |
The data object properties vary depending on the type of action chosen :
Data object when the button action type is invoke.function
| Attribute | Type | Description |
| name* | string | Name of the function to be invoked. |
| owner* | string | The email address of the function creator |
| location | string | Specifies whether location sharing is mandatory or optional when invoking the function.
|
Data object when the button action type is open.url
| Attribute | Type | Description |
| web | string (URL) | The URL to be opened on clicking the button. Supported Protocols: http | https | tel | sms | sip Maximum number of characters allowed : 256 |
| windows | string (URL) | The URL to be opened on clicking the button. Exclusive for windows mobile. Maximum number of characters allowed : 256 |
| iOS | string (URL) | The URL to be opened on clicking the button. Exclusive for iOS mobile. Maximum number of characters allowed : 256 |
| android | string (URL) | The URL to be opened on clicking the button. Exclusive for android mobile. Maximum number of characters allowed : 256 |
Data object when the button action type is preview.url
The preview_url response type allows users to view a URL's content directly within the chat interface, such as playing a video or rendering a webpage.This rich response type can be used for the following scenarios:
Display a video player for Video link previews.
Embed a rich preview with a clickable image and text for web links.
Show basic file details and provide an option to download or view the document.
| Attribute | Type | Description |
| url* | string | Iframe url to play video or render webpage. Maximum length : 500 |
Data object when the button action type is system.api
| Attribute | Type | Description |
| api* | string | Allowed Values: audiocall | videocall | startchat | invite | locationpermission Format : system action/{zuid} |
Data object when the button action type invoke.form
The invoke.form button type allows users to invoke a form's Form View Handler when they click a Message Button. This enables users to access forms directly from message cards without relying on form permalinks.
You can use this action type in the following scenarios:
- Open forms directly from message cards: Allow users to access a form by clicking a button in a message.
- Trigger form workflows: Invoke the Form View Handler to display the form and collect user inputs.
- Pass custom parameters: Send custom parameter values to the Form View Handler to customize the form based on the context of the message.
You can also pass custom parameters to the Form View Handler using the params key.
| Attribute | Type | Description |
| name | string | Name of the form function to be invoked. |
| params | map | Custom parameter details to be passed to the Form View Handler (if available). |
return {
"buttons": [
{
"label": "View request",
"hint": "View the leave request",
"action": {
"type": "invoke.form",
"data": {
"name": "leaveApplication",
"params": {
"EMPLOYEE_ID": "EMP1024",
"LEAVE_TYPE": "Casual Leave"
}
}
}
}
],
"text": "A new leave request has been raised. Click below to review the details."
};
Data object when the button action type is copy
The copy button type allows users to copy a specified text directly to their clipboard when clicked. This type can be helpful in the following scenarios:
- Copy meeting links from notifications or unfurled link previews for easy access and sharing.
- Copy tracking numbers or order IDs to access shipment updates or returns quickly.
- Quickly copy ticket IDs from support messages to share with other teams or reference in other systems.
| Attribute | Type | Description |
| text* | string | The text to be copied to clipboard Maximum length : 200 |
Example - Copy button type in message card
return {
"buttons":{
{
"action":{
"data":{
"text":"Ticket ID: #A21398"
},
"type":"copy"
},
"label":"Copy Ticket ID"
}
},
"text":"Your support request has been created successfully. Use the ticket ID below for future reference."
};
Example - Copy button type in a widget button
{"label":"Copy","type":"copy","text":"Text to be Copied!"}
The confirm object attributes:
| Attribute | Type | Description |
| title* | string | Confirmation dialog box title before the action is executed. Maximum number of characters allowed : 100 |
| description | string | Confirmation message displayed before the action is executed. Maximum number of characters allowed : 100 |
| input* | string | The input text prompt present in the confirmation dialog box. This input field is used to collect user input ( For example : authentication key or feedback ) during confirmation or cancellation action. |
| emotion | string (Optional) | To set the visual style of the confirmation dialog box. Allowed Values : positive | neutral | negative If key is not provided, the theme of the dialog box will be set as positive by default. |
| button_label* | string | Label of the button present in the confirmation box. Maximum number of characters allowed : 100 |
| cancel_button_label | string | Label of the cancel button present in the confirmation box. Maximum number of characters allowed : 100 |
| mandatory | string (Optional ) | To specify whether the input field is required or not. Allowed Values : true | false When set to true, an error must be thrown if the user does not provide any input. |
| buttontext* Deprecated | string | Label of the button present in the confirmation box. Maximum number of characters allowed : 100 |
Instant button syntax:
[button label](action type | function name |button reference key)Note:
The instant button works only with invoke.function and system.api action types.
Sample message card button object:
"buttons": [
{
"label": "Update Campaigns",
"type": "+",
"key": "approve",
"action": {
"type": "invoke.function",
"data": {
"name": "update_campaigns",
"owner": "li.jung@zylker.com",
"location": "mandatory"
}
}
}
]
