For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at https://ascentbusiness.co.uk/zoho-services/uk-zoho-support.  For larger projects, talk to our experts and receive dedicated support from our hands-on project consultants at https://ascentbusiness.co.uk/zoho-services/zoho-crm-implementation.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at https://ascentbusiness.co.uk.

Zoho Books: Estimates/Quotes: Accept & Decline Buttons on Template

What?
An article on adding an accept and decline button on the estimate (aka Quote) notification template within ZohoBooks.

Why?
The use-case is simply that my client wants to make it easier for their customers to accept or decline a quote. Sure there's a portal and you can probably do it from there but this is a one-click accept or decline then done.

One of the biggest hurdles here, which may sound trivial, was the response when an end customer clicks on either the accept or decline button. Using ZohoFlow or other Zoho app for a webhook response, would result in the end customer suddenly downloading a JSON file. Looked a bit suspicious. The code below opens a new tab in their web-browser displaying a plain output message.

How?
So there are 2 caveats to this solution: 1 is that you will need ZohoCRM. I've tried using the "Incoming Webhooks" feature of ZohoBooks but realised the word "Incoming" is the operative word as the response cannot be configured in ZohoBooks like we need to in this solution; namely the webhook response needs to have a header and a body.

The 2nd caveat is a concern around security. It is difficult to guess a customer's Zoho ID; some might say almost impossible. To use other fields that could be sent via the URL as a verification to be checked at the webhook endpoint would be good as well; but I couldn't spend time finding fields that can be 'placeheld', other than what the interface offers, into the template.

