Want to categorize your tickets by topics as soon as an agent responds? Here's how…

Want to categorize your tickets by topics as soon as an agent responds? Here's how…

We really needed to group our Zoho Desk tickets to categories to analyze them in Zoho Analytics. This custom functions does it for you. Thanks to Zoho employee John and his colleagues who gave me the idea at Zoholics 2022 in Frankfurt.

This custom function is fired via a workflow every time there is an agent response.

  1. // Description: Fetches the topic of at ticket using a shortcode given from a template. Inserting the topic to the custom field cf_topic.
  2. // ticketID is given as an argument for this function

  3. // Inserting the Organisation ID:
  4. orgID = 2**********8;
  5. data = Collection();

  6. data.insert("#SC_GEN":"General");
  7. // +++++++++++++++++++++++++++++++++++
  8. // Insert your topic, e.g.:
  9. // data.insert("YOUR FIRST SHORTCODE":"YOUR FIRST TOPIC");
  10. // +++++++++++++++++++++++++++++++++++

  11. // Use the Shortcodes for the For-Loop:
  12. dataKeys = data.keys();

  13. // Get the latest agent reply as a thread:
  14. thread = zoho.desk.getRelatedRecords(orgID,"threads","tickets",ticketID,0,1);

  15. // Getting the HTML code of the latest reply
  16. replyID = thread.get("data").toString().get("id");
  17. reply = zoho.desk.getRelatedRecordById(orgID,"threads",replyID,"tickets",ticketID);
  18. replyText = reply.get("content");

  19. // Using foundKey as the resulting shortcode
  20. foundKey = null;

  21. for each  key in dataKeys
  22. {
  23. if(replyText.containsIgnoreCase(key))
  24. {
  25. foundKey = key;
  26. }
  27. }

  28. // Checking if shortcode was actually found
  29. if(foundKey != null)
  30. {
  31. foundValue = data.get(foundKey).toString();
  32. info "Found Value. Using: ";
  33. }
  34. else
  35. {
  36. info "Found no value.";
  37. }
  38. info foundValue;

  39. // Extracting the topic for the found shortcode
  40. customFieldsChild = Map();
  41. customFieldsChild.put("Topic",foundValue);
  42. customFieldsParent = Map();
  43. customFieldsParent.put("customFields",customFieldsChild);
  44. response = zoho.desk.update(orgID,"tickets",ticketID,customFieldsParent);

The prerequisite is that shortcodes are implemented in templates that stand for a topic. For example, we have inserted the string "#SC_DE_B2B" under the text of a ticket template and colored it white in order to be able to search for the text as a shortcode in the function. All B2B-regarding templates will contain this string and will result to the selection "B2B informations".

In addition, there is a "Topic" picklist in the ticket layout, in which the respective topics are stored.

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns 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