Cliq Bots - Building conversational bots with a series of questions and user inputs!

Cliq Bots - Building conversational bots with a series of questions and user inputs!

We all know how important it is for a bot to manage the conversation flow with a user. And so, here we bring to you the bot context handler! This post introduces the concept of a context and how a chain of questions and user inputs can be achieved through the context. 

Simply put, the context allows the bot to ask a series of questions pertaining to a topic of interest. The responses or the user inputs are then collected to perform an action at the end via the context handler.  Sounds interesting? Let's jump straight into the working of the bot's context handler!
 
So how does the bot context handler work?

The bot context handler is designed to handle multiple questions and collect the user responses. That is, a 'context' map has to be defined with the list of questions and their expected responses (as bot suggestions) from the user. This way your bot can easily ask questions to the user and collect all the information required for performing an intended action. The nitty-gritty of this handler is explained on our help page      

Key points about the context handler:

  • The context handler allows the bot to build and maintain a conversational flow, more like a dialogue exchange with a series of questions. 
  • This will be triggered only upon the initiation of the context map. 
  • Other bot handlers will be triggered to execute only if there is no ongoing context.
  • Also, an added advantage of using this handler is, your bot can handle multiple conversation chains smoothly unlike other handlers! 

So the context handler for the win!

Get started with a sample use case...

Let's say you are planning on creating a Quiz Bot for your team. A quiz bot that can engage the user by asking questions from a list of topics as suggestions. Once the user selects a topic, the bot will get started with the questions. Once the user answers a question, the answer will be saved followed by initiation of the next question. Take a look at how the context handler can be used in this scenario!