the CRM webhook API function
So let's do my favorite method of creating a REST API function in CRM
  1. Login to ZohoCRM > Setup > Functions > New Function
  2. Give it a function name, I'm calling mine fn_ZohoBooks_Estimates_AcceptDecline with the parameters: p_Intent (string), p_QuoteRef (string), p_CxID (string)
  3. The display name I'm giving it is Fn - ZohoBooks - Estimates - Accept/Decline
  4. It's a standalone function
  5. I'll give it the following code (amend the org ID and connection name):
    copyraw
    //
    // initialize
    b_ValidResponse = false;
    v_EstimateID = "-";
    v_OrgId = "123456789";
    v_Output = "Unable to process request";
    //
    // evaluate
    v_Intent = ifnull(input.p_Intent,"-");
    v_QuoteRef = ifnull(input.p_QuoteRef,"-");
    v_CustomerID = ifnull(input.p_CxID,"-");
    //
    // Search ZohoBooks estimates for the quote reference and validate by the contact Zoho ID
    if(v_QuoteRef != "-")
    {
    	r_SearchResults = zoho.books.getRecords("estimates",v_OrgId,"estimate_number=" + v_QuoteRef,"my_books_connection");
    	if(r_SearchResults.get("code") == 0)
    	{
    		l_SearchResults = r_SearchResults.get("estimates");
    		for each  m_Estimate in l_SearchResults
    		{
    			if(m_Estimate.get("estimate_number").equalsIgnoreCase(v_QuoteRef))
    			{
    				if(m_Estimate.get("customer_id") == v_CustomerID)
    				{
    					v_EstimateID = m_Estimate.get("estimate_id");
    				}
    			}
    		}
    	}
    }
    //
    // accept or decline
    if(v_EstimateID != "-")
    {
    	if(v_Intent == "Accept")
    	{
            b_ValidResponse = true;
    		//
    		// Mark the estimate as accepted
    		r_Accept = invokeurl
    		[
    			url :"https://www.zohoapis.com/books/v3/estimates/" + v_EstimateID + "/status/accepted?organization_id=" + v_OrgId
    			type :POST
    			connection:"my_books_connection"
    		];
    		v_OutputResponse = "Thank you for accepting your quote!  We'll be in touch soon to finalize the next steps and get everything ready.";
    	}
    	else if(v_Intent == "Decline")
    	{
            b_ValidResponse = true;
    		//
    		// Mark the estimate as declined
    		r_Decline = invokeurl
    		[
    			url :"https://www.zohoapis.com/books/v3/estimates/" + v_EstimateID + "/status/declined?organization_id=" + v_OrgId
    			type :POST
    			connection:"my_books_connection"
    		];
    		v_OutputResponse = "We're sorry to see you decline the quote, but we're here if you change your mind.";
    	}
    }
    //
    // push a response so when clicked, it loads up a page in a browser (redirect from a zoho page)
    if(b_ValidResponse)
    {
        //
        // generate HTML page when clicked (please amend the following variables)
        v_CompanyName = "Joel Lipman Ltd";
        v_CompanyStrapline = "The One and Only";
        v_CompanyURL = "https://www.joellipman.com";
        v_LogoURL = v_CompanyURL + "/images/logos/logo.png";
        //
        // create a HTML message to display
    	v_BodyHTML = "<html><head><title>";
    	v_BodyHTML = v_BodyHTML + v_CompanyName + "</title><script>window.history.pushState({},'','/thank-you');</script>";
    	v_BodyHTML = v_BodyHTML + "<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" /><link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin /><link href=\"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;1,100&display=swap\" rel=\"stylesheet\" /><style>body{font-family:'Poppins', sans-serif;}</style></head><body><div style=\"display:flex;flex-wrap:wrap;justify-content:center;align-content:center;height:100%;width:100%;\"><center><a href=\"";
    	v_BodyHTML = v_BodyHTML + v_CompanyURL + "\"><img src=\"" + v_LogoURL;
    	v_BodyHTML = v_BodyHTML + "\" style=\"max-width:215px;border:0;\" /></a><br /><span>" + v_CompanyStrapline + "</span><br /><h2 style=\"font-weight:100;max-width:400px;\">" + v_OutputResponse + "</h1></center></div></body></html>";    
        //
        // output to new browser tab
    	m_Response = Map();
    	m_Response.put("Content-Type","text/html");
    	m_Response.put("status_code",200);
    	m_Header = Map();
    	m_Header.put("Content-Disposition","inline;");
    	m_Response.put("headers",m_Header);
    	m_Response.put("body",v_BodyHTML);
    }
    else
    {
        //
        // could put a 403 but it's if there was an invalid request.  Here we're not really responding with anything
    	m_Response = Map();
    	m_Response.put("status_code",200);
    }
    //
    // return webhook response
    return {"crmAPIResponse":m_Response};
    1.  // 
    2.  // initialize 
    3.  b_ValidResponse = false
    4.  v_EstimateID = "-"
    5.  v_OrgId = "123456789"
    6.  v_Output = "Unable to process request"
    7.  // 
    8.  // evaluate 
    9.  v_Intent = ifnull(input.p_Intent,"-")
    10.  v_QuoteRef = ifnull(input.p_QuoteRef,"-")
    11.  v_CustomerID = ifnull(input.p_CxID,"-")
    12.  // 
    13.  // Search ZohoBooks estimates for the quote reference and validate by the contact Zoho ID 
    14.  if(v_QuoteRef != "-") 
    15.  { 
    16.      r_SearchResults = zoho.books.getRecords("estimates",v_OrgId,"estimate_number=" + v_QuoteRef,"my_books_connection")
    17.      if(r_SearchResults.get("code") == 0) 
    18.      { 
    19.          l_SearchResults = r_SearchResults.get("estimates")
    20.          for each  m_Estimate in l_SearchResults 
    21.          { 
    22.              if(m_Estimate.get("estimate_number").equalsIgnoreCase(v_QuoteRef)) 
    23.              { 
    24.                  if(m_Estimate.get("customer_id") == v_CustomerID) 
    25.                  { 
    26.                      v_EstimateID = m_Estimate.get("estimate_id")
    27.                  } 
    28.              } 
    29.          } 
    30.      } 
    31.  } 
    32.  // 
    33.  // accept or decline 
    34.  if(v_EstimateID != "-") 
    35.  { 
    36.      if(v_Intent == "Accept") 
    37.      { 
    38.          b_ValidResponse = true
    39.          // 
    40.          // Mark the estimate as accepted 
    41.          r_Accept = invokeUrl 
    42.          [ 
    43.              url :"https://www.zohoapis.com/books/v3/estimates/" + v_EstimateID + "/status/accepted?organization_id=" + v_OrgId 
    44.              type :POST 
    45.              connection:"my_books_connection" 
    46.          ]
    47.          v_OutputResponse = "Thank you for accepting your quote!  We'll be in touch soon to finalize the next steps and get everything ready."
    48.      } 
    49.      else if(v_Intent == "Decline") 
    50.      { 
    51.          b_ValidResponse = true
    52.          // 
    53.          // Mark the estimate as declined 
    54.          r_Decline = invokeUrl 
    55.          [ 
    56.              url :"https://www.zohoapis.com/books/v3/estimates/" + v_EstimateID + "/status/declined?organization_id=" + v_OrgId 
    57.              type :POST 
    58.              connection:"my_books_connection" 
    59.          ]
    60.          v_OutputResponse = "We're sorry to see you decline the quote, but we're here if you change your mind."
    61.      } 
    62.  } 
    63.  // 
    64.  // push a response so when clicked, it loads up a page in a browser (redirect from a zoho page) 
    65.  if(b_ValidResponse) 
    66.  { 
    67.      // 
    68.      // generate HTML page when clicked (please amend the following variables) 
    69.      v_CompanyName = "Joel Lipman Ltd"
    70.      v_CompanyStrapline = "The One and Only"
    71.      v_CompanyURL = "https://www.joellipman.com"
    72.      v_LogoURL = v_CompanyURL + "/images/logos/logo.png"
    73.      // 
    74.      // create a HTML message to display 
    75.      v_BodyHTML = "<html><head><title>"
    76.      v_BodyHTML = v_BodyHTML + v_CompanyName + "</title><script>window.history.pushState({},'','/thank-you');</script>"
    77.      v_BodyHTML = v_BodyHTML + "<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" /><link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin /><link href=\"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;1,100&display=swap\" rel=\"stylesheet\" /><style>body{font-family:'Poppins', sans-serif;}</style></head><body><div style=\"display:flex;flex-wrap:wrap;justify-content:center;align-content:center;height:100%;width:100%;\"><center><a href=\""
    78.      v_BodyHTML = v_BodyHTML + v_CompanyURL + "\"><img src=\"" + v_LogoURL; 
    79.      v_BodyHTML = v_BodyHTML + "\" style=\"max-width:215px;border:0;\" /></a><br /><span>" + v_CompanyStrapline + "</span><br /><h2 style=\"font-weight:100;max-width:400px;\">" + v_OutputResponse + "</h1></center></div></body></html>"
    80.      // 
    81.      // output to new browser tab 
    82.      m_Response = Map()
    83.      m_Response.put("Content-Type","text/html")
    84.      m_Response.put("status_code",200)
    85.      m_Header = Map()
    86.      m_Header.put("Content-Disposition","inline;")
    87.      m_Response.put("headers",m_Header)
    88.      m_Response.put("body",v_BodyHTML)
    89.  } 
    90.  else 
    91.  { 
    92.      // 
    93.      // could put a 403 but it's if there was an invalid request.  Here we're not really responding with anything 
    94.      m_Response = Map()
    95.      m_Response.put("status_code",200)
    96.  } 
    97.  // 
    98.  // return webhook response 
    99.  return {"crmAPIResponse":m_Response}
  6. Once saved, I'll hover the mouse over it and click on the ellipsis to select REST API option. Then make a note of the URL.

