Auto assignment of tickets to an agent in Zoho Desk based on Account owner in Zoho CRM

Auto assignment of tickets to an agent in Zoho Desk based on Account owner in Zoho CRM

Hello everyone!

I have written a custom function in Zoho Desk to automatically assign a ticket to an agent in Zoho Desk based on the account owner in Zoho CRM when a new ticket is created in Zoho Desk. I hope this helps who need it.

You must create a workflow to automate this. To create a workflow, follow below steps.

Step 1: Basic Information
  1. Click the Setup icon in the top bar.
  2. In the Setup Landing page, click Workflows under Automation.
  3. In the Workflows List page, click Create Rule in the upper-right area.
  1. In the New Workflow page, do the following:
  2. Select the Ticket module.
  3. Enter the Rule Name.
  4. Select the Active checkbox.
  5. Enter the Description for the workflow rule.
  6. Click Next.
Step 2: Execute On
  1. In the Execute On section, select Create.
  2. Click Next.

Part 3: Actions
  1. Under Actions, click the Add Custom Function icon and select an New custom function.
  1. Enter function Name.
  2. Click on Edit Arguments and enter argument name ticketId and select value Ticket Id.
  3. Click Done.

Pre-requisites:

1. Create connection in Zoho Desk with following scopes for Zoho CRM service
      ZohoCRM.modules.contacts.READ, ZohoSearch.securesearch.READ
2. Create connection in Zoho Desk with following scopes for Zoho Desk service
      Desk.settings.READ, Desk.basic.READ

Paste below code in editor. Replace orgId with your org ID.
  1. orgId = 123456789; // organization ID. Replace it with your Org Id.
  2. ticketRecord = zoho.desk.getRecordById(orgId,"tickets",ticketId); //  ticketId to be mapped as an argument
  3. contactEmail = ticketRecord.get("email"); //extracts the contact person's email ID from the ticket record
  4. departmentId = ticketRecord.get("departmentId"); //extracts department id from the ticket record
  5. // search for a matching contact in Zoho CRM
  6. contactSearchResponse = invokeurl
  7. [
  8. url : "https://www.zohoapis.com/crm/v6/Contacts/search?email=" + contactEmail
  9. type : GET
  10. connection: "zcrm"
  11. ];
  12. // checks if a matching contact is found in Zoho CRM by checking the size of the response data
  13. if(contactSearchResponse.get("data").size() > 0)
  14. {
  15. data = contactSearchResponse.get("data").get(0);
  16. contactOwnerEmail = data.get("Owner").get("email"); // extracts the contact owner's email ID
  17. accountRecord = zoho.crm.getRecordById("Accounts", data.get("Account_Name").get("id"));
  18. contactOwnerId = data.get("Owner").get("id");
  19. accountOwnerId = accountRecord.get("Owner").get("id");
  20. //contact owner's ID and account owner's ID are compared to check if they are the same
  21. //If the contact owner and account owner are the same, search for a matching agent in Zoho Desk
  22. if ( contactOwnerId == accountOwnerId )
  23. {
  24. headerMap = Map();
  25. headerMap.put("orgId",orgId);
  26. agentSearchResponse = invokeurl
  27. [
  28. url : "https://desk.zoho.com/api/v1/agents/email/" + contactOwnerEmail
  29. type : GET
  30. headers: headerMap
  31. connection: "zdesk"
  32. ];
  33. agentId = agentSearchResponse.get("id");
  34. departmentList = agentSearchResponse.get("associatedDepartmentIds");
  35. // check if the matching agent has access to the department associated with the ticket
  36. // If the agent has access to the department, assign the ticket to the agent
  37. if(departmentList.contains(departmentId) == true)
  38. {
  39. agentMap = Map();
  40. agentMap.put("assigneeId",agentId);
  41. agent = agentMap.toString();
  42. ticketResponse = invokeurl
  43. [
  44. url : "https://desk.zoho.com/api/v1/tickets/" + ticketId
  45. type : PUT
  46. parameters: agent
  47. headers: headerMap
  48. connection: "zdesk"
  49. ];
  50. }
  51. }
  52. }
