What are client actions?
Client actions are the actions that a Flock client takes when a user interacts with controls like buttons, slash commands, and so on, that have been provided by an app. Flock currently supports three kinds of client actions. They are:
- Opening a widget inside the Flock client
- Opening a URL in the system browser;
- Sending event to the app service.
How do I configure a client action?
Different controls have different ways in which their respective client actions can be configured:
- For an attachment picker button, chat tab button, launcher button or a slash command, the client action is configured in the dev dashboard
- For an attachment button, the client action is configured using an ActionConfig object provided along with other button attributes when creating the Attachment.
- From inside a widget, a client action can be triggered by calling
flock.openWidget
orflock.openBrowser
methods provided by flock.js. - A FlockML view can trigger a client action by using the
action
element.
What happens when a client action is triggered?
An event is generated every time a client action is triggered.
- If the configured action is to open a widget or browser URL, the event is appended as a query parameter to the URL.
- Or if the configured action is to send the event to the app service, it is sent to the app service's event callback URL.
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.
Can client actions be triggered for users who haven't installed the app?
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 validation 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 validation token (even if they haven't installed the app).