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:
How do I configure a client action?
Typically, you set up a client action by providing a ClientActionConfig object while configuring a button or a slash command, either in the app manifest or in an attachment.
Which client action is performed depends on the
type attribute of this object. The various options are:
open_widget.Opens a widget.
open_browser. Opens the system browser.
.Sends an event to the app backend.
How do I open the system browser?
You can open the system browser by providing a ClientActionConfig object with type
open_browser and the following attributes:
url. The URL to open.
send_context. This is a boolean value that specifies if specific query parameters (like
flock_event, and so on) should be appended to the URL. The default value is
false. Never set this to
trueif you are opening a third party URL in the browser.
For example, to open the browser each time a user presses the attachment picker button, provide the configuration as shown below.
How do I dispatch an event to the app backend?
Send an event to your app backend by providing a ClientActionConfig object with the type
Which event is sent to your app backend is covered in the next section.
For example, to dispatch an event when user enters a slash command, provide this configuration:
How does my app discover what triggered the client action?
An event is generated anytime a client action is triggered. The event alongwith its attributes is
- either sent to the app backend using the Events API if the configured action was to dispatch the event
- or passed as the URL query params
flock_event_attributesto the widget or browser URL
The table below explains what event is generated for each trigger:
The event name along with its attribute should provide sufficient context for the client action.
Can client actions be triggered for users who haven't installed the app?
Yes, there are a couple of scenarios in which a Flock client might trigger one for a user who hasn't installed the app
- An attachment that contains a widget is shared with a user or a group where atleast some users haven't installed your app
- An attachment shared with such a user contains a button that triggers a client action
In case the configured action is to open a widget or the browser, the Flock client allows it, however no user token is passed. See this section in the widgets page for more details.
In the configured action is to dispatch an event to the app backend, the Flock client doesn't allow it, and instead prompts the user to install your app.