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

    Access your files securely from anywhere



                        Zoho Developer Community




                                              • Desk Community Learning Series


                                              • Digest


                                              • Functions


                                              • Meetups


                                              • Kbase


                                              • Resources


                                              • Glossary


                                              • Desk Marketplace


                                              • MVP Corner


                                              • Word of the Day


                                              • Ask the Experts



                                                        • 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
                                                        • Automate your status with Cliq Schedulers

                                                          Imagine enjoying your favorite homemade meal during a peaceful lunch break, when suddenly there's a PING! A notification pops up and ruins your moment of zen. Even worse, you might be in a vital product development sprint, only to be derailed by a "quick
                                                        • Bulk user onboarding for Cliq Channels in a jiffy

                                                          As developers, we frequently switch between coding, debugging, and optimizing tasks. The last thing we want is to be burdened by manual user management. Adding users one by one to a channel is tedious and prone to errors, taking up more time than we could
                                                        • 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
                                                        • Unfurling Unlimited Possibilities in Zoho Cliq 🔗

                                                          Are you tired of your app links looking plain? Imagine if the shared links came to life with custom previews, organized data, and one-click actions, making chats more interactive. With the Cliq platform's unfurl handlers, let's see how developers can


                                                        Manage your brands on social media



                                                              Zoho TeamInbox Resources



                                                                  Zoho CRM Plus Resources

                                                                    Zoho Books Resources


                                                                      Zoho Subscriptions Resources

                                                                        Zoho Projects Resources


                                                                          Zoho Sprints Resources


                                                                            Qntrl Resources


                                                                              Zoho Creator Resources



                                                                                  Zoho CRM Resources

                                                                                  • CRM Community Learning Series

                                                                                    CRM Community Learning Series


                                                                                  • Kaizen

                                                                                    Kaizen

                                                                                  • Functions

                                                                                    Functions

                                                                                  • Meetups

                                                                                    Meetups

                                                                                  • Kbase

                                                                                    Kbase

                                                                                  • Resources

                                                                                    Resources

                                                                                  • Digest

                                                                                    Digest

                                                                                  • CRM Marketplace

                                                                                    CRM Marketplace

                                                                                  • MVP Corner

                                                                                    MVP Corner





                                                                                      Design. Discuss. Deliver.

                                                                                      Create visually engaging stories with Zoho Show.

                                                                                      Get Started Now


                                                                                        Zoho Show Resources


                                                                                          Zoho Writer Writer

                                                                                          Get Started. Write Away!

                                                                                          Writer is a powerful online word processor, designed for collaborative work.

                                                                                            Zoho CRM コンテンツ










                                                                                              Nederlandse Hulpbronnen


                                                                                                  ご検討中の方




                                                                                                        • Recent Topics

                                                                                                        • Zoho Bookings Integration with Make.com

                                                                                                          Dear Zoho Bookings Support Team, We are writing to request a new integration between Zoho Bookings and Make.com, a leading automation platform widely used by Zoho users. Current Integration: We acknowledge the existing integration with Zapier, another
                                                                                                        • Introducing Zoho CRM for Everyone: A reimagined UI, next-gen Ask Zia, timeline view, and more

                                                                                                          Hello Everyone, Your customers may not directly observe your processes or tools, but they can perceive the gaps, missed hand-offs, and frustration that negatively impact their experience. While it is possible to achieve a great customer experience by
                                                                                                        • Introducing Rollup summary in Zoho CRM

                                                                                                          ------------------------------------------Moderated on 5th July'23---------------------------------------------- Rollup summary is now available for all organizations in all the DCs. Hello All, We hope you're well! We're here with an exciting update that
                                                                                                        • Different Page Numbering

                                                                                                          I want the page numbers not just 1,2,3... but i,ii,iii,iv,... or even I,II,III,IV.... How can I do this?
                                                                                                        • Leads Should Support Business-Centric Structure for B2B Use

                                                                                                          We’re a B2B company that generates leads for other businesses and often engage with multiple contacts within the same company. For years, we’ve struggled with Zoho CRM’s limitation of requiring a Last Name field for leads. For example, if we’re pursuing
                                                                                                        • Poor Search Results on Zoho CRM

                                                                                                          The search on Zoho CRM is quite poor. Salesforce has now published a new search, when will get this on Zoho? https://help.salesforce.com/s/articleView?id=data.c360_a_hybridsearch_index.htm&type=5
                                                                                                        • Holding Shift to keep selected tickets

                                                                                                          It is annoying trying to change the category of tickets and then closing them. You have to select them one by one, no way to 'hold down left click and drag your mouse down to select multiple'. Once you have selected them and you change the category, you
                                                                                                        • Currency Data Type Issue

                                                                                                          Hi, I'm running into an issue with the currency data type conversion with the pipeline tool inside Zoho Analytics. Basically, when the table is added to the pipeline, the columns with currency data type will be converted to text type. I assume it's because
                                                                                                        • Zoho AI Translate – No Support for Hebrew?

                                                                                                          I want to use Zoho AI Translate, but I see that it does not support Hebrew. Since Zoho supports multiple languages, I was hoping this function would also work with Hebrew. Is there any plan to add Hebrew support in the near future? Or is there an alternative
                                                                                                        • CRM HAS BEEN SOOO SLOW For Days 05/15/25

                                                                                                          I have fantastic Wifi speed and have zero issues with other websites, apps, or programs. It takes an excruciatingly amount of time to simply load a record, open an email, compose an email, draft a new template, etc. Am I in a subset/region of subscribers
                                                                                                        • Exclude Segment from Campaign Recipients

                                                                                                          I've created two Segments in order to separate Non-Marketing Contacts from Marketing Contacts. I'd like to send an Eblast to all Marketing contacts in my lists, but when I go to select Recipients, I have two options: 1. To Choose Lists to Send to; 2.
                                                                                                        • Equivalent domains

                                                                                                          Need a settings feature for adding/modifying/deleting domains that use the same login service. The feature can also suggest some popular sites that use shared credentials to access domains under their control. For example: amazon.com and its local variations like amazon.in. For example: gmail.com and google.com. LastPass has this feature.
                                                                                                        • Introducing Keyboard Shortcuts for Zoho CRM

                                                                                                          Dear Customers, We're happy to introduce keyboard shortcuts for Zoho CRM features! Until now, you might have been navigating to modules manually using the mouse, and at times, it could be tedious, especially when you had to search for specific modules
                                                                                                        • Associating Multiple Work Orders with a Single Invoice in Zoho FSM

                                                                                                          Hello Everyone, Is it possible to associate multiple Work Orders with a single Invoice in Zoho FSM? Best Regards, Subhash Kumar
                                                                                                        • Can't verify DKIM key?

                                                                                                          So basically I just wanted to verify the email on my domain so it doesn't showup as spam in other people's inboxes. So I did what Zoho told me to do, it was to verify a DKIM key. I created the key with the address, added the correct information to the TXT file in my domain's DNS settings, tried to verify it and it keeps saying 'Verification failed'. I tried it more then once, I reset the DKIM key, and for some reason it just won't verify. Either it's me being impatient or this thing isn't working.
                                                                                                        • Custom view placeholders

                                                                                                          Hi all, On some occasions it would be great to have placeholders setting up a custom view. Example in our case we have a field for a year. We would like to have a placeholder like $.{CurrentYear} that will insert the current year 2025 e.g. Now we have
                                                                                                        • Forecast performance analysis

                                                                                                          Last modified on 15/05/2023: Performance analysis in forecasts is now available for all Zoho CRM users in all DCs. Note that it was an early access feature available only upon request. As of May 10, 2023, it is rolled out for all Zoho CRM accounts. Find
                                                                                                        • Audio/video quality issues with Zoho Meeting – Any roadmap for improvement?

                                                                                                          Hi Zoho Team, We’ve been using Zoho Meeting for both internal and external meetings, and unfortunately, the experience has been consistently poor. The video and audio quality are so unreliable that it often renders meetings ineffective—especially with
                                                                                                        • Clone a Module??

                                                                                                          I am giong to repurpose the Vendors module but would like to have a separate but very similar module for another group of contacts called Buyers. I have already repurposed Contacts to Sellers. Is it possible to clone (make a duplicate) module of Vendors
                                                                                                        • Deleting Records Older Than 14 Days

                                                                                                          I have a form called vacancies that contains a field "status_date". I need to create a schedule that runs once a week and if the status date is > 14 days it deletes that record.  I would appreciate anyones help.  -Aaron 
                                                                                                        • I need open my email in Zoho from oulook account

                                                                                                          Hi Can you help me to solved this First, I’m unable to access my email account via Outlook. Second, when I send any email from my Zoho account, it doesn’t reach Gmail inboxes. Thank you for your support
                                                                                                        • USA Military addresses

                                                                                                          When we have a client with a US military address adding them to the CRM, or having them fill in a form is a problem. Zoho Forms and CRM doesn't seem accommodate them correctly. It doesn't make sense for me to have to create a secondary data model for
                                                                                                        • Default value for Subject field in Case module

                                                                                                          I would like to add a default value to the Subject field in a custom module based on the Case module. Since this field is mandatory, I can't use a workflow rule that adds a default subject if the field is left empty. So I would like to display a default
                                                                                                        • Getting daily summary report from SalesIQ

                                                                                                          Why am I suddenly getting a daily summary report from SalesIQ when I'm not even using it nor signed up to it knowingly?
                                                                                                        • MULTI-SELECT LOOKUP - MAIL TEMPLATE

                                                                                                          Dear all how are you? We need to insert data from MULTI-SELECT LOOKUP in a email template, but I can't do that, when I'm creating the template I can't find the field to insert it. is there any solution? PVU
                                                                                                        • What’s New in Zoho Inventory | April 2025

                                                                                                          Hello users, April has been a big month in Zoho Inventory! We’ve rolled out powerful new features to help you streamline production, optimise stock management, and tailor your workflows. While several updates bring helpful enhancements, three major additions
                                                                                                        • 請求書に添付されているファイルをAPI経由で取得する際の問題について

                                                                                                          Books APIリファレンス 現在、Books APIを利用して請求書内の添付ファイルを取得するメソッドを構築しています。以下のコードを参考にしているのですが、添付ファイルが複数アップロードされている場合、responseにおいて2つ目のファイルの情報しか取得できない現象が発生しています。 headers_data = Map(); headers_data.put("Authorization", "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f");
                                                                                                        • Custom Function : Copy multilookup field to text field

                                                                                                          Hi, I'm a newbie on function programming, I try to copy text from a multi lookup field named "societe" to a text field named "societe2". I've used this code. In deluge script it seems to work, but when I trigger this function it doesn't work (Societe2
                                                                                                        • Save Draft in email bigin for desktop and mobile

                                                                                                          Hi any news to when we going to have the save draft for email in bigin desktop and mobile?
                                                                                                        • Zoho books and venmo

                                                                                                          Hi, Is there a way to hook Venmo into zoho books? I have a Venmo business account and want to be able to sync that. I know you can do it with the paypal integration but I dont want to use paypal for the fees and that doesnt allow me use/integrate my current
                                                                                                        • Add Pinned Tickets to top of queue

                                                                                                          As an IT Helpdesk, we have some tickets where they will need to be looked at daily over a week or 2, and the ability to pin a ticket to the front/top of the queue would be handy as we can be reminded to take a look, rather than placing them on hold and
                                                                                                        • I can't found API for Sales Receipts

                                                                                                          Hello May you please help me to find an API document for Sales Receipts to get data and retrive a custom fields like Invoice and credit notes Regards
                                                                                                        • Create custom field using API.

                                                                                                          Hi Zoho Support, can we create the custom field using Zoho API? Thanks, Parth Moderation Update: I'm locking this post as the feature has now been implemented. Please refer to the help link provided in the comment below.
                                                                                                        • Pipeline in Custom Modules

                                                                                                          I love the way the Sales Pipeline looks and functions with reports. I would like to add the save pipeline features and visualization to a custom module, however, I only see that these pipelines are only available for the Deals module. Is there a way to add pipelines to custom modules?
                                                                                                        • I don't really understand leads in the campaigns tab on Zoho CRM

                                                                                                          Good morning, fellow CRM users. I am having quite a hard time understanding the leads in the campaigns tab. In this particular campaign in the screenshot below, we sent out emails to our mailing leads through Zoho Campaigns, and the data is linked back
                                                                                                        • Attention API Users: Upcoming Support for Renaming System Fields

                                                                                                          Hello all! We are excited to announce an upcoming enhancement in Zoho CRM: support for renaming system-defined fields! Current Behavior Currently, system-defined fields returned by the GET - Fields Metadata API have display_label and field_label properties
                                                                                                        • Assistance with Bulk Contact Import in Zoho Email Campaign

                                                                                                          I’m currently in the process of importing the Supermarkets customer list from Zoho Accounts into Zoho Email Campaigns. During the import, I’m being prompted to complete the "field mapping" section, but I’m unsure how to properly configure it to ensure
                                                                                                        • what is the header code and footer code, do you provide it for my website

                                                                                                          I am unable to understand few terms in making website, i need your help in header code, footer code, face book pixel integration etc..
                                                                                                        • Zoho DataPrep

                                                                                                          Zoho DataPrep is not updating the dataset. I post the updated dataset in Zoho WorkDrive under the same file name. (I delete the old file and upload the updated file with the same filename.) Zoho DataPrep is supposed to pull the dataset from Zoho WorkDrive,
                                                                                                        • Zoho Assist Unattended Access prevent my Windows 10 Pro business computers to sleep (ever)!

                                                                                                          Since I begin my trial period of Zoho Assist (Unattended Access) for business, I have sleep mode issues on all my business computer. In fact none of the sleep delay worked or even if I manually click the "Sleep" button into the Start Menu... After using the "powercfg -requests" command from Microsoft to troubleshoot sleep issues, I see that Zoho was responsible to all my sleep issues. Of course after uninstalling Zoho Assist Unattended Access from my test computer, the sleep mode returned to normal
                                                                                                        • Next Page