For Zoho services only


I'm currently part of a wider delivery team at Ascent Business Solutions, recognised as a leading Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions support organisations with everything from targeted technical fixes through to full Zoho CRM implementations and long-term platform adoption. Working as a team rather than a one-person consultancy allows projects to move forward consistently, with access to the right skills at each stage.

The team I manage specialises in API integrations between Zoho and third-party finance and commerce platforms such as Xero, Shopify, WooCommerce, and eBay. Much of our work involves solving integration challenges that fall outside standard documentation, supporting new ideas, new sectors, and evolving business models.

Success is measured through practical outcomes and return on investment, ranging from scaling small operations into high-turnover businesses to delivering rapid gains through online payments, automation, and streamlined digital workflows.

If you are looking for structured Zoho expertise backed by an established consultancy, you can contact Ascent Business Solutions on 0121 392 8140 (UK), email info@ascentbusiness.co.uk, or visit https://www.ascentbusiness.co.uk.
Zoho Survey: Zoho CRM Webhook

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:	2025-10-06 (Joel Lipman)
    					- Clients wants a public URL for Survey: Need this webhook to create contact/account on-the-fly if needed.
    
    	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 by email
    	v_CrmContactID = "";
    	l_SearchContacts = zoho.crm.searchRecords("Contacts","Email:equals:" + m_SurveyBody.get("Email"));
    	for each  m_ContactResult in l_SearchContacts
    	{
    		//
    		// if found then simply update the contact
    		if(!isNull(m_ContactResult.get("id")))
    		{
    			v_CrmContactID = 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 "Updating CRM Contact: " + r_UpdateContact;
    		}
    	}
    	if(v_CrmContactID == "")
    	{
    		//
    		// create an account/company record to associate the contact to
    		v_CrmAccountID = "";
    		if(!isNull(m_SurveyBody.get("Company")))
    		{
    			m_CreateAccount = Map();
    			m_CreateAccount.put("Account_Name", m_SurveyBody.get("Company"));
    			m_CreateAccount.put("Number_of_Employees", m_SurveyBody.get("Number_of_Employees"));
    			m_CreateAccount.put("Turnover", m_SurveyBody.get("Last_Years_Turnover"));
    			r_CreateAccount = zoho.crm.createRecord("Accounts", m_CreateAccount);
    			info "Creating CRM Account: " + r_CreateAccount;
    			if(!isNull(r_CreateAccount.get("id")))
    			{
    				v_CrmAccountID = r_CreateAccount.get("id");
    			}
    		}
    		// create this contact as they filled in the survey without us sending it to them
    		m_CreateContact = Map();
    		m_CreateContact.put("First_Name", m_SurveyBody.get("First_Name"));
    		m_CreateContact.put("Last_Name", m_SurveyBody.get("Last_Name"));
    		m_CreateContact.put("Phone", m_SurveyBody.get("Phone"));
    		m_CreateContact.put("Email", m_SurveyBody.get("Email"));
    		m_CreateContact.put("Title", m_SurveyBody.get("Job_Title"));
    		if(v_CrmAccountID != "")
    		{
    			m_CreateContact.put("Account_Name", v_CrmAccountID);
    		}
    		m_CreateContact.put("Response_ID",m_SurveyBody.get("Response_ID"));
    		m_CreateContact.put("Survey_ID",m_SurveyBody.get("Survey_ID"));
    		m_CreateContact.put("Scheduled_Report_Generation_Time",zoho.currenttime.addHour(1).toString("yyyy-MM-dd'T'HH:mm:ss","Europe/London"));	
    		r_CreateContact = zoho.crm.createRecord("Contacts", m_CreateContact);
    		info "Creating CRM Contact: " + r_CreateContact;
    	}
    	/* 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 :"TEST: 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:    2025-10-06 (Joel Lipman) 
    15.                      - Clients wants a public URL for Survey: Need this webhook to create contact/account on-the-fly if needed. 
    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 by email 
    34.      v_CrmContactID = ""
    35.      l_SearchContacts = zoho.crm.searchRecords("Contacts","Email:equals:" + m_SurveyBody.get("Email"))
    36.      for each  m_ContactResult in l_SearchContacts 
    37.      { 
    38.          // 
    39.          // if found then simply update the contact 
    40.          if(!isNull(m_ContactResult.get("id"))) 
    41.          { 
    42.              v_CrmContactID = m_ContactResult.get("id")
    43.              m_UpdateContact = Map()
    44.              m_UpdateContact.put("Response_ID",m_SurveyBody.get("Response_ID"))
    45.              m_UpdateContact.put("Survey_ID",m_SurveyBody.get("Survey_ID"))
    46.              m_UpdateContact.put("Scheduled_Report_Generation_Time",zoho.currenttime.addHour(1).toString("yyyy-MM-dd'T'HH:mm:ss","Europe/London"))
    47.              r_UpdateContact = zoho.crm.updateRecord("Contacts",m_ContactResult.get("id"),m_UpdateContact)
    48.              info "Updating CRM Contact: " + r_UpdateContact; 
    49.          } 
    50.      } 
    51.      if(v_CrmContactID == "") 
    52.      { 
    53.          // 
    54.          // create an account/company record to associate the contact to 
    55.          v_CrmAccountID = ""
    56.          if(!isNull(m_SurveyBody.get("Company"))) 
    57.          { 
    58.              m_CreateAccount = Map()
    59.              m_CreateAccount.put("Account_Name", m_SurveyBody.get("Company"))
    60.              m_CreateAccount.put("Number_of_Employees", m_SurveyBody.get("Number_of_Employees"))
    61.              m_CreateAccount.put("Turnover", m_SurveyBody.get("Last_Years_Turnover"))
    62.              r_CreateAccount = zoho.crm.createRecord("Accounts", m_CreateAccount)
    63.              info "Creating CRM Account: " + r_CreateAccount; 
    64.              if(!isNull(r_CreateAccount.get("id"))) 
    65.              { 
    66.                  v_CrmAccountID = r_CreateAccount.get("id")
    67.              } 
    68.          } 
    69.          // create this contact as they filled in the survey without us sending it to them 
    70.          m_CreateContact = Map()
    71.          m_CreateContact.put("First_Name", m_SurveyBody.get("First_Name"))
    72.          m_CreateContact.put("Last_Name", m_SurveyBody.get("Last_Name"))
    73.          m_CreateContact.put("Phone", m_SurveyBody.get("Phone"))
    74.          m_CreateContact.put("Email", m_SurveyBody.get("Email"))
    75.          m_CreateContact.put("Title", m_SurveyBody.get("Job_Title"))
    76.          if(v_CrmAccountID != "") 
    77.          { 
    78.              m_CreateContact.put("Account_Name", v_CrmAccountID)
    79.          } 
    80.          m_CreateContact.put("Response_ID",m_SurveyBody.get("Response_ID"))
    81.          m_CreateContact.put("Survey_ID",m_SurveyBody.get("Survey_ID"))
    82.          m_CreateContact.put("Scheduled_Report_Generation_Time",zoho.currenttime.addHour(1).toString("yyyy-MM-dd'T'HH:mm:ss","Europe/London"))
    83.          r_CreateContact = zoho.crm.createRecord("Contacts", m_CreateContact)
    84.          info "Creating CRM Contact: " + r_CreateContact; 
    85.      } 
    86.      /* OPTIONAL: Send yourself an email 
    87.          sendmail 
    88.          [ 
    89.              from :zoho.adminuserid 
    90.              to :"This email address is being protected from spambots. You need JavaScript enabled to view it." 
    91.              subject :"TEST: Survey has been submitted" 
    92.              message :crmAPIRequest 
    93.          ] 
    94.      */ 
    95.      // 
    96.      // build response to Zoho Survey (hard-coded a ok) 
    97.      m_ResponseHeader = Map()
    98.      m_ResponseHeader.put("status_code",200)
    99.      return {"crmAPIResponse":m_ResponseHeader}
    100.  } 
  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

Source(s):
Category: Zoho CRM :: Article: 435

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

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