Message Action Handler

Message actions help in executing an action on a sent message. Apart from the default actions such as Forward , Reply you can create a message action to suit your purpose. 

Each message action performed will be passed through the following attributes:

Attribute NameDescription
messageDetails of the message for which the action is performed.
messagesArray list of details of all selected messages for which the action is performed.(The limit is upto 25 messages including upto 10 files)
attachmentsMessage actions performed on the attachments triggered on the attachments message type.
userDetails of the user executing the message action.
mentionsArray of information about the user/channel/bot mentioned.
chatChat details in which the message action is executed.
locationDetails of the current location of the user.

Rendering a response:

When a message action is executed the response rendered can be made visible either to the action executor or can be posted as a message in the conversation with the help of the messaging deluge tasks, zoho.cliq.postToChat or zoho.cliq.postToChannel

Where can you find a message action?

To perform a message action, hover over the sent message and click on the "..." (more) option and select Installed Apps to view the custom message actions available. 

Example:

Let us consider a message action to save files or images shared in a chat directly to your cloud storage, Google Drive for example. In the following sample syntax; params, comments, driveheaders  are defined as a Map where the header details, file details are stored as a key value pair respectively. The files object is defined as a collection to store the list of files being uploaded. The invoke URL task is used to establish the connection between Cliq and Google Drive. 



// Sample Syntax for Google Drive Message Action
message = Map();
file = attachments.get(0);
params = Map();
params.put("name",file);
comments = Map();
comments.put("stringPart","true");
comments.put("paramName","metadata");
comments.put("content",params.toString());
comments.put("contentType","application/json");
comments.put("encodingType","UTF-8");
fileList = List();
fileList.add(comments);
fileList.add(file);
driveHeaders = Map();
driveHeaders.put("Content-Type","multipart/related");
response = invokeurl
[
	url :"https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"
	type :POST
	headers:driveHeaders
	files:fileList
	connection: //Give your connection name
];
info response;
fileDetails = invokeurl
[
	url :"https://www.googleapis.com/drive/v3/files/" + encodeUrl(response.get("id")) + "?fields=name,id,webViewLink&restrictToMyDrive=true"
	type :GET
	connection: //Give your connection name
];
button = List();
if(!fileDetails.get("webViewLink").isNull())
{
	button.add({"label":"View","action":{"type":"open.url","data":{"web":fileDetails.get("webViewLink")}},"type":"+"});
}
message = {"text":"The file [" + response.get("name") + "]("+fileDetails.get("webViewLink")+") has been uploaded to your Google Drive. :thumbsup:"};
return message;

 

Note:

1. Connections is an interface that enables integration of third party services with Cliq. Take a look at Connections to understand more.

2. The Invoke URL task using the files object is explained here.

Related Articles:

Message Actions: Do more than just Forward, Reply on your chat messages by creating custom actions

Learn how to turn messages into actionable work items.