Menu Handler provides an easy way to trigger actions with just one click! Imagine a news bot having the list of categories as a menu, instead of asking the bot to get the news for a particular category, the user can click on any particular menu action and get the details. For example, a custom menu action 'Help' dedicated to educating the users about the bot's functionality and how to interact with the bot will provide to be of great use!
Working of the bot menu handler
The workflow for the menu handler is pretty straightforward. The handler is invoked to perform an action when a user selects a particular action from the menu list. The response is displayed to the user as a preview. Take a look at the list of attributes passed when the menu handler is triggered in our
help page.
Note: Each bot can have a list of 5 custom actions!
Sample Scenario
Let us try creating a feedback menu action for a bot. On clicking this feedback action, the user should be able to send feedback or feature requests to the bot creator directly. This makes it easier for the user to give their feedback without going through the usual route of sending an email / filling a form!
The following steps go into creating this feedback menu :
- Configure the feedback menu action to post message on click
- A function to work in association with the feedback button.
- Creating a connection with Cliq ( to post the feedback response from the user to the bot creator)
Take a look at the sample code snippet for the bot menu handler:
- response = Map();
- response =
- {
- "text": "Hi " + user.get("first_name") + " !Tell us what you think of Connect Bot and also give us suggestions on a feature you would love to have! :grinning:",
- "card":{
- "title":"Feedback Time",
- "theme":"prompt"
- },
- "buttons":{
- {
- "label":"Give Feedback",
- "type":"+",
- "action":{
- "type":"invoke.function",
- "data":{
- "name":"feedback",
- "owner": " youremail@yourdomain.com "
- },
- "confirm":{
- "title":"Give us your valuable feedback!",
- "description":"Write what you think of Connect Bot!",
- "buttontext":"Submit Feedback",
- "input":"Enter your feedback here"
- }
- }
- }
- }
- };
- return response;
Sample Functions Execution Code:
- response = Map();
- feedback = arguments.get("input");
- param = Map();
- param.put("text","You've got a new feedback! User:" + user.get("email") + " Feedback: " + feedback);
- response = invokeurl
- [
- url :"https://cliq.zoho.com/api/v2/channelsbyname/feedbackchannel/message"
- type :POST
- parameters:param.toString()
- connection: " your connection name "
- ];
- message = Map();
- message = {"text":"Thank you for your feedback! :smile: ","bot":{"name":"Connect Bot"}};
- info message;
- post_message= zoho.cliq.postToChat(chat.get("id"),message);
- return Map();
The below-given video demonstrates how to configure and build this custom feedback menu action and also the working
We hope this sample scenario threw light on how easy bot actions are to create and equally easy to use! Comments and suggestions are welcome!
Few useful links to refer:
Best,
Manasa
Cliq