What is an Attachment?
An attachment is rich content attached to a message. It can include content like dynamic widgets, static HTML, FlockML, images and files. Attachments can also have their own buttons. Here are a few examples:
The Poll app uses a widget to render a live interactive poll inside a chat tab.
URL Preview uses static HTML, for example, to display YouTube previews inline.
The Trello app uses FlockML to render card information in attachments.
Unlike widgets or static HTML that can only be rendered inline on desktop, FlockML can be rendered inline in mobile too.
Your app can also send images using attachments.
Or share files.
How can I send an attachment?
Since an attachment is a part of a message, to send an attachment you will need to send a message. If you haven't, read Sending Messages first.
Include the Attachment inside the
attachmentsarray that is passed to chat.sendMessage. The example below shows an attachment with a title, description and a widget included inside a message. See the Attachment reference for more details on the attachment object.
- Send this message using chat.sendMessage.
What are Attachment buttons?
Each attachment can also provide one or more buttons to perform custom actions in Flock when they are pressed.
For example, the to-do app adds a View button for any attachment that it sends.
To add a button one or more buttons to an attachment, use the
Each button can have a name, icon, an identifier and an action associated with it. An attachment button can perform any of these three actions:
- Open a widget
- Open the browser
- Send an event to the event listener URL
See ActionConfig for details on how an action can be configured for attachment buttons.
How do I create different kinds of attachments?
Create an attachment with a widget as follows. Note that an attachment widget opens inline in the chat pane only on the desktop and not on mobile (where it opens in a full screen modal on click).
height are only used on desktop to fix the dimensions of the inline attachment widget. See Widgets for more details.
Static HTML included in an attachment shows up inline in desktop. On mobile clients, clicking on the attachment opens this HTML in a modal webview. Again,
height are only used on desktop.
FlockML is an alternative to static HTML that can be shown inline in both desktop and mobile.
An image and optionally its thumbnail can be added to an attachment as follows. Images are rendered inline on both mobile and desktop
One can also share files using attachments via the
What is the precedence order for attachment rendering?
Flock selects of the following "Views" for display in the chat screen. The order of precedence (highest to lowest) is as follows:
On mobile, widget and HTML are not displayed on the chat screen, so only the last two are used. If a user taps on the attachment though, widget or HTML are shown in a modal.