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 Survey: Zoho CRM Webhook

What?
A separate article as a follow-on from my previous article in this series Zoho Survey & Zoho Analytics: Query to generate individual responses and grouped pages which may have grown a little but just wanted to record how to receive a Zoho Survey response in a Zoho CRM REST API function.

Why?
As above, didn't want to overload a single article with all the answers of one development but this one may be referred to separately. I want a Zoho Survey when submitted to be parsed by a Zoho CRM REST API function.

How?
First, I'll go through the steps of setting up the Zoho CRM function, we'll convert it to a REST API function which will give us a URL and then we'll configure the Zoho Survey to trigger a webhook when submitted.

Pre-Amble
Just need a few fields on the CRM contact record to store the survey metadata
  1. Login to ZohoCRM with permissions to edit modules
  2. Go to Setup > Modules and Fields > Contacts > Layout > Standard
  3. Add the section: "Latest Survey"
  4. Add to it the fields "Response ID", "Survey ID", "Scheduled Report Generation Time"
  5. Save and close

the CRM function
You should know how to set up a CRM function as a REST API function but here goes a quick recap:
  1. Login to ZohoCRM as a user who has permission to create functions
  2. Create a CRM function, I'm calling mine "Fn - Submit Suspect Survey - Webhook" with internal name as fn_SubmitSuspectSurvey_Webhook and the parameter is a string called crmAPIRequest
  3. Give it the following code:
    copyraw
    string standalone.fn_SubmitSuspectSurvey_Webhook(String crmAPIRequest)
    {
    /* *******************************************************************************
    	Function:       string standalone.fn_SubmitSuspectSurvey_Webhook(String crmAPIRequest)
    	Label:          Fn - Submit Suspect Survey - Webhook
    	Trigger:        Webhook when a suvey is submitted in Zoho Survey
    	Purpose:		Push the calculated score and results from Analytics into the corresponding Zoho CRM record.
    	Inputs:         String crmAPIRequest
    	Outputs:        -
    
    	Date Created:   2025-09-19 (Joel Lipman)
    					- Initial release
    					- Identifies a survey by email
    	Date Modified:	???
    					- ???
    
    	More Information:
    					Within Zoho Surveys, configure the webhook to return the Response ID, Email, and Survey ID:
    					1. Login to Zoho Surveys
    					2. Click on the Survey > Builder > Hub > Triggers > Webhook > Manage
    					3. Post URL is the REST API URL of the ZohoCRM function (this function)
    					4. Set Request Body to JSON with name 'Survey' and within specify Response ID, Email, and Survey ID mapping as appropriate.
    					5. Click on 'Save' button at the bottom of the page
    					
    					CAVEAT: If you have multiple contacts in your CRM with the same email address, then you're stuffed.
    
    	******************************************************************************* */
    	v_WebhookBody = ifnull(crmAPIRequest.toMap().get("body"),"");
    	v_WebhookBodyDecode = zoho.encryption.urlDecode(v_WebhookBody);
    	v_WebhookBodyString = v_WebhookBodyDecode.getSuffix("Survey=");
    	m_SurveyBody = v_WebhookBodyString.toMap();
    	//
    	// find contact
    	l_SearchContacts = zoho.crm.searchRecords("Contacts","Email:equals:" + m_SurveyBody.get("Email"));
    	for each  m_ContactResult in l_SearchContacts
    	{
    		if(!isNull(m_ContactResult.get("id")))
    		{
    			m_UpdateContact = Map();
    			m_UpdateContact.put("Response_ID",m_SurveyBody.get("Response_ID"));
    			m_UpdateContact.put("Survey_ID",m_SurveyBody.get("Survey_ID"));
    			m_UpdateContact.put("Scheduled_Report_Generation_Time",zoho.currenttime.addHour(1).toString("yyyy-MM-dd'T'HH:mm:ss","Europe/London"));
    			r_UpdateContact = zoho.crm.updateRecord("Contacts",m_ContactResult.get("id"),m_UpdateContact);
    			info r_UpdateContact;
    		}
    	}
    	/* OPTIONAL: Send yourself an email
    		sendmail
    		[
    			from :zoho.adminuserid
    			to :"This email address is being protected from spambots. You need JavaScript enabled to view it."
    			subject :"WEBHOOK: Survey has been submitted"
    			message :crmAPIRequest
    		]
    	*/
    	//
    	// build response to Zoho Survey (hard-coded a ok)
    	m_ResponseHeader = Map();
    	m_ResponseHeader.put("status_code",200);
    	return {"crmAPIResponse":m_ResponseHeader};
    }
    1.  string standalone.fn_SubmitSuspectSurvey_Webhook(String crmAPIRequest) 
    2.  { 
    3.  /* ******************************************************************************* 
    4.      Function:       string standalone.fn_SubmitSuspectSurvey_Webhook(String crmAPIRequest) 
    5.      Label:          Fn - Submit Suspect Survey - Webhook 
    6.      Trigger:        Webhook when a suvey is submitted in Zoho Survey 
    7.      Purpose:        Push the calculated score and results from Analytics into the corresponding Zoho CRM record. 
    8.      Inputs:         String crmAPIRequest 
    9.      Outputs:        - 
    10.   
    11.      Date Created:   2025-09-19 (Joel Lipman) 
    12.                      - Initial release 
    13.                      - Identifies a survey by email 
    14.      Date Modified:    ??? 
    15.                      - ??? 
    16.   
    17.      More Information: 
    18.                      Within Zoho Surveys, configure the webhook to return the Response ID, Email, and Survey ID: 
    19.                      1. Login to Zoho Surveys 
    20.                      2. Click on the Survey > Builder > Hub > Triggers > Webhook > Manage 
    21.                      3. Post URL is the REST API URL of the ZohoCRM function (this function) 
    22.                      4. Set Request Body to JSON with name 'Survey' and within specify Response ID, Email, and Survey ID mapping as appropriate. 
    23.                      5. Click on 'Save' button at the bottom of the page 
    24.   
    25.                      CAVEAT: If you have multiple contacts in your CRM with the same email address, then you're stuffed. 
    26.   
    27.      ******************************************************************************* */ 
    28.      v_WebhookBody = ifnull(crmAPIRequest.toMap().get("body"),"")
    29.      v_WebhookBodyDecode = zoho.encryption.urlDecode(v_WebhookBody)
    30.      v_WebhookBodyString = v_WebhookBodyDecode.getSuffix("Survey=")
    31.      m_SurveyBody = v_WebhookBodyString.toMap()
    32.      // 
    33.      // find contact 
    34.      l_SearchContacts = zoho.crm.searchRecords("Contacts","Email:equals:" + m_SurveyBody.get("Email"))
    35.      for each  m_ContactResult in l_SearchContacts 
    36.      { 
    37.          if(!isNull(m_ContactResult.get("id"))) 
    38.          { 
    39.              m_UpdateContact = Map()
    40.              m_UpdateContact.put("Response_ID",m_SurveyBody.get("Response_ID"))
    41.              m_UpdateContact.put("Survey_ID",m_SurveyBody.get("Survey_ID"))
    42.              m_UpdateContact.put("Scheduled_Report_Generation_Time",zoho.currenttime.addHour(1).toString("yyyy-MM-dd'T'HH:mm:ss","Europe/London"))
    43.              r_UpdateContact = zoho.crm.updateRecord("Contacts",m_ContactResult.get("id"),m_UpdateContact)
    44.              info r_UpdateContact; 
    45.          } 
    46.      } 
    47.      /* OPTIONAL: Send yourself an email 
    48.          sendmail 
    49.          [ 
    50.              from :zoho.adminuserid 
    51.              to :"This email address is being protected from spambots. You need JavaScript enabled to view it." 
    52.              subject :"WEBHOOK: Survey has been submitted" 
    53.              message :crmAPIRequest 
    54.          ] 
    55.      */ 
    56.      // 
    57.      // build response to Zoho Survey (hard-coded a ok) 
    58.      m_ResponseHeader = Map()
    59.      m_ResponseHeader.put("status_code",200)
    60.      return {"crmAPIResponse":m_ResponseHeader}
    61.  } 
  4. Save the function, hover over it and select "REST API", enable both options and copy the URL for the REST API

Configuring Zoho Survey
  1. Login to Zoho Surveys
  2. Click on the Survey > Builder > Hub > Triggers > Webhook > Manage
  3. Post URL is the REST API URL of the ZohoCRM function (this function)
  4. Set Request Body to JSON with name 'Survey' and within specify Response ID, Email, and Survey ID mapping as appropriate.
  5. Click on 'Save' button at the bottom of the page

Category: Zoho :: Article: 911

Add comment

Your rating:

Submit

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

Accreditation

Badge - Zoho Creator Certified Developer Associate
Badge - Zoho Deluge Certified Developer
Badge - Certified Zoho CRM Developer

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

Please publish modules in offcanvas position.