What are client actions?

Client actions are the actions that a Flock client takes when a user interacts with controls like buttonsslash 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 an ActionConfig object while configuring a button or a slash command, either in the app manifest or in an attachment. A client action can also be triggered by a widget using methods provided in flock.js, or by FlockML content using anchor tags.

Which client action is performed depends on the type attribute of this object. The various options are:

How do I open a widget?

See the relevant section in the widgets page.

How do I open the system browser?

You can open the system browser by providing a ClientActionConfig object with type openBrowser and the following attributes:

For example, to open the browser each time a user presses the attachment picker button, provide the configuration as below.

attachmentPicker: {
    description: "<attachment picker help text>",
    icon: "attachment-picker.png",
    action: { type: "openBrowser", url: "<action url>", sendContext: true }
}

How do I send an event to the app service?

You can dispatch an event to the app service by providing an ActionConfig object with the type sendToAppService. The type of event that is sent to your app service is covered in the next section.

For example, to dispatch an event when user enters a slash command, provide this configuration:

slashCommand: {
    command: "<name of the command>",
    helpText: "<help text for the slash command>",
    action: { type: "sendToAppService" }
}

How does my app discover what triggered the client action?

An event is generated anytime a client action is triggered. The event, along with its attributes, is:

The table below explains the specific events generated for each trigger.

TriggerEvent
Buttonclient.pressButton
Slash Commandclient.slashCommand
Widgetclient.widgetAction
FlockMLclient.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. There are a couple of scenarios in which a Flock client might trigger a client action for a user who hasn't installed the app. These are:

If you verify that the validation token sent with the 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.