This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Customer Creation in Shopify

The second use case in the Shopify business scenario is used for customer creation. This page describes the relevant tasks and the operations you use in the Shopify connector and the other ESB connectors. It contains the following sections:

Overview

The flow for customer creation is illustrated in the following diagram. The ESB connectors for MailChimp, CallRail, Facebook, and ZohoCRM will be used to connect to each service.

Lead Generation 

In this use case, leads will be created in ZohoCRM. MailChimp is an online e-mail marketing solution which can be used to track campaigns and their clickers’ details and convert them into leads in ZohoCRM. Facebook can be used to retrieve the comment leaver’s feedback on a product that is marketed through the seller’s wall. The CallRail API is a call tracking tool which can be used to capture callers' contact details.

  1. Retrieve campaign clicks and campaign clickers from the MailChimp API using the listCampaignClicks and listCampaignClickers operations. 
  2. Retrieve the callers' contact details from the CallRail API using the listCalls operation. 
  3. Retrieve comment leavers' information from the Facebook API using the getPost operation.
  4. Create a lead in ZohoCRM using the insertRecords operation. 

    Note

    The created leads will be converted to contacts within ZohoCRM once they are qualified. This is a manual process for this scenario.

ZohoCRM operations
MailChimp operations
CallRail operations
Facebook operations
Samples
Sample Template for Retrieving Comment Leavers According to the Specified Criteria in Post, Retrieving Campaign Clickers of the Sent Campaign in Scenario One, and Retrieving Callers for the Given CallRail Company's Tracker Identifier
<?xml version="1.0" encoding="UTF-8"?>
<!-- This template retrieves comment leavers according to the specified criteria in the post, retrieves Campaign Clickers of 
	the sent campaign in Scenario One, and retrieves callers for the given CallRail company's tracker identifier. Then it creates 
	Leads in ZohoCRM using the retrieved details. -->
