Cliq bots share a few similarities to Cliq users; that is all bots have a profile where you can set their display pictures, a status and can be mentioned in a conversation too! Just typing '
@ ' followed by the bot name will mention the bot in a conversation. We're drawing this analogy here to convey the idea behind a bot's mention handler. This handler is prompted to act when a bot is mentioned by a user in a conversation.
What happens when you mention a bot?
The handler will enable the bot to perform an action it is programmed to do so. During this execution, the bot handler receives a list of attributes. Learn more about these attributes in the bot mention handler
help page.
For example, "
@geekbot give me some interesting fact!"
The bot response would look something like this - "Did you know? The character Mario from the video game Mario Bros is best known as a plumber. But he originally debuted as a carpenter in the game Donkey Kong."
The geekbot's mention handler is triggered to respond to the conversation with an interesting fact. How? The bot identifies the keywords to give an appropriate answer if the keywords do not match, then you don't get a fact. As simple as that!
Sample Scenario Illustration
Let us try to build a bot for the support team of an organization. A typical work day for any support executive will consist of handling multiple chats and replying to tons of emails. How can a bot be helpful as an assistant here? When a support agent is trying to discuss a request raised by a customer, the agent simply @mentions the TicketBot to get details about this ticket. The bot posts the response in a message card in the same conversation for everybody to see!
The TicketBot 's mention handler code is shown below. Take a look!
- response = Map();
- userinput = message;
- if(userinput.containsIgnoreCase("#"))
- {
- ticketID = userinput.subString(userinput.indexOf("#"));
- id = ticketID.subString(0,ticketID.indexOf(" "));
- ticket = zoho.support.searchRecords("Requests","Zylker","ZylCal","Request Id",id,1,10,"desk","true");
- if (ticket.size() > 0)
- {
- response = {"text":"Details for the ticket " + id,"card":{"theme":"modern-inline"},"slides":{{"type":"label","data":{{"Ticket Status":ticket.toMap().get("Status")},{"Contact Name":ticket.toMap().get("Contact Name")},{"Contact Email":ticket.toMap().get("Email")},{"View More Details":"[Take me to desk!](https://desk.zoho.com" + ticket.toMap().get('URI') + ")"}}}}};
- }
- else
- {
- response = {"text" : "Hey! Looks like the ticket ID is invalid. :neutral:"};
- }
- }
- else
- {
- response = {"text":"Hi There! \n I can get you the ticket details for any ticket. Just try mentioning me followed by the #ticketID. Just like this: *@salesbot* give me details about *#12345*","card":{"theme":"prompt"}};
- }
- return response;
Key Points to Note
- zoho.support.searchRecords is the deluge task to get a record from Zoho Desk. To learn more about this task refer the searchRecords help page. The format of this deluge task is
- records = zoho.support.searchRecords("<Module_Name>","<Organization_Name>","<Department_Name>","Status","Open",1,10,"<Connection_Link_Name>", User_Access);
- In the code snippet, ' desk ' is the connection link name, created for Zoho Desk and Zoho Search. If you're looking to create a bot that integrates with other products or within Zoho, then you'll have to create a connection. Learn how to create connections here .
- This code in mention handler is invoked when the bot is mentioned in any conversation. The response is posted in the same conversation by the bot.
- To structure the response of the bot as a message card, refer this help page .
The bot mention handler is a great way to ask your bot to do custom tasks for you or your team and also to involve your bot in group conversations. So start building your bot mention handler right away!
Comments and suggestions are welcome!
Best,
Manasa
Cliq