Client actions are actions that Flock clients take when a user interacts with controls like Slash Commands, Attachment Pickers, Launcher Buttons, and so on.
Flock currently supports three kinds of client actions. They are:
Apps can use widgets to render web applications inside an iframe or a webview within Flock. They can not only do everything that a normal webapp can, but also interact with the Flock client hosting them.
To open a widget, the following info is required:
modal
or sidebar
modal
.Apps can choose to open a URL in the browser too. To open the browser, provide the following:
Apps can also choose to silently send an event to the event listener URL.
There are many ways to configure client actions in Flock.
Use the developer dashboard to configure an action for a Slash Command, Launcher Button, Chat Tab Button or Attachment Picker.
Client actions for attachment buttons are configured while creating the corresponding Attachment. Use the action
property of a button to set the appropriate ActionConfig object.
{ "description": "attachment description", "views": { "widget": { "src": "<widget url>", "width": 400, "height": 400 } }, "buttons": [{ "name": "<button 1>", "icon": "<icon 1 url>", "action": { "type": "openWidget", "desktopType": "modal", "mobileType": "modal", "url": "<action url>" }, "id": "<button id 1>" }, { "name": "<button 2>", "icon": "<icon 2 url>", "action": { "type": "openBrowser", "sendContext": true } "id": "<button id 2>" }] } |
Widgets can open another widget or the browser using flock.js.
flock.openWidget("<widget url>", "modal") |
flock.openBrowser("<url>", true); |
FlockML's action
tag can also be used to trigger client actions:
<flockml>click <action type="openWidget" url="<url>" desktopType="sidebar" mobileType="modal">here</action> to launch a widget.</flockml> |
<flockml>click <action type="openBrowser" url="<url>" sendContext="true">here</action> to open the browser.</flockml> |
<flockml>client <action type="sendToAppService">here</action> to send an event to the event listener URL.</action> |
An event is generated every time a client action is triggered.
The events sent by various controls when a client action is triggered are listed below:
Trigger | Event |
---|---|
Button | client.pressButton |
Slash Command | client.slashCommand |
Widget | client.widgetAction |
FlockML | client.flockmlAction |
The event name along with its attribute provides sufficient context for the client action.
Yes. Your app may send a message to a user who may not have installed your app, or a group where some users may not have installed your app. When these users interact with this message's attachment (e.g. click on an attachment button, or take some action inside the attachment widget), a client action is triggered.
If you verify that the event token sent with the corresponding event is really signed using your app's secret (you should always do this anyways), you can be certain that the event originated from Flock and was actually triggered by the user whose userId is included in the event token (even if they haven't installed the app).