Sending Zoho CRM Email Templates Using Zoho Deluge

Sending Zoho CRM Email Templates Using Zoho Deluge

Overview:

Zoho CRM allows users to create Email Templates for sending standardised messages to multiple recipients. In some scenarios, users may wish to send these templates using Deluge through custom functions. This guide outlines the steps to send a Zoho CRM Email Template via Deluge.

Scenario:

Suppose you want to automatically send a Welcome Email Template whenever a new lead is created in Zoho CRM. This can be achieved by creating a Workflow Rule with a Custom Function that triggers the email template.

 

Configuration:

Workflow Rule Setup :

  1. Kindly navigate to setup > Automation > Workflow rules > Create rule.
  2. Select the Leads module and give a name along with the description.
    1. When: Select Record Action >> Create
    2. Condition: All Leads
    3. Instant Actions: Select Function >> Write your own function



Create a Connection:

  1. Navigate to Setup >> Developer Hub >> Connections >> My Connection >> Create Connection
  2. Select "Zoho OAuth" as service and provide Name to "Connection". Then, select the below
    scope:ZohoCRM.templates.email.READ

 

 

 

 

Custom Function Script: 

  1. void automation.Welcomeemail(int leadRecordId)
  2. {
  3. //Associating the template id for the API URL
  4. templateurl = "https://www.zohoapis.com/crm/v2.1/settings/email_templates/"+"6700402000001190011";
  5. templatedata = invokeUrl [
  6. url : templateurl
  7. type : GET
  8. connection : "emailtemplates"
  9. ];
  10. //info templatedata;
  11. // Fetching the content of the respective template
  12. templatecontent = templatedata.get("email_templates").get("0").get("content");
  13. //info templatecontent;
  14. //Since the template has Mergetags such as Lead First name, Last name and Company, fetch such information from the Leads module
  15. Leaddata = zoho.crm.getRecordById("Leads",leadRecordId);
  16. LeadName = ifNull(Leaddata.get("First_Name"),"") + " " + ifNull(Leaddata.get("Last_Name"),"");
  17. Company = ifNull(Leaddata.get("Company"),"");
  18. LeadEmail = ifNull(Leaddata.get("Email"),"");
  19. // Replace the merge tags in Email template with the respective information
  20. revisedcontent = templatecontent.replaceAll("\$\{!Leads.Full_Name\}",LeadName).replaceAll("\$\{!Leads.Company\}",Company);
  21. //info revisedcontent;
  22. //Send the Email to the Lead Email along with the Email template
  23. sendmail
  24. [
  25. from: zoho.adminuserid
  26. to: LeadEmail
  27. subject: "Welcome Email Template"
  28. message: revisedcontent
  29. ]
  30. }

 


NotesNotesIn the API URL, kindly change the domain as per your Data Center. 

Argument Mapping in Deluge RunTime Editor:


Screen Cast Video:





End Result:

 

 

TIPS: Avoid Common Errors

-> Ensure to use the correct API Names for both Module & Fields in the script.


-> To ensure you get the intended output, we would suggest you to use info() logs to each variable to check the output for seamless functionality under the Console section within Zoho CRM Function IDE.


-> Since we have used the Connections within a function script, ensure to have the required scopes added in connection to perform the intended API action. Also, ensure to use the connection link name (i.e., crm_connection ) while passing on to Deluge Invoke URL or Integration Task. 

-> As a common practice, we have used US DC API end point. If you are using CRM account in a different DC (i.e., IN, EU, CA, AU, etc.), then we would recommend you to use the API end point URL according to your DC.

For example:

US DC - "https://www.zohoapis.com/crm/v2/Deals/" + dealRecordID + "/Attachments/" + attachementIdList.get(i)
IN DC - "https://www.zohoapis.in/crm/v2/Deals/" + dealRecordID + "/Attachments/" + attachementIdList.get(i)
EU DC - "https://www.zohoapis.eu/crm/v2/Deals/" + dealRecordID + "/Attachments/" + attachementIdList.get(i)

-> Since the Automation Feature (e.g., Workflow Rules) is involved in this use-case, if the intended functionality does not work, then users can check the associated function failure reason under "Setup >> Developer Hub >> Functions >> Failures". Additionally, Users can also see the complete Log of all function execution for any specific created function to track the executions (i.e. under My Functions >> 3 Dots >> Logs). This also help in a scenario where a function is executed via Workflow rule in CRM record(shows in timeline), however it didn't perform the intended actions/updates in record. In such scenario, users can check the output (info logs) & error of execution via function logs within Zoho CRM.

Notes
Notes: Refer to the following Guide - Article to learn the best practices for Optimizing the code and various ways to deploy Custom Function across Zoho CRM.

  



Quote
Custom Solution Created by Sakthi Priyadharshini | Zoho Partner Support.
If you need any further clarifications, please don’t hesitate to contact partner-support@zohocorp.com.
Notes
Additionally, we kindly ask all "Europe and UK partners" to reach out to partner-support@eu.zohocorp.com.

      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          Zoho CRM Training Programs

          Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

          Zoho CRM Training
            Redefine the way you work
            with Zoho Workplace

              Zoho DataPrep Personalized Demo

              If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

              Zoho CRM Training

                Create, share, and deliver

                beautiful slides from anywhere.

                Get Started Now


                  Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                  BOOK A SESSION







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsEnterpriseOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceAccessible Forms
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit

                              Intake FormsLegal
                              Mobile App
                              Form DesignerHR
                              Mobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic Forms
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsFormstack alternativeEncrypted Forms

                              Wufoo alternativeSecure Forms

                              WCAG



                                        Create. Review. Publish.

                                        Write, edit, collaborate on, and publish documents to different content management platforms.

                                        Get Started Now







                                                          You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                              Manage your brands on social media


                                                                • Desk Community Learning Series


                                                                • Digest


                                                                • Functions


                                                                • Meetups


                                                                • Kbase


                                                                • Resources


                                                                • Glossary


                                                                • Desk Marketplace


                                                                • MVP Corner


                                                                • Word of the Day


                                                                • Ask the Experts


                                                                  Zoho Sheet Resources

                                                                   

                                                                      Zoho Forms Resources


                                                                        Secure your business
                                                                        communication with Zoho Mail


                                                                        Mail on the move with
                                                                        Zoho Mail mobile application

                                                                          Stay on top of your schedule
                                                                          at all times


                                                                          Carry your calendar with you
                                                                          Anytime, anywhere




                                                                                Zoho Sign Resources

                                                                                  Sign, Paperless!

                                                                                  Sign and send business documents on the go!

                                                                                  Get Started Now




                                                                                          Zoho TeamInbox Resources





                                                                                                    Zoho DataPrep Demo

                                                                                                    Get a personalized demo or POC

                                                                                                    REGISTER NOW


                                                                                                      Design. Discuss. Deliver.

                                                                                                      Create visually engaging stories with Zoho Show.

                                                                                                      Get Started Now









                                                                                                                            Wherever you are is as good as
                                                                                                                            your workplace

                                                                                                                              Resources

                                                                                                                              Videos

                                                                                                                              Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                              eBooks

                                                                                                                              Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                              Webinars

                                                                                                                              Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                              CRM Tips

                                                                                                                              Make the most of Zoho CRM with these useful tips.



                                                                                                                                Zoho Show Resources