Post To User

Use the zoho.cliq.postToUser deluge task to post message to a user by passing their email address or their ZUID as a string. This task will call the Post message to a user API.


Syntax: zoho.cliq.postToUser("<abc@example.com>","Hello!");

Example

Take this example of a scheduler configured to get reports of the latest campaign sent. The scheduler is executed to get the report and post it as a message in the user's chat!


//Configure a scheduler that reminds you of tasks and posts the message in a chat, channel or a bot!
message = Map();
params = Map();
params.put("limit","1");
params.put("resfmt","JSON");
response_map = invokeurl
[
	url :"https://campaigns.zoho.com/api/recentsentcampaigns"
	type :GET
	parameters:params
	connection:"INSERT YOUR CONNECTION NAME"
];
// info response_map;
campaignKey = response_map.get("recent_sent_campaigns").toMap().get("campaign_key");
info campaignKey;
paramsMap = Map();
paramsMap.put("campaignkey",campaignKey);
paramsMap.put("resfmt","JSON");
response = invokeurl
[
	url :"https://campaigns.zoho.com/api/campaignreports"
	type :GET
	parameters:paramsMap
	connection:"INSERT YOUR CONNECTION NAME"
];
info response;
label = {"type":"label","data":{{"Total audience count":response.get("campaign-reports").toMap().get("emails_sent_count")},{"Unique clicks":response.get("campaign-reports").toMap().get("unique_clicked_percent") + " %"},{"Open Percentage":response.get("campaign-reports").toMap().get("open_percent")}}};
info label;
message = {"text":"Stats of the recent " + response.get("campaign-details").toMap().get("campaign_name") + " campaign you sent.","card":{"title":"Campaign Stats","theme":"basic","thumbnail":""},"bot":{"name":"Campaigns Notifier","image":""},"slides":{label}};
zoho.cliq.postToUser("user_emailID",message);