Automation #15: Automatically Adding Static Secondary Contacts

Automation #15: Automatically Adding Static Secondary Contacts



Rockel is a top-tier client of Zylker traders. Marcus handles communications with Rockel and would like to add Terence, the CTO of Zylker traders to the email conversations. In this case, the emails coming from user address rockel.com should have Terence looped in automatically as the secondary contact.

Like Zylker, many users have the requirement to include secondary contacts while communicating with their customers. Here's for you the custom function to automatically add static secondary contacts while responding to an email.

Prerequisite
1. Enable Secondary Contacts (CCs) in Tickets
Navigate to Setup >> Customization >> General Settings >> Tickets >> Secondary Contacts (CCs) in Tickets >> Configure(If not enabled) or Edit Configuration(If enabled), select the department to which you want to implement the automation.


2. Create a Connection
To establish a connection, perform the following steps:

      2.1 Go to
Setup and choose Connections under Developer Space.
      2.2 Click
Create Connection.
      2.3 Select
Zoho OAuth under Default Connection.
      2.4 Give the connection name as
secondarycontact.
      2.5 Under
Scope choose the below scope values:
            Desk.search.READ
            Desk.tickets.READ
            Desk.tickets.UPDATE
            Desk.contacts.READ
            Desk.contacts.UPDATE
      2.6 Click Create and Connect.
      2.7 Click
Connect and click Accept.
Connection is created successfully.

Create a Workflow Rule
1. Go to Setup, choose Workflows under Automation.
2. Under Workflows, click Rules >> Create Rule.
In the Basic Information section
3. Select Tickets under Module.
4. Enter a Rule Name and Description for the rule.
5. To activate the rule, select the Active checkbox. Click Next.
In the Execute on section, follow these steps:
6. Select Create checkbox to execute this rule every time a new ticket is created. Click Next.
7. In the Criteria section, specify the criteria as "Email contains @zylker.com" and click Next.
8. In the Actions section, click the + icon and select New next to Custom Functions.
9. Enter a name and description for the custom function.                 
10. In the script window, insert the Custom Function given below:
  1. //--------------- User Input -----------------
  2. Email = "STATIC_EMAIL_ID"; // Static email ID
  3. deskURL = "https://desk.zoho.com";
  4. //-----------------------------------------------
  5. logs = Collection();
  6. secondaryContacts = list();
  7. ticketDetails = zoho.desk.getRecordById(orgId, "tickets", ticketId, "secondarycontact");
  8. logs.insert("ticketDetails": ticketDetails);
  9. secondaryCC = ticketDetails.get("secondaryContacts");
  10. if (secondaryCC != "" && secondaryCC != null)
  11. {
  12. secondaryContacts = secondaryCC.toList(",");
  13. }
  14. searchParam = Map();
  15. searchParam.put("from", 0);
  16. searchParam.put("limit", 1);
  17. field1 = "email:" + Email;
  18. encryptEmail = zoho.encryption.urlEncode(field1);
  19. searchParam.put("field1", encryptEmail);
  20. contactSearch = invokeurl
  21. [
  22. url: deskURL + "/api/v1/contacts/fieldSearch"
  23. type: GET
  24. parameters: searchParam
  25. connection: "secondarycontact"
  26. ];
  27. logs.insert("contactSearch": contactSearch);
  28. if(contactSearch != null && contactSearch.get("data") != null && contactSearch.get("data").size() > 0)
  29. {
  30. contactId = contactSearch.get("data").get(0).get("id");
  31. }
  32. else
  33. {
  34. createConatctParam = Map();
  35. lastName = Email.getPrefixIgnoreCase("@");
  36. createConatctParam.put("lastName", lastName);
  37. createConatctParam.put("email", Email);
  38. createContact = invokeurl
  39.     [
  40.      url: deskURL + "/api/v1/contacts"
  41.      type: POST
  42.      parameters: createConatctParam.toString()
  43.      connection: "secondarycontact"
  44.     ];
  45. logs.insert("createContact": createContact);
  46. contactId = createContact.get("id");
  47. }
  48. logs.insert("contactId": contactId);
  49. if(contactId != null && contactId != ticketContactId)
  50. {
  51. secondaryContacts.add(contactId);
  52. updateParam = Map();
  53. updateParam.put("secondaryContacts", secondaryContacts);
  54. updateTicket = invokeurl
  55.     [
  56.         url: deskURL + "/api/v1/tickets/" + ticketId
  57.         type: PATCH
  58.         parameters: updateParam.toString()
  59.         connection: "secondarycontact"
  60.     ];
  61. logs.insert("updateTicket": updateTicket);
  62. }
  63. info logs ;
Note: In Line 1 Email = "STATIC_EMAIL_ID", replace the "STATIC_EMAIL_ID" with the email address you prefer to be added in the secondary contact automatically. eg:  Email = "terence@zylker.com"
11. Click Edit Arguments and include the argument mapping as below: 
11.1 In the Name field type ticketId, and from the Value drop-down list select Ticket Id under Ticket Information.
11.2 In the Name field type ticketContactId, and from the Value drop-down list select Contact Id under Contacts Information.
11.3 In the Name field type orgId, and from the Value drop-down list select specify custom value and enter your Zoho Desk. OrgId. To  get Zoho Desk OrgId, navigate to Setup >> Developer Space >> API.  
12. Click Save to save the custom function
13. Click Save again to save the workflow.

We hope this custom function fosters your experience with Zoho Desk. Stay tuned for regular updates and insights on our automation features in this space.

    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      • Sticky Posts

      • Zoho Desk Virtual Meetup: US Central, October 5 - 7, 2021

        After the interactive Virtual Meetups in the other regions, we are starting with the US Central and Midwest regions from October 5 to October 7, 2021. The dates for other regions will be announced soon.  At this event, we will explore the topics which
      • Register for Zoho Desk Beta Community

        With the start of the year, we have decided to take a small step in making the life of our customers a little easier. We now have easy access to all our upcoming features and a faster way to request for beta access. We open betas for some of our features
      • Ask the Experts 10: A 5-hour online Q&A on Zoho Desk Best Practices

        Welcome to Zoho Desk's Ask the Experts session! This is a monthly discussion on our  forums; wherein a panel of experts will take on questions  specific to topics related to Zoho Desk. The panel will be available for a 5-hour period and will answer any questions posted here.   Let's begin the year learning some best practices from our experts. In this month's ATE we are opening the floor to questions on how to use Zoho Desk the best way.  If you have a business use case but not sure if Workflow is
      • Share your Zoho Desk story with us!

        Tell us how you use Zoho Desk for your business and inspire others with your story. Be it a simple workflow rule that helps you navigate complex processes or a macro that saves your team a lot of time; share it here and help the community learn and grow with shared knowledge. 
      • Ask the Experts 7: A 5-hour online Q&A on Telephony and Call Module

        Welcome to Ask the Experts session! This is a monthly discussion in forums; each session, a panel of experts will take questions on specific topics related to Zoho Desk. The panel will be available for a 5-hour period and answer any questions posted here. In this month's Ask the Experts, we will take questions on everything related to Telephony and the Call Module in Zoho Desk. We will discuss the following aspects:  Integration with different Telephony vendors Routing calls to agents Converting

      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 Campaigns 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 コンテンツ




                              ご検討中の方