<template name="shopify-createLeadsWithFacebookMailChimpCallRailDetails" xmlns="http://ws.apache.org/ns/synapse">
	<!-- Facebook parameters -->
	<parameter name="fbApiUrl" description="Facebook Api Url" />
	<parameter name="fbAccessToken" description="Facebook Access Toekn for authentication" />
	<parameter name="fbPostId" description="Facebook Post Identifier contataining campaign details" />
	<parameter name="fbCompanyName" description="Company name to be used for the Leads created using Facebook details" />
	<!-- MailChimp parameters -->
	<parameter name="mcApiUrl" description="MailChimp Api Url" />
	<parameter name="mcApiKey" description="MailChimp Api key for authentication" />
	<parameter name="mcCampaignId" description="MailChimp Campaign identifier to retrieve the clicker details of this Campaign" />
	<parameter name="mcCompanyName" description="Company name to be used for the Leads created using MailChimp details" />
	<parameter name="mcClickUrl" description="A url of the MailChimp Campaign body to track the clicker details" />
	<!-- ZohoCRM parameters -->
	<parameter name="zohoApiUrl" description="Zoho CRM Api Url" />
	<parameter name="zohoAccessToken" description="Zoho CRM Access token for authentication" />
	<!-- Call Rail parameters -->
	<parameter name="crApiUrl" description="CallRail Api Url" />
	<parameter name="crApiKey" description="CallRail Api Key for authentication" />
	<parameter name="crPerPage" description="Number of CallRail caller results to be returned in the response page" />
	<parameter name="crPage" description="Callrail Caller detail response page number" />
	<parameter name="crCompanyId" description="CallRail Company Identifier under which the caller details are being tracked" />
	<parameter name="crCompanyName" description="Company name to be used for the Leads created using CallRail details" />
	<parameter name="crStartDate"
		description="Date or Date and Time in ISO 8601 format. Calls on or after this date will be fetched to extract caller details" />
	<parameter name="crEndDate"
		description="Date or Date and Time in ISO 8601 format. Calls on or before this date will be fetched to extract caller details" />
	<sequence>
		<!-- Facebook properties -->
		<property name="uri.var.fbApiUrl" expression="$func:fbApiUrl" />
		<property name="uri.var.fbAccessToken" expression="$func:fbAccessToken" />
		<property name="uri.var.fbPostId" expression="$func:fbPostId" />
		<property name="uri.var.fbCompanyName" expression="$func:fbCompanyName" />
		<property name="uri.var.fbFields" value="message,comments" />
		<!-- MailChimp Properties -->
		<property name="uri.var.mcApiUrl" expression="$func:mcApiUrl" />
		<property name="uri.var.mcApiKey" expression="$func:mcApiKey" />
		<property name="uri.var.mcCampaignId" expression="$func:mcCampaignId" />
		<property name="uri.var.mcClickUrl" expression="$func:mcClickUrl" />
		<property name="uri.var.mcCompanyName" expression="$func:mcCompanyName" />
		<property name="uri.var.mcFormat" value="json" />
		<!-- ZohoCRM properties -->
		<property name="uri.var.zohoApiUrl" expression="$func:zohoApiUrl" />
		<property name="uri.var.zohoAccessToken" expression="$func:zohoAccessToken" />
		<property name="uri.var.zohoScope" value="crmapi" />
		<property name="uri.var.zohoNewFormat" value="1" />
		<property name="uri.var.zohoVersion" value="1" />
		<property name="uri.var.zohoModuleType" value="Leads" />
		<!-- Call Rail properties -->
		<property name="uri.var.crApiUrl" expression="$func:crApiUrl" />
		<property name="uri.var.crApiKey" expression="$func:crApiKey" />
		<property name="uri.var.crPerPage" expression="$func:crPerPage" />
		<property name="uri.var.crPage" expression="$func:crPage" />
		<property name="uri.var.crCompanyId" expression="$func:crCompanyId" />
		<property name="uri.var.crCompanyName" expression="$func:crCompanyName" />
		<property name="uri.var.crStartDate" expression="$func:crStartDate" />
		<property name="uri.var.crEndDate" expression="$func:crEndDate" />

		<!-- START: Facebook -->
		<!-- Check the availability of the Facebook access token to proceed with the Facebook API call. -->
		<filter source="boolean(get-property('uri.var.fbAccessToken'))" regex="true">
			<else>
				<property name="uri.var.activity" value="facebook_getPost" />
				<property name="uri.var.status" value="Skipped" />
				<property name="uri.var.message" value="The API Key has not provided, Will also skip the Lead creation using MailChimp details" />
			</else>
			<then>
				<!-- Facebook retrieve post to extract Campaign Id and interested users. -->
				<facebook.init>
					<apiUrl>{$ctx:uri.var.fbApiUrl}</apiUrl>
					<accessToken>{$ctx:uri.var.fbAccessToken}</accessToken>
					<connection>{$ctx:uri.var.fbConnection}</connection>
					<fields>{$ctx:uri.var.fbFields}</fields>
				</facebook.init>
				<facebook.getPost>
					<postId>{$ctx:uri.var.fbPostId}</postId>
				</facebook.getPost>
				<property name="uri.var.fbGetPostErrorCode" expression="json-eval($..code[0])" />
				<!-- Checks the availability of the Facebook error code value to proceed with Lead creation. -->
				<filter source="get-property('uri.var.fbGetPostErrorCode') = '[]'" regex="true">
					<else>
						<property name="uri.var.fbGetPostErrorMessage" expression="json-eval($..message[0])" />
						<!-- The following Script mediator was added to replace Double Quotes with Single Quotes to keep a valid JSON format. -->
						<script language="js">
					         <![CDATA[
					         	var fbGetPostErrorMessage = mc.getProperty('uri.var.fbGetPostErrorMessage');
					         	mc.setProperty('uri.var.fbGetPostErrorMessage', fbGetPostErrorMessage.replace('"', '\\"'));
					          ]]>
						</script>
						<!-- Error in retrieving comment code from the Facebook post. -->
						<property name="uri.var.activity" value="facebook_getPost" />
						<property name="uri.var.status" value="Error" />
						<property name="uri.var.message" expression="get-property('uri.var.fbGetPostErrorMessage')" />
					</else>
					<then>
						<property name="uri.var.fbPostMessage" expression="json-eval($.message)" />
						<property name="uri.var.fbCommentsArray" expression="json-eval($..data)" />
						<!-- Generates the xmlData value with Facebook details to create Leads. -->
						<script language="js">
							<![CDATA[
								var fbPostMessage = mc.getProperty('uri.var.fbPostMessage');
								var fbCompanyName = mc.getProperty('uri.var.fbCompanyName');
								var commentCodePresent = false;
								var commentCode = '';
								var fbXmlData = '';
								
								// Regex to extract the Campaign Id, included in the Facebook post body.
								var fbCommentCode = fbPostMessage.match('enter "' + "(.*?)" + '" as');
								if(fbCommentCode != null && fbCommentCode !=''){
									commentCode = fbCommentCode[1];
									if(commentCode != null && commentCode != ''){
										mc.setProperty('uri.var.fbCommentCode', commentCode);
										commentCodePresent = true;
									}
								}
								
								// Checks the availability of the Campaign Id.
								if(commentCodePresent){
									var fbCommentsArray = eval ( '(' + mc.getProperty('uri.var.fbCommentsArray') + ')' );
									var row = 0;
									for (var i = 0; i < fbCommentsArray.length; i++) {
											if(commentCode == fbCommentsArray[i].message){
												fbXmlData += '<row no="' + (row+1) + '"><FL val="First Name">' + fbCommentsArray[i].from.name + '</FL><FL val="Last Name">' + fbCommentsArray[i].from.id + '</FL><FL val="Company">' + fbCompanyName + '</FL><FL val="Lead Source">Facebook</FL><FL val="Description">SHOPIFY</FL></row>';
												row = row + 1;
											}
										}								
									mc.setProperty('uri.var.fbXmlData', fbXmlData);						
								}
								
							]]>
						</script>
						<!-- Checks the availability of the Campaign Id to proceed with Lead creation. -->
						<filter source="boolean(get-property('uri.var.fbCommentCode'))" regex="true">
							<else>
								<!-- Error in retrieving comment code from fb post -->
								<property name="uri.var.activity" value="facebook_getPost" />
								<property name="uri.var.status" value="Error" />
								<property name="uri.var.message"
									value="Could not retrieve the comment code value from the post body, Will also skip the Lead creation using MailChimp details" />
							</else>
							<then>
								<!-- Checks whether the xmlData was populated to proceed with the Lead generation. -->
								<filter source="boolean(get-property('uri.var.fbXmlData'))" regex="false">
									<then>
										<!-- Error response -->
										<property name="uri.var.activity" value="facebook_getPost" />
										<property name="uri.var.status" value="Skipped" />
										<property name="uri.var.message"
											expression="fn:concat('Comments were not found with ' , get-property('uri.var.fbCommentCode') , ' value in the Post, with Post ID: ', get-property('uri.var.fbPostId'))" />
									</then>
									<else>
										<!-- Generate the xmlData value with the <Leads> root tag. -->
										<property name="uri.var.fbXmlDataVal" expression="fn:concat('&lt;Leads&gt;' , get-property('uri.var.fbXmlData') , '&lt;/Leads&gt;')" />
										<!-- Create Leads using Facebook details. -->
										<zohocrm.init>
											<scope>{$ctx:uri.var.zohoScope}</scope>
											<accessToken>{$ctx:uri.var.zohoAccessToken}</accessToken>
											<apiUrl>{$ctx:uri.var.zohoApiUrl}</apiUrl>
										</zohocrm.init>
										<zohocrm.insertRecords>
											<moduleType>{$ctx:uri.var.zohoModuleType}</moduleType>
											<duplicateCheck>{$ctx:uri.var.zohoduplicateCheck}</duplicateCheck>
											<newFormat>{$ctx:uri.var.zohoNewFormat}</newFormat>
											<version>{$ctx:uri.var.zohoVersion}</version>
											<xmlData>{$ctx:uri.var.fbXmlDataVal}</xmlData>
											<isApproval>{$ctx:isApproval}</isApproval>
											<wfTrigger>{$ctx:wfTrigger}</wfTrigger>
										</zohocrm.insertRecords>
										<property name="uri.var.zohoFBInsertLeadsError" expression="json-eval($.response.error)" />
										<property name="uri.var.activity" value="zohocrm_insertLeadsFromFacebookData" />
										<!-- Checks successful lead creation using the availability of an error code. -->
										<filter source="boolean(get-property('uri.var.zohoFBInsertLeadsError'))" regex="true">
											<then>
												<property name="uri.var.fbErrorMessage" expression="json-eval($.response.error.message)" />
												<script language="js">
											         <![CDATA[
											         	//Replaces the double quotes to maintain the valid JSON response.
											         	var fbErrorMessage = mc.getProperty('uri.var.fbErrorMessage');
											         	mc.setProperty('uri.var.fbErrorMessage', fbErrorMessage.replace('"', '\\"'));
											          ]]>
												</script>
												<property name="uri.var.status" value="Error" />
												<property name="uri.var.message" expression="get-property('uri.var.fbErrorMessage')" />
											</then>
											<else>
												<property name="uri.var.fbResultMessage" expression="json-eval($.response.result.message)" />
												<property name="uri.var.zohoFBSuccessResponseArray" expression="json-eval($..recorddetail)" />
												<!-- The script mediator generates the response IDs. -->
												<script language="js">
											         <![CDATA[
											         
														var fbLeadsArray = eval( '(' + mc.getProperty('uri.var.zohoFBSuccessResponseArray') + ')');
														var fbLeadsList = '';
														
														for (var i = 0; i < fbLeadsArray.length; i++) {
															fbLeadsList += fbLeadsArray[i].FL[0].content + ',';
															
														}
														if(fbLeadsList != ''){
															mc.setProperty('uri.var.fbLeadsList', fbLeadsList.substring(0, fbLeadsList.length-1));
														}
												        
													 ]]>
												</script>
												<filter source="boolean(get-property('uri.var.fbLeadsList'))" regex="true">
													<else>
														<property name="uri.var.status" value="Warning" />
														<property name="uri.var.message" value="No errors were found. However, could not retrieve the created Lead IDs." />
													</else>
													<then>
														<property name="uri.var.id" expression="fn:concat('{lead_ids:[', get-property('uri.var.fbLeadsList'), ']}')" />
														<property name="uri.var.status" value="Success" />
														<property name="uri.var.message" expression="get-property('uri.var.fbResultMessage')" />
													</then>
												</filter>
												<!-- END: ZohoCRM Lead ID details check. -->
											</else>
										</filter>
										<!-- END: ZohoCRM insertLeads response check. -->
									</else>
								</filter>
								<!-- END: Check XML data availability. -->
							</then>
						</filter>
						<!-- END: Facebook comments availability check. -->
					</then>
				</filter>
				<!-- END: Facebook getPost error check. -->
			</then>
			<!-- END: Facebook API key availability check. -->
		</filter>
		<!-- END: Facebook Lead creation. -->
		<!-- Response generator for Facebook. -->
		<call-template target="responseHandlerTemplate">
			<with-param name="activity" value="{$ctx:uri.var.activity}" />
			<with-param name="id" value="{$ctx:uri.var.id}" />
			<with-param name="status" value="{$ctx:uri.var.status}" />
			<with-param name="message" value="{$ctx:uri.var.message}" />
		</call-template>

		<!-- Remove Facebook response header information. -->
		<header name="ETag" scope="transport" action="remove" />
		<header name="Access-Control-Allow-Origin" scope="transport" action="remove" />
		<header name="Expires" scope="transport" action="remove" />
		<header name="Facebook-API-Version" scope="transport" action="remove" />
		<header name="Content-Encoding" scope="transport" action="remove" />
		<header name="Content-Type" scope="transport" action="remove" />
		<header name="Pragma" scope="transport" action="remove" />
		<header name="Cache-Control" scope="transport" action="remove" />
		<header name="Date" scope="transport" action="remove" />
		<header name="Server" scope="transport" action="remove" />
		<header name="Transfer-Encoding" scope="transport" action="remove" />
		<header name="Connection" scope="transport" action="remove" />
		<!-- START: MailChimp -->
		<!-- Check the availability of the MailChimp access token to proceed with the Lead creation using MailChimp Campaign Clickers. -->
		<filter source="boolean(get-property('uri.var.mcApiKey'))" regex="false">
			<then>
				<property name="uri.var.activity" value="mailchimp_listCampaignClickers" />
				<property name="uri.var.status" value="Skipped" />
				<property name="uri.var.message" value="The API Key has not provided" />
			</then>
			<else>
				<!-- Retrieve click details for the given campaign. -->
				<mailchimp.init>
					<apiUrl>{$ctx:uri.var.mcApiUrl}</apiUrl>
					<apiKey>{$ctx:uri.var.mcApiKey}</apiKey>
					<format>{$ctx:uri.var.mcFormat}</format>
				</mailchimp.init>
				<mailchimp.listCampaignClicks>
					<campaignId>{$ctx:uri.var.mcCampaignId}</campaignId>
				</mailchimp.listCampaignClicks>
				<property name="uri.var.cmListClicksStatusCode" expression="$axis2:HTTP_SC" />
				<filter source="get-property('uri.var.cmListClicksStatusCode')" regex="200">
					<else>
						<!-- Error in listing Campaign clicks -->
						<property name="uri.var.cmListClicksStatusErrorMessage" expression="json-eval($.error)" />
						<property name="uri.var.activity" value="mailchimp_listCampaignClicks" />
						<property name="uri.var.id" expression="fn:concat('campaign_id:', get-property('uri.var.mcCampaignId'))" />
						<property name="uri.var.status" value="Error" />
						<property name="uri.var.message" expression="get-property('uri.var.cmListClicksStatusErrorMessage')" />
					</else>
					<then>
						<!-- Successfully retrieved the Campaign Clicks. -->
						<!-- Removing Campaign Monitor listCampaign response headers. -->
						<header name="Vary" action="remove" scope="transport" />
						<header name="Content-Encoding" action="remove" scope="transport" />
						<header name="Set-Cookie" action="remove" scope="transport" />
						<header name="Content-Type" action="remove" scope="transport" />
						<header name="Date" action="remove" scope="transport" />
						<header name="Server" action="remove" scope="transport" />
						<header name="Transfer-Encoding" action="remove" scope="transport" />
						<header name="Connection" action="remove" scope="transport" />
						<property name="uri.var.mcResponseTotalArray" expression="json-eval($..total)" />
						<!-- Retrieves the tracker ID for the given URL, to track users from. -->
						<script language="js">
							<![CDATA[
								var mcClickUrl = mc.getProperty('uri.var.mcClickUrl');
								var mcResponseTotalArray = eval( '(' + mc.getProperty('uri.var.mcResponseTotalArray') + ')');
								var isClicksAvailable = false;
								
								for (var i = 0; i < mcResponseTotalArray.length; i++) {
									if(mcClickUrl == mcResponseTotalArray[i].url){
										mc.setProperty('uri.var.mcTrackerId', '' + mcResponseTotalArray[i].tid);
										isClicksAvailable = true;
									}
								}
								
								mc.setProperty('uri.var.isClicksAvailable', isClicksAvailable);
								
							]]>
						</script>
						<filter source="get-property('uri.var.isClicksAvailable')" regex="false">
							<then>
								<!-- Error response -->
								<property name="uri.var.activity" value="mailchimp_getTrackerId" />
								<property name="uri.var.status" value="Skipped" />
								<property name="uri.var.message"
									expression="fn:concat('Click details are not avaiable for the given Campaign ID:' , get-property('uri.var.mcCampaignId') , ' with URL: ', get-property('uri.var.mcClickUrl'))" />
							</then>
							<else>
								<!-- Retrieve Campaign Clickers for the given campaign's specified URL. -->
								<mailchimp.init>
									<apiUrl>{$ctx:uri.var.mcApiUrl}</apiUrl>
									<apiKey>{$ctx:uri.var.mcApiKey}</apiKey>
									<format>{$ctx:uri.var.mcFormat}</format>
								</mailchimp.init>
								<mailchimp.listCampaignClickers>
									<campaignId>{$ctx:uri.var.mcCampaignId}</campaignId>
									<trackingid>{$ctx:uri.var.mcTrackerId}</trackingid>
									<start>{$ctx:start}</start>
									<limit>{$ctx:limit}</limit>
									<sortField>{$ctx:sortField}</sortField>
									<sortDirection>{$ctx:sortDirection}</sortDirection>
								</mailchimp.listCampaignClickers>
								<property name="uri.var.cmListClickersStatusCode" expression="$axis2:HTTP_SC" />
								<filter source="get-property('uri.var.cmListClickersStatusCode')" regex="200">
									<else>
										<!-- Error in listing campaign clicks. -->
										<property name="uri.var.cmListClickersStatusErrorMessage" expression="json-eval($.error)" />
										<property name="uri.var.activity" value="mailchimp_listCampaignClickers" />
										<property name="uri.var.id"
											expression="fn:concat('campaign_id:', get-property('uri.var.mcCampaignId'), ', tracker_id:' , get-property('uri.var.mcTrackerId'))" />
										<property name="uri.var.status" value="Error" />
										<property name="uri.var.message" expression="get-property('uri.var.cmListClickersStatusErrorMessage')" />
									</else>
									<then>
										<property name="uri.var.mcResponseDataArray" expression="json-eval($..data)" />
										<!-- Generates the xmlData value with the MailChimp clicker details to create Leads. -->
										<script language="js">
											 <![CDATA[
											 
												var mcResponseDataArray = eval( '(' + mc.getProperty('uri.var.mcResponseDataArray') + ')');
												var mcCompanyName = mc.getProperty('uri.var.mcCompanyName');
												var xmlData = '';
												var row = 0;
												for (var i = 0; i < mcResponseDataArray.length; i++) {
												
													var userDetails = mcResponseDataArray[i].member.merges;
													if(userDetails != null && userDetails != '' && userDetails.EMAIL != null && userDetails.EMAIL != ''){
															
														var lastName = userDetails.LNAME;
														if(lastName == null || lastName == '' || lastName == 'undefined'){
															lastName = userDetails.EMAIL;
														}
														
														var timeZone = mcResponseDataArray[i].member.geo.timezone;
														if(timeZone == null || timeZone == 'undefined'){
															timeZone = '';
														}
														xmlData += '<row no="' + (row+1) + '"><FL val="First Name">' + userDetails.FNAME + '</FL><FL val="Last Name">' + lastName + '</FL><FL val="Email">' + userDetails.EMAIL + '</FL><FL val="Company">' + mcCompanyName + '</FL><FL val="Country">' + timeZone + '</FL><FL val="Lead Source">MailChimp</FL><FL val="Description">SHOPIFY</FL></row>';
														row = row + 1;
													}
												}
												
												mc.setProperty('uri.var.xmlDataVar', xmlData);
											 ]]>
										</script>
										<!-- Checks whether the xmlData was populated to proceed with the Lead generation. -->
										<filter source="boolean(get-property('uri.var.xmlDataVar'))" regex="false">
											<then>
												<!-- Error response -->
												<property name="uri.var.activity" value="mailchimp_listCampaignClickerDetails" />
												<property name="uri.var.status" value="Skipped" />
												<property name="uri.var.message"
													value="fn:concat('Clicker details are not found for the given Campaign with Campaign ID:' , get-property('uri.var.mcCampaignId') , ' and Tracker ID: ', get-property('uri.var.mcTrackerId'))" />
											</then>
											<else>
												<property name="uri.var.xmlDataVal"
													expression="fn:concat('&lt;Leads&gt;' , get-property('uri.var.xmlDataVar') , '&lt;/Leads&gt;')" />
												<!-- Create Leads using MailChimp Details -->
												<zohocrm.init>
													<scope>{$ctx:uri.var.zohoScope}</scope>
													<accessToken>{$ctx:uri.var.zohoAccessToken}</accessToken>
													<apiUrl>{$ctx:uri.var.zohoApiUrl}</apiUrl>
												</zohocrm.init>
												<zohocrm.insertRecords>
													<moduleType>{$ctx:uri.var.zohoModuleType}</moduleType>
													<duplicateCheck>{$ctx:uri.var.zohoduplicateCheck}</duplicateCheck>
													<newFormat>{$ctx:uri.var.zohoNewFormat}</newFormat>
													<version>{$ctx:uri.var.zohoVersion}</version>
													<xmlData>{$ctx:uri.var.xmlDataVal}</xmlData>
													<isApproval>{$ctx:isApproval}</isApproval>
													<wfTrigger>{$ctx:wfTrigger}</wfTrigger>
												</zohocrm.insertRecords>
												<property name="uri.var.zohoMCInsertLeadsError" expression="json-eval($.response.error)" />
												<!-- Checks the successful lead creation using the availability of an error code -->
												<filter source="boolean(get-property('uri.var.zohoMCInsertLeadsError'))" regex="true">
													<then>
														<property name="uri.var.mailChimpErrorMessage" expression="json-eval($.response.error.message)" />
														<script language="js">
															<!-- The following script mediator was included to replace double quotes with single quotes, so that the response remains 
																a valid JSON. -->
															 <![CDATA[
																var mailChimpErrorMessage = mc.getProperty('uri.var.mailChimpErrorMessage');
																mc.setProperty('uri.var.mailChimpErrorMessage', mailChimpErrorMessage.replace('"', '\\"'));
															  ]]>
														</script>
														<property name="uri.var.activity" value="zohocrm_insertLeadsFromMailChimpData" />
														<property name="uri.var.status" value="Error" />
														<property name="uri.var.message" expression="get-property('uri.var.mailChimpErrorMessage')" />
													</then>
													<else>
														<property name="uri.var.mcResultMessage" expression="json-eval($.response.result.message)" />
														<property name="uri.var.zohoMcSuccessResponseArray" expression="json-eval($..recorddetail)" />
														<!-- The script mediator generates the response IDs. -->
														<script language="js">
															 <![CDATA[
															 
																var mcLeadsArray = eval( '(' + mc.getProperty('uri.var.zohoMcSuccessResponseArray') + ')');
																var mcLeadsList = '';
																
																for (var i = 0; i < mcLeadsArray.length; i++) {
																	mcLeadsList += mcLeadsArray[i].FL[0].content + ',';
																	
																}
																if(mcLeadsList != ''){
																	mc.setProperty('uri.var.mcLeadsList', mcLeadsList.substring(0, mcLeadsList.length-1));
																}
																
									
															 ]]>
														</script>
														<property name="uri.var.activity" value="zohocrm_insertLeadsFromMailChimpData" />
														<filter source="boolean(get-property('uri.var.mcLeadsList'))" regex="true">
															<else>
																<property name="uri.var.status" value="Warning" />
																<property name="uri.var.message" value="No errors were found. However, could not retrieve the created Lead IDs." />
															</else>
															<then>
																<property name="uri.var.id" expression="fn:concat('{lead_ids:[', get-property('uri.var.mcLeadsList'), ']}')" />
																<property name="uri.var.status" value="Success" />
																<property name="uri.var.message" expression="get-property('uri.var.mcResultMessage')" />
															</then>
														</filter>
														<!-- END: ZohoCRM Lead ID details check. -->
													</else>
												</filter>
												<!-- END: ZohoCRM insertLeads response check. -->
											</else>
										</filter>
										<!-- END: Check XML data availability. -->
									</then>
								</filter>
								<!-- END: listClickers response check. -->
							</else>
						</filter>
						<!-- END: Clicks availability check for the Tracker ID. -->
					</then>
				</filter>
				<!-- END: listClicks response check. -->
			</else>
		</filter>
		<!-- END: MailChimp Access token check. -->
	
		<!-- The response generator for MailChimp. -->
		<call-template target="responseHandlerTemplate">
			<with-param name="activity" value="{$ctx:uri.var.activity}" />
			<with-param name="id" value="{$ctx:uri.var.id}" />
			<with-param name="status" value="{$ctx:uri.var.status}" />
			<with-param name="message" value="{$ctx:uri.var.message}" />
		</call-template>

		<!-- START: CallRail -->
		<!-- Clear the ID value to be passed to the responseHandler template. -->
		<property name="uri.var.id" value="null" />
		<!-- Check the availability of the CallRail access token to proceed with the CallRail API call. -->
		<filter source="boolean(get-property('uri.var.crApiKey'))" regex="true">
			<else>
				<property name="uri.var.activity" value="callrail_listCalls" />
				<property name="uri.var.status" value="Skipped" />
				<property name="uri.var.message" value="The API Key has not provided" />
			</else>
			<then>
				<!-- Retrieve call details for the given company. -->
				<callrail.init>
					<apiUrl>{$ctx:uri.var.crApiUrl}</apiUrl>
					<apiKey>{$ctx:uri.var.crApiKey}</apiKey>
				</callrail.init>
				<callrail.listCalls>
					<startDate>{$ctx:uri.var.crStartDate}</startDate>
					<endDate>{$ctx:uri.var.crEndDate}</endDate>
					<perPage>{$ctx:uri.var.crPerPage}</perPage>
					<page>{$ctx:uri.var.crPage}</page>
					<companyId>{$ctx:uri.var.crCompanyId}</companyId>
				</callrail.listCalls>
				<property name="uri.var.crListCallsStatusCode" expression="$axis2:HTTP_SC" />
				<filter source="get-property('uri.var.crListCallsStatusCode')" regex="200">
					<else>
						<!-- Error in listing calls. -->
						<property name="uri.var.activity" value="callrail_listCalls" />
						<property name="uri.var.status" value="Error" />
						<property name="uri.var.message" expression="json-eval($.error)" />
					</else>
					<then>
						<property name="uri.var.callerDetailsArray" expression="json-eval($..calls)" />

						<filter source="get-property('uri.var.callerDetailsArray') = '[]'" regex="true">
							<then>
								<!-- Empty Call list -->
								<property name="uri.var.activity" value="callrail_listCalls" />
								<property name="uri.var.status" value="Skipped" />
								<property name="uri.var.message" value="Empty Call list" />
							</then>
							<else>
								<script language="js">
						         <![CDATA[
									 var callRailResults = mc.getProperty("uri.var.callerDetailsArray");
									 var crCompanyName = mc.getProperty("uri.var.crCompanyName");
									 var crXmlData = '';
									 var row = 0;
									 
									 if(callRailResults != null && callRailResults != ''){		 
										 var callsList = eval("(" + callRailResults + ")");		
										 			 
										 for (var i = 0; i < callsList.length ; i++) {
											 var firstName = callsList[i].source_name;
											 var lastName = callsList[i].caller_number;
											 var country = callsList[i].caller_country;
											 var leadSource = 'CallRail, Tracking Number: ' + callsList[i].tracking_number;
											 var city = callsList[i].caller_city;
											 var zip = callsList[i].caller_zip;
											 
											 if(firstName == null && firstName == 'undefined'){
												firstName = '';
											 }	
											 crXmlData += '<row no="' + (row+1) + '"><FL val="First Name">' + firstName + '</FL><FL val="Last Name">' + lastName + '</FL><FL val="Company">' + crCompanyName + '</FL><FL val="Country">' + country + '</FL><FL val="Lead Source">' + leadSource + '</FL><FL val="City">' + city + '</FL><FL val="Zip Code">' + zip + '</FL><FL val="Description">SHOPIFY</FL></row>';
											 row = row + 1;			
										 }
										 mc.setProperty('uri.var.crXmlDataVar', crXmlData);
									 }
								 ]]>
								</script>
								<!-- Check whether the xmlData was populated to proceed with the Lead generation. -->
								<filter source="boolean(get-property('uri.var.crXmlDataVar'))" regex="false">
									<then>
										<!-- Error response -->
										<property name="uri.var.activity" value="callrail_listCalls" />
										<property name="uri.var.status" value="Skipped" />
										<property name="uri.var.message"
											expression="fn:concat('Caller details are not found for the given Company ID:' , get-property('uri.var.crCompanyId'))" />
									</then>
									<else>
										<property name="uri.var.crXmlDataVal" expression="fn:concat('&lt;Leads&gt;' , get-property('uri.var.crXmlDataVar') , '&lt;/Leads&gt;')" />
										<!-- Create Leads using CallRail details. -->
										<zohocrm.init>
											<scope>{$ctx:uri.var.zohoScope}</scope>
											<accessToken>{$ctx:uri.var.zohoAccessToken}</accessToken>
											<apiUrl>{$ctx:uri.var.zohoApiUrl}</apiUrl>
										</zohocrm.init>
										<zohocrm.insertRecords>
											<moduleType>{$ctx:uri.var.zohoModuleType}</moduleType>
											<duplicateCheck>{$ctx:uri.var.zohoduplicateCheck}</duplicateCheck>
											<newFormat>{$ctx:uri.var.zohoNewFormat}</newFormat>
											<version>{$ctx:uri.var.zohoVersion}</version>
											<xmlData>{$ctx:uri.var.crXmlDataVal}</xmlData>
											<isApproval>{$ctx:isApproval}</isApproval>
											<wfTrigger>{$ctx:wfTrigger}</wfTrigger>
										</zohocrm.insertRecords>
										<property name="uri.var.zohoCRInsertLeadsError" expression="json-eval($.response.error)" />
										<!-- Check successful lead creation using the availability of an error code. -->
										<filter source="boolean(get-property('uri.var.zohoCRInsertLeadsError'))" regex="true">
											<then>
												<property name="uri.var.callRailErrorMessage" expression="json-eval($.response.error.message)" />
												<script language="js">
											         <![CDATA[
											         	var callRailErrorMessage = mc.getProperty('uri.var.callRailErrorMessage');
											         	mc.setProperty('uri.var.callRailErrorMessage', callRailErrorMessage.replace('"', '\\"'));
											          ]]>
												</script>
												<property name="uri.var.activity" value="zohocrm_insertLeadsFromCallRailData" />
												<property name="uri.var.status" value="Error" />
												<property name="uri.var.message" expression="get-property('uri.var.callRailErrorMessage')" />
											</then>
											<else>
												<property name="uri.var.crResultMessage" expression="json-eval($.response.result.message)" />
												<property name="uri.var.zohoCRSuccessResponseArray" expression="json-eval($..recorddetail)" />
												<!-- Script meditor generates the response IDs. -->
												<script language="js">
											         <![CDATA[
											         
														var crLeadsArray = eval( '(' + mc.getProperty('uri.var.zohoCRSuccessResponseArray') + ')');
														var crLeadsList = '';
														
														for (var i = 0; i < crLeadsArray.length; i++) {
															crLeadsList += crLeadsArray[i].FL[0].content + ',';
															
														}
														if(crLeadsList != ''){
															mc.setProperty('uri.var.crLeadsList', crLeadsList.substring(0, crLeadsList.length-1));
														}
												        
							
													 ]]>
												</script>
												<property name="uri.var.activity" value="zohocrm_insertLeadsFromCallRailData" />
												<filter source="boolean(get-property('uri.var.crLeadsList'))" regex="true">
													<else>
														<property name="uri.var.status" value="Warning" />
														<property name="uri.var.message" value="Leads were created, however, could not retrieve the created Lead IDs." />
													</else>
													<then>
														<property name="uri.var.id" expression="fn:concat('{lead_ids:[', get-property('uri.var.crLeadsList'), ']}')" />
														<property name="uri.var.status" value="Success" />
														<property name="uri.var.message" expression="get-property('uri.var.crResultMessage')" />
													</then>
												</filter>
												<!-- END: ZohoCRM Lead ID details check. -->
											</else>
										</filter>
										<!-- END: ZohoCRM insertLeads response check. -->
									</else>
								</filter>
								<!-- END: Check XML data availability. -->
							</else>
						</filter>
						<!-- END: Empty call list check. -->
					</then>
				</filter>
				<!-- END: CallRail listCalls response check. -->
			</then>
		</filter>
		<!-- END: CallRail API token check. -->
		<!-- Response generator for CallRail. -->
		<call-template target="responseHandlerTemplate">
			<with-param name="activity" value="{$ctx:uri.var.activity}" />
			<with-param name="id" value="{$ctx:uri.var.id}" />
			<with-param name="status" value="{$ctx:uri.var.status}" />
			<with-param name="message" value="{$ctx:uri.var.message}" />
		</call-template>
	</sequence>