the ZohoBooks Estimate Template
Now you need to add a couple of buttons to the estimate template in ZohoBooks
  1. Login to ZohoBooks > Settings > Email Notifications > Estimate Notification
  2. Many ways to add a button but here's how I do it (requires some basic HTML/CSS knowledge):
    1. Place the cursor where you want the button and give it some text, I'm going to start with Accept Quote
    2. Then click on the link icon and give it the link noted from the URL made earlier (the one to the CRM REST API function):
      copyraw
      // should be something like
      <my_rest_api_function_url>&p_Intent=Accept&p_QuoteRef=%EstimateNumber%&p_CxID=%CustomerID%
      1.  // should be something like 
      2.  <my_rest_api_function_url>&p_Intent=Accept&p_QuoteRef=%EstimateNumber%&p_CxID=%CustomerID% 
      Then press OK to save the link
    3. Now click on the HTML icon, and find your link, then add the necessary CSS to make it look like a button (I'll tend to repeat what was done to the default "View Estimate" button).
  3. Repeat this to place the decline button, ensuring you change the link's p_Intent value to Decline:
    copyraw
    // should be something like
    <my_rest_api_function_url>&p_Intent=Decline&p_QuoteRef=%EstimateNumber%&p_CxID=%CustomerID%
    1.  // should be something like 
    2.  <my_rest_api_function_url>&p_Intent=Decline&p_QuoteRef=%EstimateNumber%&p_CxID=%CustomerID% 

When the end customer clicks on either button in their email (at least in a web-based email client such as outlook or Gmail), they should get something like the following:
Zoho Books: Estimates/Quotes: Accept & Decline Buttons on Template

Your staff will, of course, see the estimate status as accepted or declined in ZohoBooks.

Category: Zoho :: Article: 887

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Joes Word Cloud

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.