The sample context handler code is given below : 

  1. response = Map();
  2. if(context_id.matches("QUIZ"))
  3. {
  4. categories = {"Movies":11,"Politics":24,"Sports":21};
  5. if(categories.containKey(answers.get("quiz").get("text")))
  6. {
  7. topic = categories.get(answers.get("quiz").get("text"));
  8. }
  9. urlresponse = getUrl("https://opentdb.com/api.php?amount=5&category=" + topic + "&type=multiple");
  10. questions = urlresponse.get("results");
  11. info questions;
  12. randomNumbers = (getUrl("https://www.random.org/integers/?num=5&min=0&max=3&col=20&base=10&format=plain&rnd=new")).toList("\t");
  13. info randomNumbers;
  14. questionList = list();
  15. options = {0,1,2,3};
  16. count = 0;
  17. for each  question in questions
  18. {
  19. suggList = list();
  20. randomNumber = randomNumbers.get(count);
  21. info randomNumber;
  22. optionIter = 0;
  23. for each  opt in options.toList()
  24. {
  25. if(opt == randomNumber)
  26. {
  27. suggList.add({"text":question.get("correct_answer")});
  28. }
  29. else
  30. {
  31. suggList.add({"text":question.get("incorrect_answers").get(optionIter)});
  32. optionIter = optionIter + 1;
  33. }
  34. }
  35. questionString = question.get("question");
  36. questionString = questionString.replaceAll(""","'").replaceAll("'","'");
  37. q = {"name":"q" + count,"question":questionString,"suggestions":{"list":suggList}};
  38. questionList.add(q);
  39. questionList.add({"name":"a" + count,"question":questionString,"value":{"text":question.get("correct_answer")}});
  40. count = count + 1;
  41. }
  42. return {"text":"All the best for the quiz!  :victory:","context":{"id":"QuizChallenge","timeout":"600","params":questionList}};
  43. }
  44. else if(context_id.equalsIgnoreCase("QuizChallenge"))
  45. {
  46. marks = 0;
  47. q = {0,1,2,3,4};
  48. str = "";
  49. for each  no in q.toList()
  50. {
  51. qno = no + 1;
  52. userAns = answers.get("q" + no);
  53. origAns = answers.get("a" + no);
  54. if(userAns.equalsIgnoreCase(origAns))
  55. {
  56. str = str + qno + ". " + origAns.get("text") + "\n";
  57. marks = marks + 1;
  58. }
  59. else
  60. {
  61. str = str + qno + ". " + origAns.get("text") + "\n";
  62. }
  63. }
  64. str = str + "Score : " + marks + " / 5\n";
  65. quotes = {"5":"You're awesome!","4":"Great","3":"Good!","2":"Ok!","1":"Try again!","0":"Better luck next time!"};
  66. str = str + quotes.get("" + marks);
  67. return {"text":str};
  68. }
  69. return response;

Here's the message handler code :

  1. response = Map();
  2. if(message.containsIgnoreCase("Quotes"))
  3. {
  4. url = getUrl("https://talaikis.com/api/quotes/random/");
  5. quote = url.toMap();
  6. response = {"text":quote.get("quote"),"card":{"theme":"prompt","title":"Here's a quote for you by " + quote.get("author") + " :smile!:"}};
  7. }
  8. else if(message.containsIgnoreCase("Quiz"))
  9. {
  10. context = {"id":"QUIZ","timeout":"300","params":{{"name":"quiz","question":"Well, let us get started by choosing the category! Shall we? :grinning:","suggestions":{"list":{{"text":"Movies"},{"text":"Politics"},{"text":"Sports"}}}}}};
  11. response.put("context",context);
  12. }
  13. else
  14. {
  15. response = {"text":"Hi! I am Cupcake, your not so human friend. My motto in life is to stay happy always and I try to make everyone else happy too! :happy!: By just being myself. I am super cute. Just try asking me something, will you?","suggestions":{"list":{{"text":"Motivational Quotes"},{"text":"Quiz"}}}};
  16. }
  17. return response;

Check out this video for the working of the above given example!


We hope the context handler gave you an idea of how easily bot conversations can be framed! Let us know how this post helped you in the comments. 

 

Best,

Manasa

Cliq

    • Sticky Posts

    • Automating Employee Birthday Notifications in Zoho Cliq

      Have you ever missed a birthday and felt like the office Grinch? Fear not, the Cliq Developer Platform has got your back! With Zoho Cliq's Schedulers, you can be the office party-cipant who never forgets a single cake, balloon, or awkward rendition of
    • Convert a message on Cliq into a task on Zoho Connect

      Message actions in Cliq are a great way to transform messages in a conversation into actionable work items. In this post, we'll see how to build a custom message action that'll let you add a message as a task to board on Zoho Connect. If you haven't created
    • Cliq Bots - Post message to a bot using the command line!

      If you had read our post on how to post a message to a channel in a simple one-line command, then this sure is a piece of cake for you guys! For those of you, who are reading this for the first time, don't worry! Just read on. This post is all about how
    • Cliq Bots - How to make a bot respond to your messages?

      Bots are just like your buddies with whom you can interact. They carry out your tasks, keep you notified about your to-dos and come in handy when you need constant updates from a third party application.  So, how can you make your bot respond to a message? The bot message handler is a piece of code triggered when a message is sent to the bot. Message handlers help you customise your bot responses to make it look conversational. The message input from the user can be either a string or an option selected
    • Cliq Bots - Get notifications about any action on an application with the incoming webhook handler!

      Webhooks can be used to get notified about events happening in other applications inside Cliq. All bots in Cliq have their own incoming webhook endpoint. This makes it simple to post messages to the bot from external applications. Unlike the send message
    • Recent Topics

    • Amazon.in FBA multiple warehouse integration with Zoho Inventory

      My organisation subscribed to Zoho One looking at the opportunity to integrate Amazon.in with Inventory. But during the configuration, we understood the integration has severe limitations when it involves multiple warehouses in the same Organisation.
    • A recap of Zoho Sprints 2024

    • Values in multi pick list are not copied to copied deal

      Hi, After a deal is completed in our sales funnel we copy the deal to an automatically created new deal in our project funnel. All fields are copied properly, but only a Multi Pick List is not copied. How can we copy the selected values in this field
    • Zoho Form linked to an external OneDrive Account

      HI Can you connect to an external users OneDrive account from Zoho forms that is not a user in Zoho? I have a form that is shared externally where a sub contractor needs to receive info (including pictures) to their OneDrive account. When I try to connect
    • How to query for Deals record based on Pipeline?

      I want to query for Deals records that matches a specified Pipeline using a Deluge function. When I call zoho.crm.searchRecords("Deals","(Pipeline:equals:" + myPipeline + ")"), I get this error: { code: 'INVALID_QUERY' , details: {...} , message: 'Invalid
    • Zoho Books - France

      L’équipe de Zoho France reçoit régulièrement des questions sur la conformité de ses applications de finances (Zoho Books/ Zoho Invoice) pour le marché français.   Voici quelques points pour clarifier la question :   Zoho Books est un logiciel de comptabilité
    • Checklist/ save to onedrive/ a group of items invoicing in Zoho FSM

      hi, is there a way to add a specific checklist to any WO without passing eachtime by the model customization? can we save file such picture directly in our sharepoint ak onedrive? is there any way to add a group of item pre defined to make invoicing easier
    • Pushing Data from One CRM account to another.

      We have business partners that want to collaborate through the CRM. Other than pre-planned data migrations what are the options for Zoho Users to transfer data between the accounts. For instance, could I create a webhook that is sent from our CRM and then is picked up in the partner's Flow?
    • Difference: Linking Module Record vs. Subform Row with lookup

      In terms of "database relationship structure", is there is difference between a Linking Module Record and a Subform Row with a lookup? Both have the ability to store data related to a specific connection of two modules, right? Do I miss something? When
    • Explication sur comment mettre en place des règles d'affichage ou "layout Rules"

      J'ai passé plus d'une heure hier avec le support et je n'ai rien compris !! Je suis lecteur assidu des guides (je "RTFM") qui ne sont absolument pas orienté "client" chez Zoho, et je tiens à le rappeler ici . Dans la documentation on m'indique un cas
    • Kaizen #96 Automatic Mail-Merge Document Creation Using Zoho CRM APIs

      Efficient communication and personalized document generation are crucial for maintaining strong customer relationships in your business. Manual document generation can be time-consuming, repetitive and error-prone, decreasing productivity and customer
    • Automation#26: Notify Parent Ticket Owner on Child Ticket Status Updates

      Hello Everyone! Ever found yourself juggling multiple service requests that seem like pieces of a larger puzzle? Managing interconnected tickets can be challenging, especially when updates on child tickets need to be tracked. That’s where our custom function
    • Zoho Workplace renforce sa sécurité avec l'intégration Zoho Vault

      Dans un monde où l’information a une valeur inestimable, la protection des données sensibles n’a jamais été aussi essentielle. Une fuite de données peut non seulement compromettre la réputation d’une entreprise, mais également engendrer des pertes financières
    • Can the Product Image on the Quote Template be enlarged

      Hello, I am editing the Quote Template and added ${Products.Product Image} to the line item and the image comes up but it is very tiny. Is there anyway that you can resize this to be larger? Any help would be great! Thanks
    • How to sort a data in summary report with Monthly ?

      Hi Team, Can any one help me out how to sort a data based on monthly, Month was shuffled based on aliphatic order. i want to sort the below data monthy?
    • Directly Edit, Filter, and Sort Subforms on the Details Page

      Hello everyone, As you know, subforms allow you to associate multiple line items with a single record, greatly enhancing your data organization. For example, a sales order subform neatly lists all products, their quantities, amounts, and other relevant
    • Set another Layout as Standard

      We created a few layouts and we want to set another one to standard:
    • Create custom rollup summary fields in Zoho CRM

      Hello everyone, In Zoho CRM, rollup summary fields have been essential tools for summarizing data across related records and enabling users to gain quick insights without having to jump across modules. Previously, only predefined summary functions were
    • How can I create individual records from a subform

      Hi, I am collecting subform data into a Lead record and I need to create individual records for each row associated to the account when it is converted. How can I do this?
    • What is the Desk API?

      I'm trying to fetch a lookup field data from desk to our creator application and it doesn't work. I'm guessing that my search parameter is wrong? On my trial function fetch if I use these: tickets = invokeurl [ url :"https://desk.zoho.com/api/v1/tickets/351081000145244764"
    • How to choose other payment methodes than creditcards

      We have connected stripe as a payment provider in zoho books, booking, commerce and checkout. In stripe we selected al major payment methodes for Belgium (mainly bancontact). However, at checkout customers seems to have only the possibility to pay with
    • Why is Zoho support so terrible?

      I've spent the last week trying to get zoho to fix sudden SSL certificate issues with our desk and project portals. I've raised a ticket and constantly been told the issue is on our side despite it being exceedingly obvious it's not. After finally convincing
    • Custom "Filter By" in Client Portal

      Currently our client portal only shows items for that specific person that is logged on to the portal, we want the current logged user to see all items for that user's company. An example would be invoices, so the current user would see all invoices for
    • Ticket Views: filter criteria -> dynamic date values in relation to the current date

      Hello all, It would be very helpful if you could build custom views in such a way that you do not have to adjust the criteria daily or at whatever interval in order to change the fixed date value as needed. For example, I would like to create a view that,
    • Unlocking New Horizons: A Year in Review

      As we bid farewell to 2024, let's celebrate and revisit the key highlights of the year. From adding a new edition to cross-platform enhancements, here’s a roundup of all the feature updates designed to simplify accounting, optimize financial management,
    • Introducing 'Queries' In Zoho CRM

      Hello everyone! We are here with an exciting feature - Queries in Zoho CRM! A little context before we dive right into the feature specifics :) In today’s fast-paced business environment, immediate access to relevant data is essential for informed decision-making.
    • Enable Sending Direct Messages to Self in Zoho Cliq

      Hi, I would like to request a feature enhancement for Zoho Cliq to allow users to send direct messages to themselves. Currently, Zoho Cliq does not have the option to send a direct message to oneself. While creating a channel with just one member (the
    • Admin Access to Direct Messages in Zoho Cliq

      Hi Zoho Cliq Team, We would like to request a feature enhancement to enable admin access to one-on-one conversations (direct messages) conducted through Zoho Cliq. Use Case: As administrators, there are situations where it becomes essential to access
    • Zoho developer edition does not work for us

      Hi Is anyone else having this problem? I'm signed in with our admin/super user account. When I click on the link on this page: https://www.zoho.com/crm/developer/docs/dev-edition.html I am asked to agree to Terms and Conditions. Clicking Agree to Terms
    • Need help with KPI Widget on Dashboard

      What I am trying to accomplish seems simple, but I cannot figure it out.  Please help. I would like to show in a KPI Comparison Widget: Number of Meetings (CRM) Held in Last 30 Days compared to Number of Meetings Held the previous 30 days (from the date
    • Need to send message to slack channel from zoho people form

      - I have setup slack connection in zoho people, it is successfully showing connected - I am using connection name to send message view custom function, but it is not working: response = invokeurl [ url :"https://app.slack.com/client/T78002gHF/C089773324"
    • User tiers

      I am trying to add tiers of users. I would like: Me - CEO Next Tier down - Managers Next tier down - All the salepeople reporting to each manager I can only seem to add myself with mansagers below. Surely I can add more tiers?
    • Flow to follow up on trade fair contacts

      Hi, Before we moved to Zoho we had some flows (sequences) in HubSpot to follow up on trade fair contacts. To explain further on this it had the following characteristics: New contacts could be added to the sequence When added a flow of communication started.
    • Queries filtered by current page/record

      I have been trying to use the new queries feature, and I can filter the query, but I'm coming unstuck because I don't understand how to make the query dynamically include the filter of the current record. ie if I'm on a deal, to filter all the records
    • Article Numbers for KB articles

      Hello, I was wondering if it's possible to turn on article numbers/ part numbering for KB articles. If this is not already a feature, we'd like to request it. Frequently a solution will require multiple articles so tracking which articles are referenced
    • Audit Log Export via API

      Hello, Based on the documentation here https://www.zoho.com/crm/developer/docs/api/v7/create-export-audit-log.html I need to specify the scope ZohoCRM.settings.audit_logs.CREATE to create a log export. I've created a Self Client app but when I specify
    • Zoho CRM API Credits & Limits for Workflow

      Hi Team, Just wanted to clarify how the API credits work for Zoho CRM and workflows with custom functions. API Credits are based on your subscription and are set at the account level. You can buy additional credits if needed. For Enterprise customers,
    • CRM Calendar Sync Not Working

      I can't get any meetings where I am a participant to sync with either Bookings or Office 365. It syncs fine when I am the host, but as a participant, it just ignores the event. I have clients booking meetings when agents are in training or OOO or any
    • How to easy change layout in existing records in Deals?

      Hello, So far i have used only 1 layout in Deals. I have about 1000 records. Now i want to make new layout. So i have 2 layouts: Layout Old (1000 records) Layout New (0 records) How to easy change layout from Layout Old into Layout New for existing records?
    • Change Last Name to not required in Leads

      I would like to upload 500 target companies as leads but I don't yet have contact people for them. Can you enable the option for me to turn this requirement off to need a Second Name? Moderation update (10-Jun-23): As we explore potential solutions for
    • Next Page