</template>
Sample Proxy for Retrieving Details of Potential Customers from Facebook, MailChimp and CallRail, and Creating Leads in ZohoCRM
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="shopify_createLeads" transports="https,http" statistics="disable"
	trace="disable" startOnLoad="true">
	<target>
		<inSequence onError="faultHandlerSeq">
			<!-- Facebook properties -->
			<property name="fbApiUrl" expression="json-eval($.fbApiUrl)" />
			<property name="fbAccessToken" expression="json-eval($.fbAccessToken)" />
			<property name="fbPostId" expression="json-eval($.fbPostId)" />
			<property name="fbCompanyName" expression="json-eval($.fbCompanyName)" />
			<!-- MailChimp Properties -->
			<property name="mcApiUrl" expression="json-eval($.mcApiUrl)" />
			<property name="mcApiKey" expression="json-eval($.mcApiKey)" />
			<property name="mcCampaignId" expression="json-eval($.mcCampaignId)" />
			<property name="mcClickUrl" expression="json-eval($.mcClickUrl)" />
			<property name="mcCompanyName" expression="json-eval($.mcCompanyName)" />
			<!-- Zoho CRM properties -->
			<property name="zohoApiUrl" expression="json-eval($.zohoApiUrl)" />
			<property name="zohoAccessToken" expression="json-eval($.zohoAccessToken)" />
			<!-- Call Rail properties -->
			<property name="crApiUrl" expression="json-eval($.crApiUrl)" />
			<property name="crApiKey" expression="json-eval($.crApiKey)" />
			<property name="crPerPage" expression="json-eval($.crPerPage)" />
			<property name="crPage" expression="json-eval($.crPage)" />
			<property name="crCompanyId" expression="json-eval($.crCompanyId)" />
			<property name="crCompanyName" expression="json-eval($.crCompanyName)" />
			<property name="crStartDate" expression="json-eval($.crStartDate)" />
			<property name="crEndDate" expression="json-eval($.crEndDate)" />
			<call-template target="shopify-createLeadsWithFacebookMailChimpCallRailDetails">
				<!-- Parameter values will be passed on to a sequence template. -->
				(
				<with-param name="fbApiUrl" value="{$ctx:fbApiUrl}" />
				|
				<with-param name="fbAccessToken" value="{$ctx:fbAccessToken}" />
				|
				<with-param name="fbPostId" value="{$ctx:fbPostId}" />
				|
				<with-param name="mcApiUrl" value="{$ctx:mcApiUrl}" />
				|
				<with-param name="mcApiKey" value="{$ctx:mcApiKey}" />
				|				
				<with-param name="mcCampaignId" value="{$ctx:mcCampaignId}" />
				|				
				<with-param name="mcCompanyName" value="{$ctx:mcCompanyName}" />
				|
				<with-param name="mcClickUrl" value="{$ctx:mcClickUrl}" />
				|
				<with-param name="zohoApiUrl" value="{$ctx:zohoApiUrl}" />
				|
				<with-param name="zohoAccessToken" value="{$ctx:zohoAccessToken}" />
				|
				<with-param name="crApiUrl" value="{$ctx:crApiUrl}" />
				|
				<with-param name="crApiKey" value="{$ctx:crApiKey}" />
				|
				<with-param name="crPerPage" value="{$ctx:crPerPage}" />
				|
				<with-param name="crPage" value="{$ctx:crPage}" />
				|
				<with-param name="crCompanyId" value="{$ctx:crCompanyId}" />
				|
				<with-param name="crCompanyName" value="{$ctx:crCompanyName}" />
				|
				<with-param name="crStartDate" value="{$ctx:crStartDate}" />
				|
				<with-param name="crEndDate" value="{$ctx:crEndDate}" />
				|
				<with-param name="fbApiUrl" value="{$ctx:fbApiUrl}" />
				|
				<with-param name="fbAccessToken" value="{$ctx:fbAccessToken}" />
				|
				<with-param name="fbPostId" value="{$ctx:fbPostId}" />
				|
				<with-param name="fbCompanyName" value="{$ctx:fbCompanyName}" />
				|
				) *
			</call-template>
			<loopback />
		</inSequence>
		<outSequence>
			<property name="messageType" value="application/json" scope="axis2" />
			<!-- Generate the chained response of all the API calls in createLeads. -->
			<payloadFactory media-type="json">
				<format>
					{
					"Response":{
					"process":"shopify-createLeads",
					"activityResponse":[$1]
					}
					}
				</format>
				<args>
					<arg evaluator="xml" expression="get-property('operation', 'responseString')" />
				</args>
			</payloadFactory>
			<send />
		</outSequence>
	</target>
	<description />
