Bot Menu Handler

Bot Menu Handler

A menu action is a shortcut to a list of actions that can bot can perform for the user. You can add upto 5 custom menus for a bot. There are a list of attributes that are available in the bot's menu handler: 

AttirbuteDescription
user

Details of the bot subscriber who executes the menu action

chat

Details of the bot's chat. 

How to add menus?

  • Once you create a bot by giving the name, description, filling the required fields and clicking that Save Bot button, you will be directed to the Edit Handlers page.
  • Click Add Menu under the Menu option. 
  • Name your menu action and define it's functionality in the Edit Code page.

Where can you find a bot's menu actions?

The custom menu actions are displayed below the message composer in the chat window! 

Default Menu Actions

A list of default menu actions are available for all bots, such as

  • Print - To print the chat transcript
  • Pin Bot - Use this menu item to list the bot under the My Pins category
  • Unsubscribe - Unsubscribe to a bot
  • Bot Permalink - Select this action item to copy the bot permalink and share it instantly.

Example

The Projects Bot has a menu option to get details of issues/bugs assigned to you. Take a look at the sample syntax given below. We've used our message cards here to display data. Learn more about message cards 

Note:

This example uses the Get all issues API of Zoho Projects. To learn more about this API, refer Zoho Projects API

 


message = Map();
assigneelist = List();
assigneelist.add(user.get("id"));
paramsMap = {"statustype":"open","assignee":assigneelist};
getUserIssues = invokeurl
[
	url :"https://projectsapi.zoho.com/restapi/portal/Portal ID/projects/Project ID/bugs/"
	type :GET
	parameters:paramsMap
	connection:"Enter your connection name"
];
bugs = getUserIssues.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);
        row.put("Change Status","[+Change Stauts](invoke.function|projects)");
        row.put("Add Note","[Add Note](invoke.function|projects)");
	rows.add(row);
}
info rows;
message = {"text":"Hey "+user.get("first_name")+" ! List of recent open issues assigned to you!","card":{"title":"Open Issues","theme":"modern-inline"},"slides":{{"type":"table","title":"Issue Details","data":{"headers":{"Issue Title","Issue ID","Severity","Change Status","Add Note"},"rows":rows}}}};
zoho.cliq.postToBot("Enter your bot's unique name",message);
return Map();

Related Articles:

Cliq Bots - Create preset actions for your bot using the menu handler

Learn how to configure a feedback menu action to receive feedback from your bot subscribers

Share this post : FacebookTwitter

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

Write to us: support@zohocliq.com