You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 33 Next »

What are client actions?

Client actions are actions that Flock clients take when a user interacts with controls like Slash CommandsAttachment PickersLauncher Buttons, and so on. 

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 an event to the event listener URL.

Opening a Widget

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:

  • URL of the widget
  • Type of widget in desktop – it can be either modal or sidebar
  • Type of widget in mobile – this is usually optional. The only acceptable value is modal.

Opening the Browser

Apps can choose to open a URL in the browser too. To open the browser, provide the following:

  • The URL to open.
  • Whether to send event context or not. When enabled, event parameters are appended to the URL.

Sending an event to the event listener URL

Apps can also choose to silently send an event to the event listener URL.

Configuring Client Actions

There are many ways to configure client actions in Flock.

Developer Dashboard

Use the developer dashboard to configure an action for a Slash CommandLauncher ButtonChat Tab Button or Attachment Picker.

Opening a Widget

flock.js

Widgets can open another widget or the browser using flock.js.

Opening a widget using flock.js
flock.openWidget("<widget url>", "modal")
Opening the browser using flock.js
flock.openBrowser("<url>", true);

FlockML

 

 

FlockML's action tag can also be used to trigger client actions:

Opening a widget using FlockML
<flockml>click <action type="openWidget" url="<url>" desktopType="sidebar" mobileType="modal">here</action> to launch a widget.</flockml>
Opening the browser using 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>

 

 

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, 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 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 or flock.openBrowser methods provided by flock.js.
  • 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.

The events sent by various controls when a client action is triggered are listed below:

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 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).