</proxy>                                                                  
Sample Request for Retrieving Details of Potential Customers from Facebook, MailChimp and CallRail, and Creating Leads in ZohoCRM
{
	"fbApiUrl":"https://graph.facebook.com",
	"fbAccessToken":"CAACEdEose0cBAJYh7dkhqhE52lSKLUCkSY8d1EZC3vh3SagkLGzcYaaShZB7jZCKtdyFw2gEIBFTJpuEwrThewkCQHFA98jQ7mZCILcyYczdZATvND7j2zGOIHINj3EbH5VrMcgVjySqIUZAU98DyPSILysUP3LrVkkOELXImZAV8zRCM1CF5goDM3sWjZCQYLXYaEIHPcqEwqnag5bRbjSZA",
	"fbPostId":"855517641126127_338677383006083",
	"fbCompanyName":"facebook_company",
		
	"mcApiUrl": "https://us9.api.mailchimp.com",
	"mcApiKey":"e9f3f31d72f27c34b09cf787ae4d850e-us9",
	"mcCampaignId":"504eaa7bea",
	"mcClickUrl":"https://www.shopify.com/login",
	"mcCompanyName":"mailchimp_company",
	
	"zohoApiUrl":"https://crm.zoho.com",
	"zohoAccessToken":"3284be8550656d9cab344471844c009a",

	"crApiUrl": "https://api.callrail.com",
	"crApiKey":"847aa413c03d889da62c9e4962d4319d",
	"crCompanyId":"322540968",
	"crCompanyName":"callrail_company",
	"crPerPage": "",
	"crPage":"",
	"crStartDate": "",
	"crEndDate":""
}

