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
    • Sticky Posts

    • 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
    • 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
    • Recent Topics

    • How to Send Email from within a custom module (with or without an email template)

      It is possible to send an email from the Deals module. However, I can't find a way to send an email from any of our custom modules. I have tried adding an email field to the modules (even though we don't really want one or need it there). That doesn't
    • Can't upload attachments.

      I can't upload attachment in Zoho Mail.
    • Empowered Custom Views: Cross-Module Criteria Now Supported in Zoho CRM

      Hello everyone, We’re excited to introduce cross-module criteria support in custom views! Custom views provide personalized perspectives on your data and that you can save for future use. You can share these views with all users or specific individuals
    • Need Guidance on SPF Flattening for Zoho Mail Configuration

      Hi everyone, I'm hoping to get some advice on optimizing my SPF record for a Zoho Mail setup. I use Zoho Mail along with several other Zoho services, and as a result, my current SPF record has grown to include multiple include mechanisms. My Cloudflare
    • How use

      Good morning sir I tried Zoho Mail
    • Zoho Mail Desktop App Not Loading + Can’t Manage Multiple Accounts

      Hi everyone, I’ve been having ongoing issues with the Zoho Mail desktop app for the past few weeks. The app starts to load but gives up midway and never actually opens — there’s no error message, it just stops loading. The main reason I use the desktop
    • Unable to copy into a new document

      Whe I create a new Writer doc and attemp to copy and past I get this message. The only way to copy into a document is I duplicate an existing document, erase the text and save it under a different name and then paste the information. Not ideal. Can you
    • not able to convert pdf to jpg and other forms and vice versa.

      i want to change my pdf to jpg, word, etc and some times jpg to pdf. i don't know how to do in this.
    • Feature Request: Tag, Search, and Report on Individual Private Comments

      Zoho Desk Team, First, I want to say that we are extensive users of Zoho Desk and it is a core part of our support operations. We rely heavily on the private comments feature for internal communication, knowledge sharing, and maintaining a clear history
    • 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
    • Connecting two modules - phone number

      Hi, I’d like some guidance on setting up an automation in Zoho CRM that links records between the Leads module and a custom module called Customer_Records whenever the phone numbers match. Here’s what I’m trying to achieve: When a new Lead is created
    • Changing an agents email address

      How do you change an agent's email address? I keep getting a red circle even though I am an admin. And on one of my agents he has two email addresses? How is that possible?
    • Creator Change History: Ways to improve

      Hi Everyone, Recently been working in developing this change history(an idea from Zoho Forms) - unlike forms that you can this with a click but using Creator, we can use "old" keyword. The concept I come up with is to put the result in a table however,
    • 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
    • Error when sending emails from Zoho

      Hello, When trying to send an email from Zoho CRM I keep getting the below error: javax.mail.AuthenticationFailedException: 535 5.7.139 Authentication unsuccessful, the user credentials were incorrect. Any support on this will be much appreciated. Thanks,
    • Zoho Tables is now live in Australia & New Zealand!

      Hey everyone! We’ve got some great news to share — Zoho Tables is now officially available in the Australian Data Center serving users across Australia and New Zealand regions! Yes, it took us a bit longer to get here, but this version of Zoho Tables
    • Zoho Inventory - How to pay a supplier up front then receive multiple deliveries

      How do we manage situations where we pay a supplier up front, then the receive the products in increments? Example Workflow: Create Purchase Order > Receive Bill for full amount > Receive Items 2 or more deliveries. Currently, once a Bill is created against
    • Not all emails from outlook365 migrated to my new zoho account

      I recently setup a new email address hosted by zoho. I migrated all my folders and email from my Outlook365 account to my new zoho account, but not all my emails migrated. Looks like only the past 12 months, or so, made the move. How do I get the rest
    • Zoho Inventory - Composite Items - Assembly - Single Line Item Quantity of One

      Hi Zoho Inventory Team, Please consider relaxing the system rules which prevent an assembly items from consisting of a single line item and outputting a quantity of 1. A client I'm currently working with sells cosmetics and offers testers of their products
    • Clients not receiving emails

      I've been informed that my emails are not being received. Is there anything that I should look into to rectify this? Many thanks!
    • Allocating inventory to specific SO's

      Is there a way that allocate inventory to a specific sales order? For example, let's say we have 90 items in stock. Customer 1 orders 100 items. This allocates all 90 items to their order, and they have a back order for the remaining 10 items which could
    • Max numbr of IMAP Accounts in Zoho Mail?

      In Zoho mail, you can manage the inboxes of other accounts using IMAP (and POP, actually) https://www.zoho.com/mail/help/external-imap-accounts.html Is there a max to the number of inboxes we can add?
    • Formula Fields Trouble

      Hi,  I can't get even a simple formula field to work and must be doing something dumb. This formula: If(Len(Trim(${Quotes.Subject}))=0,1,2) Gives the error: You used the wrong type of data in an argument. Check what you entered between the parentheses of your functions to make sure you put the right kind of data in the right place. This formula: Len(Trim(${Quotes.Subject}))=0 Gives the error: Syntax Error. Check the examples for any functions you're using to see if you formatted them correctly. Make
    • OPTED FOR STORAGE BY DESCRIPTIVE MISGUIDANCE

      We've opened a domain with three mail ids and payment has also been processed now the bill raised is for single use ID with additional storage capacity. Kindly request you to modify the purchase.
    • How can I add a new organization on Zoho Campaign

      I want to create a new organization with my Zoho Campaign
    • White Label certificate

      Hi all, About 72 hours ago, we fulfilled all steps for white labeling (CNAME to point to mail.cs.zohohost.eu), but since then the configuration page is now stuck at "generating certificate" since 3 days. When I execute an NSLOOKUP mail.webfoundry.be it
    • Split my account

      Hello, I recently bought an email service for a friend. But, looks like I used my personal account to buy the plan. Please split the account so that the email service stays in a different account than my personal account.
    • Remote Server is misconfigured

      Dear Team, I am unable to use email id as remote server is misconfigured. It would be really great if you could help on this and get this resolved. Thanks & Regard Rohit Gupta
    • Have Mail Lite, wish to add/purchase 2nd domain and use email

      Hello, I have recently created two new businesses. I have successfully used Zoho to create a domain for one business and have set up two email addresses / users on that domain. I am trying to figure out how to create a second domain, just like I did the
    • Zoho Learn - AI Translate

      Hi Learn team, I had a situation today where I was providing training to a client team and I had written articles into their Zoho Learn to support their learning. I realised that one of the team members was a non-native English speaker and they were struggling
    • Need support in setting up the company email and few other setups

      Need support in setting up the company email and few other setups
    • This mobile number has been marked spam.

      Dear zoho team, I am very happy to use zoho,because it india 🇮🇳 own app, but when we login into zoho account we facing some issue, please solve below issue ASAP. Add your mobile number As an added security measure for Accounts, you need to verify and
    • Add an external email to the allowed list

      I need to allow an external email to raise a ticket on Manage Engine ServiceDesk Plus. The external email is a outside of our domain and is not a domain user. The email address that needs to be allowed to raise a ticket request is noreply@formsatack.com.
    • Display name & account type change

      I made a mistake and subscribed with an individual account instead of business, how can I change the account type and enter the details of the business. The other question, if I can't, then I want the display name of our email to be 'Business name' instead
    • Request to change display name in Zoho mail

      Hello Zoho Mail Support, I am experiencing an issue with changing the display name on my Zoho Mail account. My email address is: info@witchcraftproduction.rs . I have already updated the display name in Settings > Mail Accounts, where it now shows as
    • Outbound IP address SPAM problem.

      Hello Zoho Support, We noticed that one of your outbound IP addresses (136.143.188.12), which delivers our domain’s mail, is currently listed on the UCEProtect blacklist. Because of this, our messages are sometimes flagged as spam by recipient servers.
    • Answer Bot and Personalized Questions

      Hi there, I have the same problem using the SalesIQ Answer Bot and the Zoho Desk Answer Bot (which really need different names, to be honest, in order to avoid confusion...) Customers that visit our website ask questions in the form of "What do you do?"
    • Forwarding

      How can I forward my Zoho account to my gmail account? Noël
    • Kaizen #89 - Color Coding using Client Script

      Hello everyone! Welcome back to another exciting Kaizen post. Today let us see how you can apply color codes to the List and Detail Pages of Zoho CRM using Client Script. Need for color code in Zoho CRM When you mark things with different colors as a
    • Your bot just got smarter: AI-Powered routing that reads between the lines

      What if your bot could tell the difference? Between a visitor who just needs a quick answer, someone actively comparing options, and a frustrated customer one click away from leaving? Most bots can't. They deliver the same response to everyone, missing
    • Next Page