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

                                                          • 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
                                                          • Let's build a dashboard with Cliq Widgets!

                                                            While juggling multiple tasks and tracking real-time data, you face a strict deadline for delivering a quarterly analysis report on a blank canvas while switching between different apps. Sounds exhausting, right? What if you could streamline everything
                                                          • 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


                                                          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

                                                                                                          • Sum Total of various fields in child module and add value to parent module field

                                                                                                            Hi! Having trouble with a custom function, im trying to calculate the total of all the rent and sqm fields of our offices in Products module and have them transfer to the parent module Location. The API names are as below: Child module Products = "Products"
                                                                                                          • GCLID arrives not in CRM with iframe integrated ZOHO Form

                                                                                                            Hello amazing community, I enabled Adwords integration in ZOHO CRM. I have a ZOHO Form integrated in a wordpress. I tested iframe and Javascript. I enabled the "handover" GCLID in the ZOHO Form. When I add a GLID with http://www.example.com/?gclid=TeSter-123.
                                                                                                          • Sending Recruit SMS's to Zoho Cliq - Or tracking in the Messages module in Recruit?

                                                                                                            Is there any way to send SMS Gateway messages in Recruit to ZOho Cliq? We use 2-way SMS massages a lot in Zoho Recruit to speed up communication with Candidates. However the only way to keep track of received SMS's is by keeping a look out for the Email
                                                                                                          • Feature Request - Insert URL Links in Folders

                                                                                                            I would love to see the ability to create simple URL links with titles in WorkDrive. or perhaps a WorkDrive extension to allow it. Example use case: A team is working on a project and there is project folder in WordDrive. The team uses LucidChart to create
                                                                                                          • Allowing workflows to execute as an admin

                                                                                                            Workflows currently seem to execute with the permissions of the logged in user. This is a problem for most of the forms we have where we have hidden fields that perform business logic. If we restrict the permissions of these fields so users can't view
                                                                                                          • How to validate Rich Text in Zoho Creator! Urgent!

                                                                                                            Hi members, Recently I just started to use Rich Text field. Now I have a requirement where I need to validate to ensure this Rich Text field must contain a value. Meaning must contain something. I use the below script if(input.Rich_Text == null) { alert
                                                                                                          • Custom Function to Format Phone / Mobile numbers in Australian Standard format

                                                                                                            So I got sick of phone numbers being formatted incorrectly and Zoho not doing anything to standardise phone numbers to meet E.164 formats. So I went and coded my own function to fix this. And figured I'd share with the community This is specifically for
                                                                                                          • Add Lookup Field in Tasks Module

                                                                                                            Hello, I have a need to add a Lookup field in addition to the ones that are already there in the Tasks module. I've seen this thread and so understand that the reason lookup fields may not be part of it is that there are already links to the tables (https://help.zoho.com/portal/en/community/topic/custom-fields-on-task-module).
                                                                                                          • Group Emails

                                                                                                            I have synced Zoho CRM to Campaigns but there are certain email not synced. showing it is Group Emails, but this email ids belongs to different individuals. please provide a solution as i nedd to sync the same.
                                                                                                          • How to modify query from a DataBridge Connection

                                                                                                            Hello, I just installed the new DataBridge tool to import data to our Zoho Analytycs account from our local database. It works well so far, and data gets sync every day. The only issue that I found is that we do not know how to modify the query that imports
                                                                                                          • Is there a way to force a page refresh after changing a Subform via Workflow / Function?

                                                                                                            I have a workflow which triggers a function, and in this function i am changing the values of a certain subform. The changed are only visibile when i manually refresh the page and this is a no-no for my use-case. When other workflows, that change certain
                                                                                                          • Unable to invite contacts

                                                                                                            Hi! I'm unable to invite contacts as end-users from my trial account. The green pop-up displays "Invited succesfully" but the email never arrives, nor the re-invitation - even though it's "sucessfully" as well. Tried with several e-mail accounts, even
                                                                                                          • Enable Full Theme Editor for Help Center (Disable Express Builder)

                                                                                                            Dear Zoho Support, We are currently using the Elegant theme in Zoho Desk Help Center, but we only have access to the limited Express Builder. We would like to switch to the full Theme Editor to be able to: Access Language Strings Edit all pages (HTML/CSS/JS)
                                                                                                          • Introducing Assemblies and Kits in Zoho Inventory

                                                                                                            Hello customers, We’re excited to share a major revamp to Zoho Inventory that brings both clarity and flexibility to your inventory management experience! Presenting Assemblies and Kits We’re thrilled to introduce Assemblies and Kits, which replaces the
                                                                                                          • Zoho Desk - account and contact lookup by phone

                                                                                                            Hi team, Does Zoho Desk allow to lookup Accounts and Contacts by phone or not? I am using this endpoint- GET https://desk.zoho.eu/api/v1/accounts/search?phone=987-654-3210 But I am getting this error- { "errorCode": "UNPROCESSABLE_ENTITY", "message":
                                                                                                          • Add picklist in subform lookup

                                                                                                            Hello, I am trying to rewrite a script that works on a from as parent form, to the same form when is is a subform. Here is what I did in the form itself : RefCat = Offre_de_produits.distinct(Categorie_OFFRE); clear Categorie_LIGNE; for each Record in
                                                                                                          • Way to export / import a Flow between different accounts?

                                                                                                            Hi, I developped some flows in my account and see that for some other organisation I'm working with, they would need the same or similar flows. Is there a way for me to export one flow from one account and import it to another ? This would be handy, as
                                                                                                          • Setting admin only field values in widget

                                                                                                            Hello If I'm using a Widget addRecord function invoked by a user input (the user has write permission not developer) can he set values to a field that is set to be visible to Admin only?
                                                                                                          • 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.
                                                                                                          • Option to Delete Chats in IM

                                                                                                            Currently, there is no option to delete any chats in IM, regardless of their source.
                                                                                                          • Installing EMAIL Setup in New Domain

                                                                                                            Respected Support team, I'm facing an issue with cloudflare in Pakistan, I want to setup Zoho Mail Setup but I Don't know how to enable Zoho mail setup without cloudflare. My Website https://stumbleguymod.com/ is using CF, and I want a different Zoho
                                                                                                          • Stop completed task lists from disappearing?

                                                                                                            Is there any way to stop projects from making tasks lists disappear when all the tasks in the list are completed? That's one of those little things where we're constantly fighting the product. For instance we have some projects which are ongoing - no start and end date. We use Kanban view to show the various task lists. We don't want the kanban list to disappear every time the items on it happen to be closed out. Thanks
                                                                                                          • Adding Coloured Picklist Based On Email Body Text

                                                                                                            Hey All, So i am having this problem, Im currently trying to automate a coloured picklist so that when the body of an email contains a specific word it will assign one of my coloured picklist i have created automatically, But it appears this only works
                                                                                                          • Automation #11 - Auto Update Custom Fields with Values from Emails

                                                                                                            This is a monthly series designed to help you get the best out of Desk. We take our cue from what's being discussed or asked about the most in our community. Then we find the right use cases that specifically highlight solutions, ideas and tips to optimize
                                                                                                          • Email notification for followers

                                                                                                            Is there a way to enable email notification for followers of a support ticket? ie: Ticket #123 is owned by Agent#1, Agent#2 adds themselves as a follower. Whenever ticket #123 receives an email from the customer, Agent#1 receives an email. Agent#2 would
                                                                                                          • Unified WhatsApp Number Management in Zoho Desk and SalesIQ

                                                                                                            Dear Zoho Desk Support Team, We are currently utilizing both Zoho Desk and Zoho SalesIQ for our customer support operations. While both platforms offer WhatsApp integration, we are facing challenges due to the requirement of separate WhatsApp numbers
                                                                                                          • Zoho Desk is extremely slow

                                                                                                            Hi Team, We are facing extreme latency issue with Zoho Desk. It is currently unusable. I have submitted a ticket already could you please look into this asap. Regards, Priya Sharna
                                                                                                          • Zoho Desk is extremeley Slow

                                                                                                            Hi, Zoho Desk seems to be extremely slow for the last 15 mins for everyone in our team (5 people). https://status.zohocloud.ca/ didn't show any status in this regard. Would it be possible to have an idea what is happening and when this should be resolved?
                                                                                                          • Help Centre - Widget or Tab for Customer Downloads

                                                                                                            USE CASE: We are a software vendor, using Zoho Desk (as part of a Zoho One subscription) to help mange support issues from our customer base. Customers can log tickets via email or Help Centre portal. QUESTION: I need to provide the capability for our
                                                                                                          • Integración Books para cumplir la ley Crea y Crece y Ley Antifraude (VeriFactu)

                                                                                                            Hola: En principio, en julio de 2025, entra en vigor la ley Crea y Crece y Ley Antifraude (VeriFactu). ¿Sabéis si Zoho va a cumplir con la ley para cumplir con la facturación electrónica conectada a Hacienda? Gracias
                                                                                                          • How to let only account-bound products visible to users

                                                                                                            Hello friends, I'm trying to leave only the Products linked to the accounts visible to Zoho Portal users. If the user clicks "All Products," they can open tickets incorrectly for products that do not belong to the account that are registered. Is it possible
                                                                                                          • Work Orders / Bundle Requests

                                                                                                            Zoho Inventory needs a work order / bundle request system. This record would be analogous to a purchase order in the purchasing workflow or a sales order in the sales cycle. It would be non-journaling, but it would reserve the appropriate inventory of
                                                                                                          • Try CRM for everyone button in the way of workflow

                                                                                                            Please consider using the bottom bar for offers. Using the top bar for offers like "Try CRM for everyone" really gets in the way of my day to day workflow.
                                                                                                          • Markdown for Desk?

                                                                                                            Hi, my company wants to use markdown for formatting text in Desk (in all modules there, especially Tickets and Helpcenter). Zoho already offers use of markdown in several products (see https://help.zoho.com/portal/en/kb/backstage/microsite-guide/formatting-with-markdown/articles/formatting-with-markdo)
                                                                                                          • Limits on workflow never disclosed, not documents and now being applied. I feel scammed and there is no reply for support.

                                                                                                            Hello everyone, I’m facing a critical issue with Zoho Recruit and would appreciate any insights from fellow users or someone from Zoho. For months, I’ve been receiving daily emails stating that I have reached the maximum workflow custom functions limit.
                                                                                                          • Variables in Zoho Mail Signatures defined by Administrator

                                                                                                            Good afternoon, I'm looking at the Admin component of Zoho Mail, and I see we have the capability to define signatures for end users. We also have the ability to associate with multiple email addresses. Are we able to use any variables such as [FirstName}
                                                                                                          • Invoice status on write-off is "Paid" - how do I change this to "Written off"

                                                                                                            HI guys, I want to write off a couple of outstanding invoices, but when I do this, the status of the invoices shows as "Paid". Clearly this is not the case and I need to be able to see that they are written off in the customer's history. Is there a way
                                                                                                          • report on lead status history in zoho crm

                                                                                                            I have enabled the lead status history. I want to understand how many days a lead is waiting in which stage and the number of leads vs. stage history, like 0 days, 1-4 days, 5 days above, and 10 days above.
                                                                                                          • Cannot send a Campaign. No Send or Proceed button

                                                                                                            I have built a Campaign. I had to drop Leads and only use Contacts because only one group can sync. But now I do not see any errors but I do not see anyway to proceed with sending the campaign?
                                                                                                          • Default Lookup Field Value based on Picklist

                                                                                                            How do I change a lookup field value based on another field's value, while creating/editing a record using form? I have a picklist of different types of Loans. For example: PPP, EDIL, Term, etc. When I create a record using the form, if I choose PPP from
                                                                                                          • Next Page