What is a message action button?

Your app's message action button is added to each and every message that a user sees in Flock. If a user clicks the message action button, the message and chat details are sent to the app via the client.messageAction event.   

A user can also select multiple messages in Flock. If a user clicks the message action button after selecting multiple messages, then details of all the selected messages are sent.

What are the available actions for a message action button?

Your app can configure any of these client actions for a message action button:

  • Opening a widget inside the Flock client
  • Opening a URL in the system browser;
  • Sending an event to the event listener URL.

What message details are included in client.messageAction?

Flock will always send the uid of every message that was selected when the message action button was pressed.

client.messageAction with messageUids
{
    "name": "client.messageAction",
    "userId": "u:cfc76545-3400-4864-892a-513a9f4ae409",
    "userName": "Alyssa P. Hacker",
    "chat": "u:1e6429de-16b7-48b3-acc0-c2d7ec5ad195",
    "chatName": "Ben Bitdiddle",
    "messageUids": [ "fd4877b719b1", "59e2da001af2" ]
}

To get further details of each message, you can call chat.fetchMessages and pass the received message uids. This will return the Message object for each message.

Optionally, when the number of messages selected is low, Flock might send the Message objects within the event itself. If the messages array is included, then you can read message details directly from within the event, rather than calling chat.fetchMessages.

client.messageAction with messages
{
    "name": "client.messageAction",
    "userId": "u:cfc76545-3400-4864-892a-513a9f4ae409",
    "userName": "Alyssa P. Hacker",
    "chat": "u:1e6429de-16b7-48b3-acc0-c2d7ec5ad195",
    "chatName": "Ben Bitdiddle",
    "messageUids": [ "fd4877b719b1", "59e2da001af2" ]
    "messages": [ { "from": "u:1e6429de-16b7-48b3-acc0-c2d7ec5ad195",
                    "to": "u:cfc76545-3400-4864-892a-513a9f4ae409",
                    "uid": "fd4877b719b1",
                    "text": "Hello" },
                  { "from": "u:cfc76545-3400-4864-892a-513a9f4ae409",
                    "to": "u:1e6429de-16b7-48b3-acc0-c2d7ec5ad195",
                    "uid": "59e2da001af2",
                    "text": "Hello again" } ]
}

How do I create a message action button?

  1. Go through Creating an App to setup your app in the developer dashboard.
  2. In the Advanced Info section, enable the message action button.



    Fill in the info below:

    FieldMandatoryDescription
    TitleYesTitle for the message action button
    Select ActionYesSelect an appropriate client action for the message action button
  3. Go through app installation and install the app into your own Flock account.
  4. Click the app's message action button on any message.
  5. Verify the event token and take relevant action at your end.