Best Regards,
Subhash Kumar

      Zoho Campaigns Resources


        • Desk Community Learning Series


        • Digest


        • Functions


        • Meetups


        • Kbase


        • Resources


        • Glossary


        • Desk Marketplace


        • MVP Corner


        • Word of the Day


        • Ask the Experts


          • Sticky Posts

          • 2024 Email Authentication Standards: Elevating Security with Google and Yahoo

            In contemporary email communication, email authentication plays a pivotal role in mitigating email fraud, spam, and phishing attacks. Brace yourself for a new level of security. Starting February 2024, Gmail and Yahoo will be implementing robust email
          • Using Agent Email Address as From Address

            Currently, while replying to a ticket, it is possible for agents to choose their own email addresses as 'from' addresses. Although we built this just for that little extra flexibility, in hindsight, it hasn't figured much in conventional usage.  Almost all businesses prefer that responses to their customers' tickets be sent from the common support/service email address and NOT from those of individual agents. During personal interactions at events, some of you have even made passing mentions about
          • Edit and Delete options in Comments

            A lot of teams have been using ticket comments extensively to collaborate everyday. Notification Center further improved this experience by bringing real-time updates. As we continue to build more improvements to this experience, we've shipped a small-yet-important
          • Webinar 2: Supercharged customer support for growing business

            Join us for this webinar and learn how to step up your support game using a real-time communication platform to generate happier, more successful customers. In this live webinar, we will will discuss the importance of SalesIQ for your support team and how it can help you:  Understand your customers better and their journeys to proactively support and engage them even before they ask for help.  Integrating real time conversations into Zoho Desk’s Support, providing a conversational customer service
          • Customize Colors of your Customer Self Service Portal

            You asked for it. We heard you. We're happy to roll out the most sought after feature request, Customizing the Colors of your Customer Self-service Portal. Now you can set the color of your customer portal to mimic your company's web site, so that your customers visiting the portal will not feel alienated by the default theme.  Go ahead and configure the color of the header, tabs, fonts and background according to your needs. You can either choose between default color themes like Blue, Grey, Green

          Zoho CRM Plus Resources

            Zoho Books Resources


              Zoho Subscriptions Resources

                Zoho Projects Resources


                  Zoho Sprints Resources


                    Zoho Orchestly Resources


                      Zoho Creator Resources


                        Zoho WorkDrive Resources



                          Zoho CRM Resources

                          • CRM Community Learning Series

                            CRM Community Learning Series


                          • Tips

                            Tips

                          • Functions

                            Functions

                          • Meetups

                            Meetups

                          • Kbase

                            Kbase

                          • Resources

                            Resources

                          • Digest

                            Digest

                          • CRM Marketplace

                            CRM Marketplace

                          • MVP Corner

                            MVP Corner




                            Zoho Writer Writer

                            Get Started. Write Away!

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

                              Zoho CRM コンテンツ




                                ご検討中の方

                                  • Recent Topics

                                  • scope for phonebridge in CRM and phonebridge API documentation

                                    Hi I cannot find the scope to be used for phonebridge in CRM API V2 calls. I am getting OAUTH_SCOPE_MISMATCH for scope group ZohoCRM.modules.ALL,ZohoCRM.setttings.ALL Also I am not able to locate the documentation for the same, All I have is phonebridge
                                  • 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
                                  • Job Alerts for Candidates

                                    hi All, I have 2 questions relating to sharing job details with candidates. 1. is there a way to notify candidates that meet certain criteria of current jobs available? eg. I run a candidate search, and identify 50 candidates that might be suitable. Can
                                  • Zoho Wiki or new Zoho Learn

                                    We are currently evaluating if we should move off confluence. At present in Confluence we have multiple levels within our documentation but with learn it looks like you can only have Space       - Manual             - Chapter Is it possible to have levels below Chapter? Also the same question for the existing wiki, can I have more sub-levels?
                                  • Fix image at bottom of a page fot automatic proposal creation

                                    I'm working on a proposal document to automate our proposal creation process. So far it works fine, but I experience some problems with an image I want to have fixed at the bottom of the page AND above the footer. This section of the document consists
                                  • Can't scroll the page down unless I refresh the page

                                    Hello, This issue has been going on with me and a lot of other users in my organization, we can't scroll down! the scrolling side bar doesn't appear and scrolling down through mouse or keyboard keys doesn't work, it seems that the page just ends in the
                                  • Price List

                                    II want to restrict the items to display in sales, quote, etc for which custom rates are added in price list. How I can do the same in Zoho books
                                  • Let’s Talk Recruit: Still switching tabs to source?

                                    Welcome back to the Let’s Talk Recruit series. Let’s talk about how you actually source talent. Do you open multiple job boards every single time a role opens? Run the same keyword searches you ran yesterday? Download, upload, rename, and then do it again
                                  • Kaizen #231 - Embedding Zoho Desk Tickets in Zoho CRM

                                    Hello, CRM Wizards! This week, let us enhance cross-team visibility between Zoho CRM and Zoho Desk. We will use the Zoho Request Client inside a Related List widget to display open Zoho Desk tickets directly within the Contact record in Zoho CRM. This
                                  • EU Problem

                                    Hi all, we've been facing issues with the Europe data center for two days. It's starting to disrupt our daily workflow. Any word on when this will be resolved?
                                  • Introducing a smarter, faster, and more flexible charting experience

                                    Hello Zoho Sheet users, We're delighted to share the latest news about a major update to charts in Zoho Sheet! The new version supports dynamic data ranges, granular styling options, faster loading, and other interesting enhancements that allow you to
                                  • Introducing Job Alerts

                                    Keeping candidates engaged beyond their first application is one of the most consistent hiring challenges. Many interested candidates simply do not revisit career sites regularly, which can result in missed opportunities and reduced re-applications. To
                                  • Where is the settings option in zoho writer?

                                    hi, my zoho writer on windows has menu fonts too large. where do i find the settings to change this option? my screen resolution is correct and other apps/softwares in windows have no issues. regards
                                  • Client Script | Update - Client Script Support For Custom Buttons

                                    Hello everyone! We are excited to announce one of the most requested features - Client Script support for Custom Buttons. This enhancement lets you run custom logic on button actions, giving you greater flexibility and control over your user interactions.
                                  • Enhance Sign CRM integration

                                    Hello all, I'm working on a custom Deluge script to enhance the integration between Zoho CRM and Sign by using a writer merge template for additional flexibility. I want to replicate the post-sign document integration that exists between CRM and Sign
                                  • Task status - completed - other options

                                    I have a dumb question I know i can make custom statuses for the tasks - but is there anyway to make additional "completed" statuses like for instance if i have a task "call back customer" and i leave a vm for them to call back marking it "completed -
                                  • Bank feed integration First Abu Dhabi Bank (FAB) to Zoho? (UAE)

                                    Hello everyone, Is First Abu Dhabi Bank in the list of banks available for bank feed integration with Zoho Books? Thank you.
                                  • How to Export Filtered List of Contacts?

                                    This seems like it should be simple, but I'm stymied. I'm trying to export a filtered list of my Contacts for analysis in a spreadsheet. The use case is that I'm an ecom business based in the US. The bulk of our customers are individuals stored as Contacts.
                                  • Possible to Turn Off Automatic Notifications for Approvals?

                                    Hello, This is another question regarding the approval process. First a bit of background: Each of our accounts is assigned a rank based on potential sales. In Zoho, the account rank field is a drop-down with the 5 rank levels and is located on the account
                                  • Quick Create needs Client Script support

                                    As per the title. We need client scripts to apply at a Quick Create level. We enforce logic on the form to ensure data quality, automate field values, etc. However, all this is lost when a user attempts a "Quick Create". It is disappointing because, from
                                  • can we add product images in Zoho CRM Quote PDF template?

                                    I want to create a quotation format in Zoho CRM similar to the attached PDF, where each product is displayed in a table with rpoduct image I need the product image to appear inside the line items section of the quote. However, while checking the Quote
                                  • Does Zoho Writer have Dropdowns

                                    I want to add a drop down field in Zoho writer. Is this possible?
                                  • system not picking my default custom service report template

                                    Can you tell me why when we create a service report always pick the (standard old) template? Even when I have a custom service report selected as Default.
                                  • Facturation électronique 2026 - obligation dès le 1er septembre 2026

                                    Bonjour, Je me permets de réagir à divers posts publiés ici et là concernant le projet de E-Invoicing, dans le cadre de la facturation électronique prévue très prochainement. Dans le cadre du passage à la facturation électronique pour les entreprises,
                                  • Connecting Multiple WooCommerce Stores to a Single Zoho Marketing Automation Account

                                    Is it possible to connect multiple WooCommerce stores to a single Zoho Marketing Automation account?
                                  • Service Title in Service Report Template Builder

                                    I am currently working on the Service Report Template Builder in Zoho FSM. I have created three separate service report templates for different workflows: Preventive Maintenance Report Requested Service Report Installation Report My issue is that I cannot
                                  • One Support Email Managed By Multiple Departments

                                    Hello,  We use one support email (support@company.com). Incoming emails come to the "Support Department" and based on what the customer is asking, we route that ticket to different departments (billing, technical support, etc.). When users in these different
                                  • Update: New Security Admin Role

                                    Hello Zoho Directory Admins! This post is to highlight the recent role and permission changes introduced as part of the security enhancements. Previously, Helpdesk Admins had the security permissions and were responsible for managing the security configurations
                                  • Client Script | Update #14 - Client Script Support for Quick Create

                                    Hello Everyone! We are back with another exciting and highly awaited update in Client Script! Over the past months, many of you shared your insights and requests, asking for the power to extend Client Script functionality to Quick Create forms. This capability
                                  • Empty folders are now appearing in the sidebar...

                                    ...and the folder list is now auto-collapsed by default with no way to change. Neither of these recent updates are useful or user-friendly. ==================== Powered by Haiku https://www.haiku.co.uk ====================
                                  • Does Zoho has chatroom/chatbot url feature?

                                    Hi Zoho community! I’m looking for a quick "Yes/No" answer for my dev team regarding Zoho’s capabilities. We currently use Zoho Desk for our Service Team and Zoho CRM for our Marketing Team to bring both functions under one platform. Our question: Does
                                  • Upload from Zoho Creator File Upload field to OpenAI Vector Store

                                    I’ve struggled for quite a while to get this working properly. For a long time we relied on Azure Functions as a workaround to handle file transfers between Zoho Creator and OpenAI Vector Stores. It worked, but added unnecessary infrastructure and complexity.
                                  • Career site URL - Suggestion to modify URL of non-english job posting

                                    Hi, I would like to suggest making a few modification to career sites that are not in english. Currently, the URL are a mix of different languages and are very long. It makes for very unprofessional looking URLs... Here is an example of one of our URL
                                  • I'd like to suggest a feature enhancement for SalesIQ that would greatly improve the user experience across different channels.

                                    Hello Zoho Team, Current Limitation: When I enable the pre-chat form under Brands > Flow Controls to collect the visitor’s name and email, it gets applied globally across all channels, including WhatsApp, Messenger, and Instagram. This doesn't quite align
                                  • The Social Playbook - February edition: Why moment marketing works (and how brands use it)

                                    Imagine the final season of your favorite series is about to drop. Your entire feed is talking about it. Trailers everywhere. Fan theories. Hype at 100%. Now your go-to burger place launches a limited-edition meal box themed around that series—custom
                                  • PDF Attachment Option for Service Reports

                                    Hello Team, I would like to check with you all if there is an option to attach PDF documents to the service reports. When I try to attach a file, the system only allows the following formats: JPEG, JPG, and PNG. Could you please confirm whether PDF attachments
                                  • Manage Every Customer Conversation from Every Channel inside Zoho SalesIQ

                                    Your customers message you from everywhere. But are you really able to track, manage, and follow through on every conversation, without missing anything? With interactions coming in from websites, mobile apps, and messaging platforms like WhatsApp and
                                  • Approvals in Zoho Creator

                                    Hi, This is Surya, in one of  my creator application I have a form called job posting, and I created an approval process for that form. When a user submits that form the record directly adding to that form's report, even it is in the review for approval.
                                  • 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
                                  • Depositing funds to account

                                    Hello, I have been using Quickbooks for many years but am considering moving to Zoho Books so I am currently running through various workflows and am working on the Invoicing aspect. In QB, the process is to create an invoice, receive payment and then
                                  • Next Page