Customer Creation

In addition to lead generation, you can also create customers in Shopify by retrieving contacts from ZohoCRM. 

  1. Retrieve contacts from ZohoCRM using the searchRecords operation. Update or modify contacts in ZohoCRM using the updateRecords operation. 
  2. Create customers in Shopify using the createCustomer operation.
 ZohoCRM operations
Shopify operations
Samples
Sample Proxy for Retrieving Contacts from the ZohoCRM API and Creating them as Customers in the Shopify API
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="shopify_createCustomers"
	transports="https,http" statistics="disable" trace="disable"
	startOnLoad="true">
	<target>
		<inSequence onError="faultHandlerSeq">
			<!-- ZohoCRM properties -->
			<property name="zohoApiUrl" expression="json-eval($.zohoApiUrl)" />
			<property name="zohoAccessToken" expression="json-eval($.zohoAccessToken)" />
			<property name="zohoScope" value="crmapi" />			
			<property name="zohoSelectColumns" value="Contacts(First Name,Last Name,Account Name,Description,Email,Mailing Street,Mailing State,Mailing City,Mailing Country,Mailing Zip,phone)" />
			<property name="zohoCriteria" value="(Description:SHOPIFY)" />
			<property name="zohoModule" value="Contacts" />
			<property name="zohoXMLData" value="&lt;Contacts&gt; &lt;row no=&quot;1&quot;&gt; &lt;FL val=&quot;Description&quot;&gt;&lt;/FL&gt; &lt;/row&gt; &lt;/Contacts&gt;" />
			<!-- Shopify properties -->
			<property name="shopifyApiUrl" expression="json-eval($.shopifyApiUrl)" />
			<property name="shopifyAccessToken" expression="json-eval($.shopifyAccessToken)" />
			<property name="shopifyFormat" value="json" />
			<!-- Common properties -->
			<property name="index" value="0" scope="operation" />
			
			<!--  Retrieve ZohoCRM contacts for the search criteria. -->
			<zohocrm.init>
				<scope>{$ctx:zohoScope}</scope>
				<accessToken>{$ctx:zohoAccessToken}</accessToken>
				<apiUrl>{$ctx:zohoApiUrl}</apiUrl>
			</zohocrm.init>
			<zohocrm.searchRecords>
				<criteria>{$ctx:zohoCriteria}</criteria>
				<selectColumns>{$ctx:zohoSelectColumns}</selectColumns>
				<module>{$ctx:zohoModule}</module>
			</zohocrm.searchRecords>
			<!-- Remove custom headers from the searchContacts response. -->
			<header name="Strict-Transport-Security" scope="transport" action="remove" />
			<header name="X-XSS-Protection" scope="transport" action="remove" />
			<header name="X-Download-Options" scope="transport" action="remove" />
			<header name="X-Content-Type-Options" scope="transport" action="remove" />
			<header name="Pragma" scope="transport" action="remove" />
			<header name="Cache-Control" scope="transport" action="remove" />
			<!-- Check whether an error is returned while retrieving the contacts. If yes, return an error response; otherwise, proceed to create customers. -->
			<property name="errorCode" expression="json-eval($..code)" />
			<filter source="get-property('errorCode') = '[]'" regex="true">
				<else>
					<property name="message" expression="json-eval($..message[0])" />
					<call-template target="responseHandlerTemplate">
						<with-param name="activity" value="zohocrm_searchContacts" />
						<with-param name="status" value="Error" />
						<with-param name="message" value="{$ctx:message}" />
					</call-template>
					<loopback />
				</else>
				<then>
					<!-- Creating the customers in Shopify using the details of retrieved contacts. -->
					<property name="messageType" value="application/xml" scope="axis2" />
					<property name="contactsCount" expression="count(//result/Contacts/row)" scope="operation" />
					<iterate expression="//result/Contacts/row" id="contactsIterator" continueParent="true"  preservePayload="true"  sequential="true">
						<target>
							<sequence>
								<property name="contactId"
									expression="//FL[val[text()='CONTACTID']]/content/text()" />
								<property name="firstName"
									expression="//FL[val[text()='First Name']]/content/text()" />
								<property name="lastName"
									expression="//FL[val[text()='Last Name']]/content/text()" />
								<property name="company"
									expression="//FL[val[text()='Account Name']]/content/text()" />	
								<property name="email"
									expression="//FL[val[text()='Email']]/content/text()" />
								<property name="street"
									expression="//FL[val[text()='Mailing Street']]/content/text()" />
								<property name="state"
									expression="//FL[val[text()='Mailing State']]/content/text()" />
								<property name="city"
									expression="//FL[val[text()='Mailing City']]/content/text()" />
								<property name="country"
									expression="//FL[val[text()='Mailing Country']]/content/text()" />
								<property name="zipCode"
									expression="//FL[val[text()='Mailing Zip']]/content/text()" />
								<property name="phone"
									expression="//FL[val[text()='Phone']]/content/text()" />
									
								<property name="messageType" value="application/json" scope="axis2" />
								<payloadFactory media-type="json">
									<format>
										{
										"customerDetails": {
										"first_name": "$1",
										"last_name": "$2",
										"email": "$3",
										"addresses": [
										{
										"address1": "$4",
										"city":	"$5",
										"company":"$6",
										"province": "$7",
										"phone": "$8",
										"zip": "$9",
										"last_name": "$2",
										"first_name": "$1",
										"country": "$10"
										}
										]
										}
										}
									</format>
									<args>
										<arg expression="get-property('firstName')" />
										<arg expression="get-property('lastName')" />
										<arg expression="get-property('email')" />
										<arg expression="get-property('street')" />
										<arg expression="get-property('city')" />
										<arg expression="get-property('company')" />
										<arg expression="get-property('state')" />
										<arg expression="get-property('phone')" />
										<arg expression="get-property('zipCode')" />
										<arg expression="get-property('country')" />
									</args>
								</payloadFactory>
								<property name="customerDetails" expression="json-eval($.customerDetails)" />
								<shopify.init>
									<apiUrl>{$ctx:shopifyApiUrl}</apiUrl>
									<accessToken>{$ctx:shopifyAccessToken}</accessToken>
									<format>{$ctx:shopifyFormat}</format>
								</shopify.init>
								<shopify.createCustomer>
									<customer>{$ctx:customerDetails}</customer>
								</shopify.createCustomer>
								<!-- Removing custom headers from the createCustomers response. -->
								<header name="X-XSS-Protection" scope="transport" action="remove" />
								<header name="X-UA-Compatible" scope="transport" action="remove" />
								<header name="X-Request-Id" scope="transport" action="remove" />
								<header name="X-Stats-ApiClientId" scope="transport" action="remove" />
								<header name="X-Content-Type-Options" scope="transport" action="remove" />
								<header name="X-Stats-ApiPermissionId" scope="transport" action="remove" />
								<header name="Status" scope="transport" action="remove" />
								<header name="X-Frame-Options" scope="transport" action="remove" />
								<header name="X-Stats-UserId" scope="transport" action="remove" />
								<header name="X-ShopId" scope="transport" action="remove" />
								<header name="Vary" scope="transport" action="remove" />
								<header name="HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT" scope="transport" action="remove" />
								<header name="X-Served-With" scope="transport" action="remove" />
								<header name="X-ShardId" scope="transport" action="remove" />
								<header name="X-Shopify-Shop-Api-Call-Limit" scope="transport" action="remove" />
								<header name="WWW-Authenticate" scope="transport" action="remove" />
								<header name="X-Stats-Validation-Errors" scope="transport" action="remove" />
								<property name="createdCustomer" expression="json-eval($.customer)" />
								<!-- Check whether the customer has been created. If created, return a success response; if not, return an error response. -->
								<filter source="boolean(get-property('createdCustomer'))" regex="true">
									<then>
										<property name="id" expression="json-eval($.customer.id)" />
										<property name="status" value="Success" />
										<property name="activity" value="shopify_createCustomers" />
										<property name="message" value="Successfully created the customer" />
										<!-- Update the description field in ZohoCRM contacts after successfully creating the customer. -->
										<zohocrm.init>
											<scope>{$ctx:zohoScope}</scope>
											<accessToken>{$ctx:zohoAccessToken}</accessToken>
											<apiUrl>{$ctx:zohoApiUrl}</apiUrl>
										</zohocrm.init>
										<zohocrm.updateRecords>
											<moduleType>{$ctx:zohoModule}</moduleType>
											<id>{$ctx:contactId}</id>
											<xmlData>{$ctx:zohoXMLData}</xmlData>
										</zohocrm.updateRecords>
									</then>
									<else>
										<property name="message" expression="json-eval($..errors)" />
										<property name="status" value="Error" />
										<property name="activity" value="shopify_createCustomers" />
										<property name="message" expression="json-eval($..errors)" />
									</else>
								</filter>
								<call-template target="responseHandlerTemplate">
									<with-param name="id" value="{$ctx:id}" />
									<with-param name="status" value="{$ctx:status}" />
									<with-param name="activity" value="{$ctx:activity}" />
									<with-param name="message" value="{$ctx:message}" />
								</call-template>
								<property name="index" expression="get-property('operation','index') + 1" scope="operation" />
							</sequence>
						</target>
					</iterate>
					<filter
						xpath="get-property('operation', 'index') = get-property('operation', 'contactsCount')">
						<then>
							<loopback />
						</then>
					</filter>
				</then>
			</filter>
		</inSequence>
		<outSequence>
			<property name="messageType" value="application/json" scope="axis2" />
			<payloadFactory media-type="json">
				<format>
					{
					"Response":{
					"process":"shopify-retrieveContactsAndCreateCustomers",
					"activityResponse":[$1]
					}
					}
				</format>
				<args>
					<arg expression="get-property('operation', 'responseString')" />
				</args>
			</payloadFactory>
			<send />
		</outSequence>
	</target>
	<description />
</proxy>                                                                                            
Sample Request for Retrieving Contacts from the ZohoCRM API and Creating them as Customers in the Shopify API
{
	"zohoApiUrl":"https://crm.zoho.com",
	"zohoAccessToken":"a55a9431798aa91071bcd53526152548",
	"shopifyApiUrl":"https://disnafirststore.myshopify.com",
	"shopifyAccessToken":"32841521265cb52bef980cff1da1e008"
}