Post To Bot

Post To Bot

Table of Contents

Send a bot message

Use the postToBot deluge task to post a message to the bot. The message can be just text, or a card or even an image.


Syntax: zoho.cliq.postToBot(<bot_unique_name>,"Hello!") 

To get the bot unique name:

  1. Select Integrations from the Settings option.
  2. Click on Bots and select the bot you would like to message.
  3. The API Endpoint URL in the Bot preview has the Bot Unique Name.


Sample API Endpoint URL of a Bot: https://cliq.zoho.com/api/v2/bots/<bot_unique_name>/message

Example

Pull out details about the bugs tagged under your name by connecting with Zoho Projects. The bugs filed under your name can be categorized according to their severity and posted as a message to a bot. 


message = Map();
response = invokeUrl [
    url : "https://projects.zoho.com/restapi/portal/[PORTAL_ID]/projects/[PROJECT_ID]/bugs/?assignee=[ASSIGNEE_ID]"
    type : GET
    connection : INSERT YOUR CONNECTION NAME
];
info response;
bugs = response.toMap().get("bugs");
rows = List();
for each  bug in bugs
{
	title = bug.get("title");
	bugid = bug.get("bug_number");
	severity = bug.get("severity").toMap().get("type");
	row = Map();
	row.put("Issue Title",title);
	row.put("Issue ID",bugid);
	row.put("Severity",severity);
	rows.add(row);
}
message = {"text":"Issues Filed Under your Name","card":{"theme":"modern-inline","title":"Issue Reports"},"slides":{{"type":"table","title":"Issue Details","data":{"headers": {"Issue Title","Issue ID","Severity"},"rows":rows}}}};
zoho.cliq.postToBot("<bot_unique_name>",message);
info message;
return Map();

Post a message to all subscribers of the bot

To post a message to all subscribers of the bot, use the broadcast key and set its value as true


response=Map();
response.put("broadcast","true");
response.put("text","Hello Everyone!");
zoho.cliq.postToBot("<bot_unique_name>",message);
return response;

Post a message to specific subscribers of the bot

You can post a message to particular subscribers of the bot, by using the userids parameter in the response map. The userids can either be ZUID's or email addresses of the users. 


response=Map();
response.put("userids","1234567,5674859");
response.put("text","Hi Guys!");
zoho.cliq.postToBot("<bot_unique_name>",response);
return response;

(OR) 

response=Map();
response.put("userids","abc@example.com,xyz@example.com");
response.put("text","Hi Guys!");
zoho.cliq.postToBot("<bot_unique_name>",response);
return response;

Post images to a bot

You can post images to the bot as well! Do note that the image should be a deluge file object. 


Syntax: zoho.cliq.postToBot(<bot_unique_name>,{image}); 

 


message = Map();
image = getUrl("https://www.zoho.com/cliq/help/restapi/v2/images/bot-unique-name-lhs.png");
zoho.cliq.postToBot("<bot_unique_name>",{image});
return message;

Post to Bot as Admin

The zoho.cliq.postToBotAsAdmin task should be used to connect to the bot in 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.postToBot, where you'll have to pass the bot unique name and the intended message to be posted.


Syntax: zoho.cliq.postToBotAsAdmin("<bot_unique_name>", "Hello"); 

Share this post : FacebookTwitter

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

Write to us: support@zohocliq.com