Post To Channel

Post to a Channel

Use the zoho.cliq.postToChannel deluge task to post a message to a channel directly by using the channle unique name or the channel ID. The message posted will be visible to all participants of the channel. The zoho.cliq.postToChannelAsAdmin task should be used to connect to Cliq from other Zoho applications.


Syntax: zoho.cliq.postToChannel(<channel_unique_name>, "Hello!");

To get the channel unique name:

  1. Hover over the channel name in the LHS and select the More Info option.
  2. Click Connectors.
  3. The API Endpoint URL contains the Channel Unique Name.

How to find the Channel Unique Name?


Sample API Endpoint URL for a Channel: https://cliq.zoho.com/api/v2/channelsbyname/<channel_unique_name>/message

 

Example

Let us consider a scheduler which posts updates about the list of calls scheduled for the day in the #sales channel. To pull data from CRM, create a connection with Zoho CRM and use the invoke URL task in the deluge script. 

Note:

To create a scheduler, head on over to the help page on Schedulers. 


message = Map();
// Use the zoho.currenttime function and form the current date pattern to match the date received in the search calls API JSON response.

currdate = zoho.currenttime;
currday = currdate.getDay();
info currday;
if(currday < 10)
{
	currday = "0" + currday;
}
currmonth = currdate.getMonth();
if(currmonth < 10)
{
	currmonth = "0" + currmonth;
}
currdatestr = currdate.getYear() + "/" + currmonth + "/" + currday;
info currdatestr;
response = invokeurl
[
	url :"https://www.zohoapis.com/crm/v2/Calls/search?criteria=((Call_Status:equals:Scheduled))"
	type :GET
	connection:"INSERT YOUR CONNECTION NAME"
];
info response;
calls = response.get("data").toList();
rows = List();
count = 0;
for each  call in calls
{
	status = call.get("Call_Status");
	dateString = call.get("Call_Start_Time");
	dateObject = dateString.toTime("yyyy-MM-dd'T'HH:mm:ssXXX");
	time = dateObject.getTime(12);
	dateObject = dateObject.toString("yyyy/MM/dd");
	info dateObject;
	if(dateObject == currdatestr)
	{
		count = count + 1;
		row = Map();
		row.put("S.No",count);
		row.put("Scheduled By",call.get("Created_By").get("name"));
		row.put("Scheduled With",call.get("Who_Id").get("name"));
		row.put("Call Time",time);
		row.put("Call Details",call.get("Subject"));
		row.put("Purpose",call.get("Call_Purpose"));
		row.put("Contact Information",call.get("What_Id").get("name"));
		row.put("Notes",call.get("Description"));
		rows.add(row);
		table = {"type":"table","title":"","data":{"headers":{"S.No","Scheduled By","Scheduled With","Call Time","Call Details","Purpose","Contact Information","Notes"},"rows":rows}};
		message = {"text":"Hello! Here's the list of calls scheduled for today :smile: ","card":{"theme":"10"},"bot":{"name":"Sales Notifier","image":""},"slides":{table}};
	}
}
zoho.cliq.postToChannel("<channel_unique_name>",message);

Sales calls for the day posted in the #zyl-sales channel

Calls for the day posted in #zyl-sales channel

Post to Channel as Admin

The zoho.cliq.postToChannelAsAdmin task should be used to connect to Cliq from other Zoho applications. This deluge task posts with the token of the Organization admin. The syntax for this deluge task is the same as zoho.cliq.postToChannel, where you'll have to pass the channel unique name and the intended message to be posted.


Syntax: zoho.cliq.postToChannelAsAdmin(<channel_unique_name>, "Hello!");

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocliq.com