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/.

Initiating Marketing in Zoho CRM

The first use case in the Zoho CRM business scenario is initiating marketing, which includes creating campaigns and creating and converting leads. This page describes the related tasks and the operations you use in the Zoho CRM connector and the other ESB connectors. It contains the following sections:

Overview

The flow for initiating marketing is illustrated in the following diagram. We will use the ESB connectors for Zoho CRM, Campaign Monitor, Facebook, and CallRail to connect to each service.


Creating campaigns  

In this use case, we will create the campaign in Zoho CRM and then use Campaign Monitor and Facebook to publicize it. Campaign Monitor is an email marketing service that allows you to publish campaigns to bring more business to the company. Facebook can be used as a marketing tool where you can post your campaign details on your wall and get interested individuals as leads in Zoho CRM .

To create a campaign
  1. Create the campaign in Zoho CRM using the insertRecords operation, and then retrieve its details using the getRecordsById operation.
  2. Create a draft campaign in Campaign Monitor using the createDraftCampaign operation, and then email the campaign to subscribers using sendCampaign .
  3. Post details of events related to the campaign on the campaign owner's Facebook wall using the createEvent operation.
 Zoho CRM operations
Campaign Monitor operations
Facebook operations
Samples
Sample Template for Creating and Retrieving Campaign Details
<template name="zohocrm-createAndRetrieveCampaignDetails" xmlns="http://ws.apache.org/ns/synapse">
	<parameter name="zohoScope" description="Specify the value as crmapi" />
	<parameter name="zohoAccessToken" description="Encrypted alphanumeric string to authenticate the Zoho credentials" />
	<parameter name="zohoApiUrl" description="The api url" />
	<parameter name="zohoIsApproval" description="To keep the records in approval mode" />
	<parameter name="zohoWfTrigger" description="The wfTrigger parameter is used to trigger the workflow rule while inserting record into CRM account" />
	<parameter name="zohoNewFormat" description="The newFormat, an integer determine weather null valus should be excluded(1) or included(2)" />
	<parameter name="zohoVersion" description="The API version" />
	<parameter name="zohoDuplicateCheck" description="Checking the duplicate records and throw an error response" />
	<parameter name="zohoXmlData" description="The xml string containing the data to be inserted" />	
	<sequence>
		<property name="uri.var.zohoScope" expression="$func:zohoScope" />
		<property name="uri.var.zohoAccessToken" expression="$func:zohoAccessToken" />
		<property name="uri.var.zohoApiUrl" expression="$func:zohoApiUrl" />
		<property name="uri.var.zohoIsApproval" expression="$func:zohoIsApproval" />
		<property name="uri.var.zohoWfTrigger" expression="$func:zohoWfTrigger" />
		<property name="uri.var.zohoNewFormat" expression="$func:zohoNewFormat" />
		<property name="uri.var.zohoVersion" expression="$func:zohoVersion" />
		<property name="uri.var.zohoDuplicateCheck" expression="$func:zohoDuplicateCheck" />
		<property name="uri.var.zohoXmlData" expression="$func:zohoXmlData" />
		<property name="uri.var.zohoModuleType" value="Campaigns" />		 
      <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>
        <xmlData>{$ctx:uri.var.zohoXmlData}</xmlData>
        <isApproval>{$ctx:uri.var.zohoIsApproval}</isApproval>
        <wfTrigger>{$ctx:uri.var.zohoWfTrigger}</wfTrigger>
        <newFormat>{$ctx:uri.var.zohoNewFormat}</newFormat>
        <version>{$ctx:uri.var.zohoVersion}</version>
      </zohocrm.insertRecords>  
	  <!-- Retrieving the ID of the new campaign-->
      <property name="uri.var.zohoCampaignId" expression="json-eval($.response.result.recorddetail.FL[0].content)"/>	
		<call-template target="responseHandlerTemplate">
			<!-- parameter values will be passed on to a sequence template -->
			(
			<with-param name="activityName" value="ZohoCRM_insertRecords" />
			|
			) *
		</call-template>		
		<filter source="boolean(get-property('uri.var.zohoCampaignId'))" regex="false">
			<then>
				<loopback/>
			</then>
	    </filter>	  
	 <!-- Retrieving information about the campaign-->  
      <zohocrm.init>
        <scope>{$ctx:uri.var.zohoScope}</scope>
        <accessToken>{$ctx:uri.var.zohoAccessToken}</accessToken>
        <apiUrl>{$ctx:uri.var.zohoApiUrl}</apiUrl>
      </zohocrm.init>	  
	  <zohocrm.getRecordsById>
        <id>{$ctx:uri.var.zohoCampaignId}</id>
        <newFormat>{$ctx:uri.var.zohoNewFormat}</newFormat>
        <version>{$ctx:uri.var.zohoVersion}</version>
	    <moduleType>{$ctx:uri.var.zohoModuleType}</moduleType>
      </zohocrm.getRecordsById>	  
	  <property name="uri.var.errorOutput" expression="json-eval($.response.error)"/>	  
		<call-template target="responseHandlerTemplate">
			<!-- parameter values will be passed on to a sequence template -->
			(
			<with-param name="activityName" value="ZohoCRM_getRecordsById" />
			|
			) *
		</call-template>		
		<filter source="boolean(get-property('uri.var.errorOutput'))" regex="true">
			<then>
				<loopback/>
			</then>
	    </filter> 		
	</sequence>
</template>
Sample Template for Creating a Facebook Event and Sending a Campaign
<template name="zohocrm-createFacebookEventAndSendCampaign" xmlns="http://ws.apache.org/ns/synapse">
	<parameter name="facebookAccessToken" description="The accesstoken of the facebook api" />
	<parameter name="facebookApiUrl" description="The facebook API url" />
	<parameter name="facebookName" description="The name of the event" />
	<parameter name="facebookStartTime" description="The start time of the event, in ISO-8601 format" />
    <parameter name="facebookDescription" description="Event description" />
	<parameter name="facebookEndTime" description="The end time of the event, in ISO-8601 format" />
	<parameter name="facebookLocation" description="Where the event is located as an arbitrary descriptive string" />
	<parameter name="facebookLocationId" description="Where the event is located as the page ID of a specific place" />
	<parameter name="facebookPrivacyType" description="Privacy of the event" />
	<parameter name="cmApiUrl" description="The api url of campaign monitor" />
	<parameter name="cmAccessToken" description="campaign monitor access token" />
	<parameter name="cmClientId" description="The unique identifier of the campaign monitor client" />
	<parameter name="cmName" description="Name of the campaign" />
	<parameter name="cmSubject" description="Subject of the campaign" />
	<parameter name="cmFromName" description="Sender name that appears on the campaign email" />
	<parameter name="cmFromEmail" description="Email address that appears on the sender email" />
	<parameter name="cmReplyToEmail" description="Email address to which the replay will be sent to" />
	<parameter name="cmHtmlUrl" description="Template embedded in the email" />
	<parameter name="cmListIds" description="Subscriber list ids" />
	<parameter name="cmSegmentIds" description="Segment list ids" />
	<parameter name="cmConfirmationEmailsList" description="Confirmation email list" />
	<parameter name="cmSendDate" description="campaign send date" />	
	<sequence>
	    <property name="uri.var.facebookAccessToken" expression="$func:facebookAccessToken" />
	    <property name="uri.var.facebookApiUrl" expression="$func:facebookApiUrl" />
		<property name="uri.var.facebookName" expression="$func:facebookName" />
		<property name="uri.var.facebookStartTime" expression="$func:facebookStartTime" />
		<property name="uri.var.facebookDescription" expression="$func:facebookDescription" />
		<property name="uri.var.facebookEndTime" expression="$func:facebookEndTime" />
		<property name="uri.var.facebookLocation" expression="$func:facebookLocation" />
		<property name="uri.var.facebookLocationId" expression="$func:facebookLocationId" />
		<property name="uri.var.facebookPrivacyType" expression="$func:facebookPrivacyType" />
		<property name="uri.var.cmApiUrl" expression="$func:cmApiUrl" />
		<property name="uri.var.cmAccessToken" expression="$func:cmAccessToken" />
		<property name="uri.var.cmClientId" expression="$func:cmClientId" />
		<property name="uri.var.cmName" expression="$func:cmName" />
		<property name="uri.var.cmSubject" expression="$func:cmSubject" />
		<property name="uri.var.cmFromName" expression="$func:cmFromName" />
		<property name="uri.var.cmFromEmail" expression="$func:cmFromEmail" />
		<property name="uri.var.cmReplyToEmail" expression="$func:cmReplyToEmail" />
		<property name="uri.var.cmHtmlUrl" expression="$func:cmHtmlUrl" />
		<property name="uri.var.cmListIds" expression="$func:cmListIds" />
		<property name="uri.var.cmSegmentIds" expression="$func:cmSegmentIds" />
		<property name="uri.var.cmConfirmationEmailsList" expression="$func:cmConfirmationEmailsList" />
		<property name="uri.var.cmSendDate" expression="$func:cmSendDate" />		
	<!-- Calling the Facebook createEvent method -->
	<filter source="boolean(get-property('uri.var.facebookAccessToken'))" regex="true">
		<then>
	     <facebook.init>
            <accessToken>{$ctx:uri.var.facebookAccessToken}</accessToken>
            <apiUrl>{$ctx:uri.var.facebookApiUrl}</apiUrl>
         </facebook.init>		 
         <facebook.createEvent>
            <name>{$ctx:uri.var.facebookName}</name>
            <startTime>{$ctx:uri.var.facebookStartTime}</startTime>
            <endTime>{$ctx:uri.var.facebookEndTime}</endTime>
            <description>{$ctx:uri.var.facebookDescription}</description>
            <location>{$ctx:uri.var.facebookLocation}</location>
            <locationId>{$ctx:uri.var.facebookLocationId}</locationId>
            <privacyType>{$ctx:uri.var.facebookPrivacyType}</privacyType>
         </facebook.createEvent>        
		<property name="messageType" value="application/json" scope="axis2"></property>	
		
		<call-template target="responseHandlerTemplate">
			<!-- parameter values will be passed on to a sequence template -->
			(
			<with-param name="activityName" value="Facebook_createEvent" />
			|
			) *
		</call-template>		
		</then>
	</filter>	
	 <campaignmonitor.init>
		<apiUrl>{$ctx:uri.var.cmApiUrl}</apiUrl>
		<accessToken>{$ctx:uri.var.cmAccessToken}</accessToken>
	 </campaignmonitor.init>		 
      <campaignmonitor.createDraftCampaign>
        <htmlUrl>{$ctx:uri.var.cmHtmlUrl}</htmlUrl>
        <segmentIds>{$ctx:uri.var.cmSegmentIds}</segmentIds>
        <subject>{$ctx:uri.var.cmSubject}</subject>
        <name>{$ctx:uri.var.cmName}</name>
        <fromEmail>{$ctx:uri.var.cmFromEmail}</fromEmail>
        <listIds>{$ctx:uri.var.cmListIds}</listIds>
        <fromName>{$ctx:uri.var.cmFromName}</fromName>
        <replyToEmail>{$ctx:uri.var.cmReplyToEmail}</replyToEmail>
        <clientId>{$ctx:uri.var.cmClientId}</clientId>
      </campaignmonitor.createDraftCampaign>	  
	  	<call-template target="responseHandlerTemplate">
			<!-- parameter values will be passed on to a sequence template -->
			(
			<with-param name="activityName" value="CampaignMonitor_createDraftCampaign" />
			|
			) *
		</call-template>		
		<filter source="$axis2:HTTP_SC" regex="(?!^201$).*">
			<then>
				<loopback/>
			</then>
		</filter>	  
	<property name="uri.var.cmCampaignId" expression="json-eval($.string)" />	
	 <campaignmonitor.init>
		<apiUrl>{$ctx:uri.var.cmApiUrl}</apiUrl>
		<accessToken>{$ctx:uri.var.cmAccessToken}</accessToken>
	 </campaignmonitor.init>		 
      <campaignmonitor.sendCampaign>
        <sendDate>{$ctx:uri.var.cmSendDate}</sendDate>
        <campaignId>{$ctx:uri.var.cmCampaignId}</campaignId>
        <confirmationEmailsList>{$ctx:uri.var.cmConfirmationEmailsList}</confirmationEmailsList>
      </campaignmonitor.sendCampaign>	  
	  <property name="messageType" value="application/json" scope="axis2"></property>	  
	  	<call-template target="responseHandlerTemplate">
			<!-- parameter values will be passed on to a sequence template -->
			(
			<with-param name="activityName" value="CampaignMonitor_sendCampaign" />
			|
			) *
		</call-template>		
	</sequence>
</template>
Sample Proxy for Creating Campaigns
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="zohocrm_fbEventCreation_cmSendCampaign"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence onError="faultHandlerSeq">	  
	  <!-- ZohoCRM insertRecords parameters -->
	  <property name="zohoApiUrl" expression="json-eval($.zohoApiUrl)"/>
      <property name="zohoAccessToken" expression="json-eval($.zohoAccessToken)"/>
      <property name="zohoScope" expression="json-eval($.zohoScope)"/>
      <property name="zohoNewFormat" expression="json-eval($.zohoNewFormat)"/>
      <property name="zohoVersion" expression="json-eval($.zohoVersion)"/>
      <property name="zohoXmlData" expression="json-eval($.zohoXmlData)"/>
      <property name="zohoWfTrigger" expression="json-eval($.zohoWfTrigger)"/>
      <property name="zohoDuplicateCheck" expression="json-eval($.zohoDuplicateCheck)"/>
      <property name="zohoIsApproval" expression="json-eval($.zohoIsApproval)"/>	  
	  <!-- facebook createEvent parameters -->
	  <property name="facebookAccessToken" expression="json-eval($.facebookAccessToken)"/>
	  <property name="facebookApiUrl" expression="json-eval($.facebookApiUrl)"/>
	  <property name="facebookEndTime" expression="json-eval($.facebookEndTime)"/>
	  <property name="facebookPrivacyType" expression="json-eval($.facebookPrivacyType)"/>
	  <property name="facebookLocationId" expression="json-eval($.facebookLocationId)"/>
	  <property name="facebookLocation" expression="json-eval($.facebookLocation)"/>	  
	  <!-- CampaignMonitor createDraftCampaign parameters-->
	  <property name="cmApiUrl" expression="json-eval($.cmApiUrl)"/>
	  <property name="cmAccessToken" expression="json-eval($.cmAccessToken)"/>
	  <property name="cmClientId" expression="json-eval($.cmClientId)"/>
      <property name="cmSubject" expression="json-eval($.cmSubject)"/>
      <property name="cmFromName" expression="json-eval($.cmFromName)"/>
      <property name="cmFromEmail" expression="json-eval($.cmFromEmail)"/>
      <property name="cmReplyToEmail" expression="json-eval($.cmReplyToEmail)"/>
      <property name="cmHtmlUrl" expression="json-eval($.cmHtmlUrl)"/>
      <property name="cmListIds" expression="json-eval($.cmListIds)"/>
      <property name="cmSegmentIds" expression="json-eval($.cmSegmentIds)"/>	  
	  <!-- CampaignMonitor sendCampaign parameters-->
      <property name="cmConfirmationEmailsList" expression="json-eval($.cmConfirmationEmailsList)"/>
      <property name="cmSendDate" expression="json-eval($.cmSendDate)"/>
	  <call-template target="zohocrm-createAndRetrieveCampaignDetails">
	   <!-- parameter values will be passed on to a sequence template -->
	   (
	   <with-param name="zohoScope" value="{$ctx:zohoScope}" /> |
	   <with-param name="zohoAccessToken" value="{$ctx:zohoAccessToken}" /> |
	   <with-param name="zohoApiUrl" value="{$ctx:zohoApiUrl}" /> |
	   <with-param name="zohoDuplicateCheck" value="{$ctx:zohoDuplicateCheck}" /> |
	   <with-param name="zohoXmlData" value="{$ctx:zohoXmlData}" /> |
	   <with-param name="zohoIsApproval" value="{$ctx:zohoIsApproval}" /> |
	   <with-param name="zohoWfTrigger" value="{$ctx:zohoWfTrigger}" /> |
	   <with-param name="zohoNewFormat" value="{$ctx:zohoNewFormat}" /> |
	   <with-param name="zohoVersion" value="{$ctx:zohoVersion}" /> |
	   ) *
	 </call-template>
	 <!-- Retrieving the name and the start date of the campaign --> 
	  <property name="campaignAttributes" expression="json-eval($.response.result.Campaigns.row.FL)"/>	 	  
     <script language="js">		 
			var jsn = eval("(" + mc.getProperty("campaignAttributes") + ")");			
			for (var i = 0; i &lt; jsn.length ; i++) { 			
			if(jsn[i].val == "Campaign Name"){
				mc.setProperty('campaignName', jsn[i].content)
			}			
			if(jsn[i].val == "Start Date"){
				mc.setProperty('campaignStartDate', jsn[i].content)
			}			
			if(jsn[i].val == "Description"){
				mc.setProperty('campaignDescription', jsn[i].content)
			}												}
		</script>	
      <call-template target="zohocrm-createFacebookEventAndSendCampaign">
	   <!-- parameter values will be passed on to a sequence template -->
	   (
	   <with-param name="facebookName" value="{$ctx:campaignName}" /> |
	   <with-param name="facebookStartTime" value="{$ctx:campaignStartDate}" /> |
	   <with-param name="facebookDescription" value="{$ctx:campaignDescription}" /> |
	   <with-param name="facebookEndTime" value="{$ctx:facebookEndTime}" /> |
	   <with-param name="facebookAccessToken" value="{$ctx:facebookAccessToken}" /> |
	   <with-param name="facebookApiUrl" value="{$ctx:facebookApiUrl}" /> |
	   <with-param name="facebookLocation" value="{$ctx:facebookLocation}" /> |
	   <with-param name="facebookLocationId" value="{$ctx:facebookLocationId}" /> |
	   <with-param name="facebookPrivacyType" value="{$ctx:facebookPrivacyType}" /> |
	   <with-param name="cmApiUrl" value="{$ctx:cmApiUrl}" /> |
	   <with-param name="cmAccessToken" value="{$ctx:cmAccessToken}" /> |
	   <with-param name="cmClientId" value="{$ctx:cmClientId}" /> |
	   <with-param name="cmName" value="{$ctx:campaignName}" /> |
	   <with-param name="cmSubject" value="{$ctx:cmSubject}" /> |
	   <with-param name="cmFromName" value="{$ctx:cmFromName}" /> |
	   <with-param name="cmFromEmail" value="{$ctx:cmFromEmail}" /> |
	   <with-param name="cmReplyToEmail" value="{$ctx:cmReplyToEmail}" /> |
	   <with-param name="cmHtmlUrl" value="{$ctx:cmHtmlUrl}" /> |
	   <with-param name="cmListIds" value="{$ctx:cmListIds}" /> |
	   <with-param name="cmSegmentIds" value="{$ctx:cmSegmentIds}" /> |
	   <with-param name="cmConfirmationEmailsList" value="{$ctx:cmConfirmationEmailsList}" /> |
	   <with-param name="cmSendDate" value="{$ctx:cmSendDate}" /> |
	   ) *
	 </call-template>
         <loopback/>
      </inSequence>
      <outSequence>
		<payloadFactory media-type="json">
			<format>
				{
				"Response":[$1]
				}
			</format>
			<args>
				<arg expression="get-property('uri.var.responseString')" />
			</args>
		</payloadFactory>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>                                                     
Sample Request for Creating Campaigns
{
	"zohoApiUrl":"https://crm.zoho.com",
	"zohoAccessToken":"542dbd71b8f52a2920ea68ca9ac5c246",
	"zohoScope":"crmapi",
	"zohoXmlData":"<Campaigns> <row no=\"1\"> <FL val=\"Campaign Name\">sar1qaz</FL><FL val=\"Start Date\">2014-08-12</FL></row> </Campaigns>",
	"facebookAccessToken":"CAACEdEose0cBAHpioYCzP7EAjRsASGth3Rsq8BDsLTW3loxZCv47VvGF2ZCgqCfYCxQGOnw87gOjaX9k9tdL2lR6rIifknsrTQpXPZB5vZBOTb0Y8mkgf1JCs3uZCgO1ar81bJtbVl599p5cZACPOAe7vCKNYALuBLqY38eSZBbZBOSgmJFYowjqHOcKto6VY3SYbEG33HMHpXyPZCDGJN6RS",
	"facebookApiUrl":"https://graph.facebook.com",
	"cmApiUrl":"https://api.createsend.com",
	"cmAccessToken":"AbnJYik59PFLgAT3Zl2HDkgyNg==",
	"cmClientId":"fc078d020bdb8b67441beece1573c988",
	"cmSubject": "My Subjaect",
	"cmFromName": "My Name",
	"cmFromEmail": "myemail@mydomain.com",
	"cmReplyToEmail": "myemail@mydomain.com",
	"cmHtmlUrl": "http://www.karelia.com/support/sandvox/help/z/Raw_HTML.html",
	"cmListIds": ["ba271882c6ea5b6f003a385b47d9b6a2"],
	"cmConfirmationEmailsList":"confirmation@example.com, another@example.com",
	"cmSendDate":"Immediately"
}

Creating leads

In addition to campaigns, you can also initiate marketing in Zoho CRM by creating leads. In this use case, we will create leads directly in Zoho CRM and obtain additional leads from Campaign Monitor and CallRail.  

To create leads
  1. Create leads directly in Zoho CRM using the insertRecords operation. You can associate each lead with a product or service that can be sold or purchased by the organization.
  2. Get details on users who click email links from Campaign Monitor using the listEmailCampaignClickers operation.

    Prerequisite

    There must be at least one person who has clicked the campaign email, sent via campaign monitor.

  3. Retrieve contact details from callers in CallRail using the listCalls operation.
Zoho CRM operations
Campaign Monitor operations
CallRail operations
Samples
Sample Template for Retrieving Details for Lead Creation
<!-- This template creates Leads in zoho crm, using the email addresses(people who clicked a link of a given campaign email) retrieved by campaign monitor API -->
<template name="zohocrm-retrieveDetailsForLeadCreation" xmlns="http://ws.apache.org/ns/synapse">
	<!-- Campaign monitor parameters -->
	<parameter name="campaignMonitorApiUrl" description="The campaign monitor api URL" />
	<parameter name="campaignMonitorAccessToken" description="The Access Token to authorize the requests" />
	<parameter name="campaignId" description="The campaign Identifier to list emails clickers" />
	<parameter name="date" description="Opens on or after the date value specified will be returned" />
	<parameter name="page" description="The results page to retrieve. Default valus is 1" />
	<parameter name="pageSize" description="The number of records to retrieve per results page. Default valus is 1000" />
	<parameter name="orderField"
		description="The field (out of email,list or date) which should be used to order the results. Default valus is email" />
	<parameter name="orderDirection" description="The direction in which results should be ordered. Default value is asc" />
	<parameter name="firstNameCM" description="The first name to be used for the leads created via Campaign Monitor" />
	<parameter name="companyNameCM" description="The company name to be used for the leads created via Campaign Monitor" />	
	<!-- Call Rail parameters -->
	<parameter name="callRailApiUrl" description="The Call Rail api URL" />
	<parameter name="callRailApiKey" description="The Api Token of the Call Rail account" />
	<parameter name="perPage" description="Indicates how many records to return for this request per page" />
	<parameter name="callRailPage" description="Indicates the page number that should be returned for this request" />
	<parameter name="companyId" description="The Identifier of a company" />
	<parameter name="startDate" description="Date or Date and Time in ISO 8601 format. Calls on or after this date will be included" />
	<parameter name="endDate" description="Date or Date and Time in ISO 8601 format. Calls on or before this date will be included" />
	<parameter name="firstNameCR" expression="Default first name of the lead, if Call Rail API call does not return source_name, will create the lead using this first name" />
	<parameter name="companyNameCR" expression="Company name of the lead being created via Call Rail Details" />	
	<sequence>
		<!-- Campaign Monitor properties -->
		<property name="uri.var.campaignMonitorApiUrl" expression="$func:campaignMonitorApiUrl" />
		<property name="uri.var.campaignMonitorAccessToken" expression="$func:campaignMonitorAccessToken" />
		<property name="uri.var.campaignId" expression="$func:campaignId" />
		<property name="uri.var.date" expression="$func:date" />
		<property name="uri.var.page" expression="$func:page" />
		<property name="uri.var.pageSize" expression="$func:pageSize" />
		<property name="uri.var.orderField" expression="$func:orderField" />
		<property name="uri.var.orderDirection" expression="$func:orderDirection" />
		<property name="uri.var.firstNameCM" expression="$func:firstNameCM" />
		<property name="uri.var.companyNameCM" expression="$func:companyNameCM" />
		<!-- Call Rail properties -->
		<property name="uri.var.callRailApiUrl" expression="$func:callRailApiUrl" />
		<property name="uri.var.callRailApiKey" expression="$func:callRailApiKey" />
		<property name="uri.var.perPage" expression="$func:perPage" />
		<property name="uri.var.callRailPage" expression="$func:callRailPage" />
		<property name="uri.var.companyId" expression="$func:companyId" />
		<property name="uri.var.startDate" expression="$func:startDate" />
		<property name="uri.var.endDate" expression="$func:endDate" />
		<property name="uri.var.firstNameCR" expression="$func:firstNameCR" />
		<property name="uri.var.companyNameCR" expression="$func:companyNameCR" />		
		<!-- Check the availability of Campaign Monitor access token to proceed with the campaign monitor API call -->		
		<filter source="boolean(get-property('uri.var.campaignMonitorAccessToken'))" regex="true">		
		<campaignmonitor.init>
			<apiUrl>{$ctx:uri.var.campaignMonitorApiUrl}</apiUrl>
			<accessToken>{$ctx:uri.var.campaignMonitorAccessToken}</accessToken>
		</campaignmonitor.init>
		<campaignmonitor.listEmailCampaignClickers>
			<orderDirection>{$ctx:uri.var.orderDirection}</orderDirection>
			<campaignId>{$ctx:uri.var.campaignId}</campaignId>
			<page>{$ctx:uri.var.page}</page>
			<orderField>{$ctx:uri.var.orderField}</orderField>
			<pageSize>{$ctx:uri.var.pageSize}</pageSize>
			<date>{$ctx:uri.var.date}</date>
		</campaignmonitor.listEmailCampaignClickers>
		<call-template target="responseHandlerTemplate">
			<!-- parameter values will be passed on to a sequence template -->
			(
			<with-param name="activityName" value="CampaignMonitor_listEmailClickers" />
			|
			) *
		</call-template>
		<property name="uri.var.results" expression="json-eval($.Results)" />
		<script language="js">
         <![CDATA[
		 var results = mc.getProperty("uri.var.results");
		 var xmlData = '';
		 if(results != null && results != ''){
			 var jsn = eval("(" + results + ")");			
			 var firstName = mc.getProperty("uri.var.firstNameCM");			
			 var companyName = mc.getProperty("uri.var.companyNameCM");				 
			 var jsonLength = jsn.length;
			 for (var i = 0; i < jsonLength ; i++) {
			 var email = jsn[i].EmailAddress;
			 xmlData += '<row no="' + (i+1) + '"><FL val="First Name">' + firstName + '</FL><FL val="Last Name">' + email + '</FL><FL val="Company">' + companyName + '</FL></row>';			
			}			 
		 mc.setProperty('uri.var.index', jsonLength);
		 mc.setProperty('uri.var.xmlDataVar', xmlData);
		 }
		 ]]>
		</script>
		<header name="Access-Control-Allow-Headers" scope="transport" action="remove" />
		<header name="Access-Control-Allow-Origin" scope="transport" action="remove" />
		<header name="P3P" scope="transport" action="remove" />
		<header name="Access-Control-Allow-Methods" scope="transport" action="remove" />
		<header name="Content-Type" scope="transport" action="remove" />
		<header name="X-CS-Node" 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="status" scope="transport" action="remove" />
		<header name="Transfer-Encoding" scope="transport" action="remove" />
		<header name="Connection" scope="transport" action="remove" />
		<property name="DISABLE_CHUNKING" value="true" scope="axis2" />
		<property name="Content-Type" value="application/json" scope="transport" type="STRING" />
		<property name="Accept" value="application/json" scope="transport" type="STRING" />	
		</filter>
			<!-- Check the availability of CallRail access token to proceed with the CallRail API call -->		
		<filter source="boolean(get-property('uri.var.callRailApiKey'))" regex="true">	
         <callrail.init>
            <apiUrl>{$ctx:uri.var.callRailApiUrl}</apiUrl>
            <apiKey>{$ctx:uri.var.callRailApiKey}</apiKey>
         </callrail.init>
         <callrail.listCalls>
            <startDate>{$ctx:uri.var.startDate}</startDate>
            <page>{$ctx:uri.var.callRailPage}</page>
            <endDate>{$ctx:uri.var.endDate}</endDate>
            <companyId>{$ctx:uri.var.companyId}</companyId>
            <perPage>{$ctx:uri.var.perPage}</perPage>
         </callrail.listCalls>		
		<call-template target="responseHandlerTemplate">
			<!-- parameter values will be passed on to a sequence template -->
			(
			<with-param name="activityName" value="CallRail_listCalls" />|
			) *
		</call-template>		
		<property name="uri.var.callRailResults" expression="json-eval($.calls)" />
		<script language="js">
         <![CDATA[
		 var callRailResults = mc.getProperty("uri.var.callRailResults");
		 if(callRailResults != null && callRailResults != ''){		 
			 var jsn = eval("(" + callRailResults + ")");		
			 var firstName = mc.getProperty("uri.var.firstNameCR");			
			 var companyName = mc.getProperty("uri.var.companyNameCR");				 
			 var xmlData = mc.getProperty("uri.var.xmlDataVar");
			 // Null check to avoid null appending in the xmlData var
			 if(xmlData == null){
				xmlData = '';
			 }			 
			 var index = mc.getProperty("uri.var.index");				 			 
			 for (var i = 0; i < jsn.length ; i++) {
				 var firstNameCR = firstName;
				 var phoneNumber = jsn[i].tracking_number;
				 var sourceName = jsn[i].source_name;
				 if(sourceName != null && sourceName != ''){
					firstNameCR = sourceName;
				 }	
				 xmlData += '<row no="' + eval((i+1) + '+' + index) + '"><FL val="First Name">' + firstNameCR + '</FL><FL val="Last Name">' + phoneNumber + '</FL><FL val="Company">' + companyName + '</FL></row>';			
			 }
			 mc.setProperty('uri.var.xmlDataVar', xmlData);
		 }
		 ]]>
		</script>		
		<header name="Status" scope="transport" action="remove" />
		<header name="Content-Encoding" scope="transport" action="remove" />
		<header name="Content-Type" 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" />
		<header name="Transfer-Encoding" scope="transport" action="remove" />	
		<property name="DISABLE_CHUNKING" value="true" scope="axis2" />
		<property name="Content-Type" value="application/json" scope="transport" type="STRING" />
		<property name="Accept" value="application/json" scope="transport" type="STRING" />		
		</filter>		
	</sequence>
</template> 
Sample Proxy for Creating Leads
 
<proxy xmlns="http://ws.apache.org/ns/synapse" name="zohocrm_createLeads" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
  <target>
    <inSequence>
      <property name="apiUrl" expression="json-eval($.apiUrl)"/>
      <property name="accessToken" expression="json-eval($.accessToken)"/>
      <property name="scope" expression="json-eval($.scope)"/>
      <property name="newFormat" expression="json-eval($.newFormat)"/>
      <property name="version" expression="json-eval($.version)"/>
      <property name="xmlData" expression="json-eval($.xmlData)"/>
      <property name="wfTrigger" expression="json-eval($.wfTrigger)"/>
      <property name="duplicateCheck" expression="json-eval($.duplicateCheck)"/>
      <property name="isApproval" expression="json-eval($.isApproval)"/>
	  <property name="moduleType" value="Leads"/>      
      <zohocrm.init>
        <scope>{$ctx:scope}</scope>
        <accessToken>{$ctx:accessToken}</accessToken>
        <apiUrl>{$ctx:apiUrl}</apiUrl>
      </zohocrm.init>
	  <zohocrm.insertRecords>
	    <moduleType>{$ctx:moduleType}</moduleType>
        <duplicateCheck>{$ctx:duplicateCheck}</duplicateCheck>
        <xmlData>{$ctx:xmlData}</xmlData>
        <isApproval>{$ctx:isApproval}</isApproval>
        <wfTrigger>{$ctx:wfTrigger}</wfTrigger>
        <newFormat>{$ctx:newFormat}</newFormat>
        <version>{$ctx:version}</version>
      </zohocrm.insertRecords>	  
	  <respond></respond>
    </inSequence>
    <outSequence>
      <send></send>
    </outSequence>
  </target>
</proxy>
Sample Request for Creating Leads
{
	"apiUrl":"https://crm.zoho.com",
	"accessToken":"ec6e6a23eb5ee563fd3b48147abb80df",
	"scope":"crmapi",
	"xmlData":"<Campaigns> <row no=\"1\"> <FL val=\"Campaign Name\">First Campaign asdasdadasda</FL> </row> </Campaigns>",
	"moduleType":"Campaigns",
	"newFormat":1,
	"version":1
}                                         
Sample Proxy for Generating Leads
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="zohocrm_generateLeads"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>		
		<!-- Zoho CRM API call related properties -->
		<property name="zohoApiUrl" expression="json-eval($.zohoApiUrl)"/>
		<property name="zohoAccessToken" expression="json-eval($.zohoAccessToken)"/>
		<property name="scope" expression="json-eval($.scope)"/>		
		<property name="firstNameCM" expression="json-eval($.firstNameCM)"/>
		<property name="companyNameCM" expression="json-eval($.companyNameCM)"/>		
		<property name="newFormat" expression="json-eval($.newFormat)"/>
		<property name="version" expression="json-eval($.version)"/>
		<property name="wfTrigger" expression="json-eval($.wfTrigger)"/>
		<property name="duplicateCheck" expression="json-eval($.duplicateCheck)"/>
		<property name="isApproval" expression="json-eval($.isApproval)"/>
		<property name="moduleType" value="Leads"/>		
		<!-- Campaign monitor API call related properties -->
		<property name="campaignMonitorApiUrl" expression="json-eval($.campaignMonitorApiUrl)"/>
        <property name="campaignMonitorAccessToken" expression="json-eval($.campaignMonitorAccessToken)"/>	  
        <property name="campaignId" expression="json-eval($.campaignId)"/>
		<property name="date" expression="json-eval($.date)"/>
        <property name="page" expression="json-eval($.page)"/>	  
        <property name="pageSize" expression="json-eval($.pageSize)"/>
		<property name="orderField" expression="json-eval($.orderField)"/>	
		<property name="orderDirection" expression="json-eval($.orderDirection)"/>			
		<!-- CallRail API call related properties -->
		<property name="callRailApiUrl" expression="json-eval($.callRailApiUrl)"/>
		<property name="callRailApiKey" expression="json-eval($.callRailApiKey)"/>
		<property name="perPage" expression="json-eval($.perPage)"/>
		<property name="callRailPage" expression="json-eval($.callRailPage)"/>
		<property name="companyId" expression="json-eval($.companyId)"/>
		<property name="startDate" expression="json-eval($.startDate)"/>
		<property name="endDate" expression="json-eval($.endDate)"/> 
		<property name="firstNameCR" expression="json-eval($.firstNameCR)" />
		<property name="companyNameCR" expression="json-eval($.companyNameCR)" />		 
		<call-template target="zohocrm-retrieveDetailsForLeadCreation">
		   <!-- parameter values will be passed on to a sequence template -->
		   (
		   <with-param name="campaignMonitorApiUrl" value="{$ctx:zohoScope}" /> |
		   <with-param name="campaignMonitorAccessToken" value="{$ctx:campaignMonitorAccessToken}" /> |
		   <with-param name="campaignId" value="{$ctx:campaignId}" /> |		   
		   <with-param name="date" value="{$ctx:date}" /> |
		   <with-param name="page" value="{$ctx:page}" /> |
		   <with-param name="pageSize" value="{$ctx:pageSize}" /> |
		   <with-param name="orderField" value="{$ctx:orderField}" /> |
		   <with-param name="orderDirection" value="{$ctx:orderDirection}" /> |		   
		   <with-param name="firstNameCM" value="{$ctx:firstNameCM}" /> |		   
		   <with-param name="companyNameCM" value="{$ctx:companyNameCM}" /> |		   
		   <with-param name="callRailApiUrl" value="{$ctx:callRailApiUrl}" /> |		   
		   <with-param name="callRailApiKey" value="{$ctx:callRailApiKey}" /> |
		   <with-param name="perPage" value="{$ctx:perPage}" /> |		   
		   <with-param name="callRailPage" value="{$ctx:callRailPage}" /> |
		   <with-param name="companyId" value="{$ctx:companyId}" /> |
		   <with-param name="startDate" value="{$ctx:startDate}" /> |		   
		   <with-param name="endDate" value="{$ctx:endDate}" /> |
		   <with-param name="firstNameCR" value="{$ctx:firstNameCR}" /> |		   
		   <with-param name="companyNameCR" value="{$ctx:companyNameCR}" /> |
		   ) *
		</call-template>
		<!-- If xmlData was not populated(Previous API calls were failed or skipped by user details) by above API calls-->		
		<filter source="boolean(get-property('uri.var.xmlDataVar'))" regex="true">
		<property name="xmlDataVal" expression="fn:concat('&lt;Leads&gt;' , get-property('uri.var.xmlDataVar') , '&lt;/Leads&gt;')"/>
			<zohocrm.init>
				<scope>{$ctx:scope}</scope>
				<accessToken>{$ctx:zohoAccessToken}</accessToken>
				<apiUrl>{$ctx:zohoApiUrl}</apiUrl>
			</zohocrm.init>
			<zohocrm.insertRecords>
				<moduleType>{$ctx:moduleType}</moduleType>
				<duplicateCheck>{$ctx:duplicateCheck}</duplicateCheck>
				<xmlData>{$ctx:xmlDataVal}</xmlData>
				<isApproval>{$ctx:isApproval}</isApproval>
				<wfTrigger>{$ctx:wfTrigger}</wfTrigger>
				<newFormat>{$ctx:newFormat}</newFormat>
				<version>{$ctx:version}</version>
			</zohocrm.insertRecords>
			<call-template target="responseHandlerTemplate">
				<!-- parameter values will be passed on to a sequence template -->
				(
				<with-param name="activityName" value="ZohoCRM_insertRecords" />|
				) *
			</call-template>		
		</filter>		
         <loopback/>
      </inSequence>
      <outSequence>
        <!-- Generate the chained response of all the API calls in createLeads -->
		<payloadFactory media-type="json">
			<format>
				{
				"Response":[$1]
				}
			</format>
			<args>
				<arg expression="get-property('uri.var.responseString')" />
			</args>
		</payloadFactory>		
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>
                                
Sample Request for Generating Leads
{
	"campaignMonitorApiUrl":"https://api.createsend.com",
	"campaignMonitorAccessToken":"AUew4legQ65Mt+JvrTC/AH8yNg==",
	"campaignId":"aa46c061c346f65970af0968c82f9a70",
	"firstNameCM":"leadFN111",
	"companyNameCM":"companyN111",
	"scope":"crmapi",
	"callRailApiUrl":"https://api.callrail.com",
	"callRailApiKey":"35393c708b09dac14357859e8afb01e7",
	"perPage":"",
	"callRailPage":"1",
	"companyId":"",
	"startDate":"2014-07-08T13:38:40Z",
	"endDate":"2014-09-08T13:38:42Z",
	"firstNameCR":"CallRailFN111",
	"companyNameCR":"CallRailCN111",
	"zohoApiUrl":"https://crm.zoho.com",
	"zohoAccessToken":"62edb605ed1e7a93165efd3d4c598358"
}

"companyNameCM" will identify the lead being generated from Campaign Monitor while "companyNameCR" will identify the lead being generated from CallRail. When generating the lead in Zoho CRM, you can identify where the leads are coming from using these two parameters.

Converting leads

After identifying leads, you qualify them and then convert them or update them as junk.

To convert and update leads
  1. Convert qualified leads to an Account (organization), Contact (individual), or Potential (opportunity) in Zoho CRM using the convertLead operation. You must create at least one lead in Zoho CRM to continue.
  2. Retrieve the relevant details of your contacts using the getRecordsById operation from Zoho CRM and then create customers in QuickBooks from your Zoho CRM contacts using the createCustomer operation.
Zoho CRM operations
QuickBooks operations
Samples
Sample Template for Converting a Lead
<template xmlns="http://ws.apache.org/ns/synapse" name="zohocrm-convertLead">
   <parameter name="zohoApiUrl" description="The api url" />
   <parameter name="zohoAccessToken" description="Encrypted alphanumeric string to authenticate the Zoho credentials" />
   <parameter name="zohoLeadId" description="The id of the lead which want to covertd to a contact" />
   <parameter name="zohoNewFormat" description="The newFormat, an integer determine weather null valus should be excluded(1) or included(2)" />
   <parameter name="zohoVersion" description="The API version" />
   <parameter name="zohoXmlData" description="The xml string containing the data to be inserted" />
   <parameter name="zohoScope" description="Specify the value as crmapi" />
   <parameter name="zohoWfTrigger" description="The wfTrigger parameter is used to trigger the workflow rule while inserting record into CRM account" />
   <sequence>
      <property name="uri.var.zohoApiUrl" expression="$func:zohoApiUrl" />
      <property name="uri.var.zohoAccessToken" expression="$func:zohoAccessToken" />
      <property name="uri.var.zohoLeadId" expression="$func:zohoLeadId" />
      <property name="uri.var.zohoNewFormat" expression="$func:zohoNewFormat" />
      <property name="uri.var.zohoVersion" expression="$func:zohoVersion" />
      <property name="uri.var.zohoXmlData" expression="$func:zohoXmlData" />
      <property name="uri.var.zohoScope" expression="$func:zohoScope" />
      <property name="uri.var.zohoModuleType" value="Contacts" />
      <property name="uri.var.zohoWfTrigger" expression="$func:zohoWfTrigger" />	  
      <!--Checking user status before convert Lead-->
      <zohocrm.init>
         <apiUrl>{$ctx:uri.var.zohoApiUrl}</apiUrl>
         <accessToken>{$ctx:uri.var.zohoAccessToken}</accessToken>
         <scope>{$ctx:uri.var.zohoScope}</scope>
      </zohocrm.init>
      <zohocrm.getRecordsById>
         <id>{$ctx:uri.var.zohoLeadId}</id>
         <newFormat>{$ctx:uri.var.zohoNewFormat}</newFormat>
         <version>{$ctx:uri.var.zohoVersion}</version>
         <moduleType>Leads</moduleType>
      </zohocrm.getRecordsById>	  
      <!--Removing headers-->
      <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" />	  
      <call-template target="responseHandlerTemplate">
         <!-- parameter values will be passed on to a sequence template -->
         (
         <with-param name="activityName" value="zohocrm_getLeadById" /> |
		 ) *
      </call-template>	  
      <property name="uri.var.leadAttributes" expression="json-eval($.response.result.Leads.row.FL)" />      
      <!-- Check the availability of zohoContactId to proceed with other API calls -->
      <filter source="boolean(get-property('uri.var.leadAttributes'))" regex="false">
         <loopback />
      </filter>	  
      <script language="js">
			var jsn = eval("(" + mc.getProperty("uri.var.leadAttributes") + ")");		
			for (var i = 0; i &lt; jsn.length ; i++) {			
				if(jsn[i].val == "Lead Status"){
						mc.setProperty('qbLeadStatus', jsn[i].content);
				}
			}
	  </script>	  
      <!--Converting Lead to a Contact, only if the Lead status is Pre Qualified-->
      <filter source="get-property('qbLeadStatus')" regex="Pre Qualified">
		  <then>
		  <!--Converting Lead to a Contact -->
		  <zohocrm.init>
			 <apiUrl>{$ctx:uri.var.zohoApiUrl}</apiUrl>
			 <accessToken>{$ctx:uri.var.zohoAccessToken}</accessToken>
			 <scope>{$ctx:uri.var.zohoScope}</scope>
		  </zohocrm.init>
		  <zohocrm.convertLead>
			 <newFormat>{$ctx:uri.var.zohoNewFormat}</newFormat>
			 <leadId>{$ctx:uri.var.zohoLeadId}</leadId>
			 <xmlData>{$ctx:uri.var.zohoXmlData}</xmlData>
			 <version>{$ctx:uri.var.zohoVersion}</version>
		  </zohocrm.convertLead>		  
		  <!--Removing headers-->
		  <property name="uri.var.zohoContactId" expression="json-eval($.success.Contact.content)" />
		  <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" />	  
		  <call-template target="responseHandlerTemplate">
			 <!-- parameter values will be passed on to a sequence template -->
			 (
			 <with-param name="activityName" value="zohocrm_convertLead" />|
			 ) *
		  </call-template>		  
		  <!-- Check the availability of zohoContactId to proceed with other API calls -->
		  <filter source="boolean(get-property('uri.var.zohoContactId'))" regex="false">
			 <loopback />
		  </filter>		  
		  <zohocrm.init>
			 <apiUrl>{$ctx:uri.var.zohoApiUrl}</apiUrl>
			 <accessToken>{$ctx:uri.var.zohoAccessToken}</accessToken>
			 <scope>{$ctx:uri.var.zohoScope}</scope>
		  </zohocrm.init>
		  <zohocrm.getRecordsById>
			 <id>{$ctx:uri.var.zohoContactId}</id>
			 <newFormat>{$ctx:uri.var.zohoNewFormat}</newFormat>
			 <version>{$ctx:uri.var.zohoVersion}</version>
			 <moduleType>{$ctx:uri.var.zohoModuleType}</moduleType>			 
		  </zohocrm.getRecordsById>		  
		  <!--Removing headers-->
		  <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" />
		  <call-template target="responseHandlerTemplate">
			 <!-- parameter values will be passed on to a sequence template -->
			 (
			 <with-param name="activityName" value="zohocrm_getRecordsById" />|
			 ) *
		  </call-template>		  
		  <!-- Retrieving Contact information -->
		  <property name="uri.var.contactAttributes" expression="json-eval($.response.result.Contacts.row.FL)" />		  
		  <!-- Check the availability of contactAttributes proceed with other API calls -->
		  <filter source="boolean(get-property('uri.var.contactAttributes'))" regex="false">
			 <loopback />
		  </filter>
	  </then>
	  <else>
		<!-- If the contact status is not "Pre Qualified", the lead will not be converted -->
		<payloadFactory media-type="json">
				<format>
					{
					"response":"Lead is not in Pre Qualified state. Therefore, Lead will not be converted."
					}
				</format>
			</payloadFactory>
			<call-template target="responseHandlerTemplate">
				<!-- parameter values will be passed on to a sequence template -->
				(
				<with-param name="activityName" value="zohocrm_convertLeadFailure" />|
				) *
			</call-template>
			 <loopback />
         <loopback />
	  </else>	  
      </filter>	  
   </sequence>
</template>
Sample Proxy for Converting Leads
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="zohocrm_qbCreateContact"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence onError="faultHandlerSeq">	  
	  <!-- ZohoCRM convertLead parameters -->
		<property name="zohoApiUrl" expression="json-eval($.zohoApiUrl)"/>
		<property name="zohoAccessToken" expression="json-eval($.zohoAccessToken)"/>
		<property name="zohoScope" expression="json-eval($.zohoScope)"/>
		<property name="zohoXmlData" expression="json-eval($.zohoXmlData)"/>
		<property name="zohoLeadId" expression="json-eval($.zohoLeadId)"/>
		<property name="zohoNewFormat" expression="json-eval($.zohoNewFormat)"/>
		<property name="zohoVersion" expression="json-eval($.zohoVersion)"/>
		<property name="zohoStatus" expression="json-eval($.zohoStatus)"/>
		<property name="zohoWfTrigger" expression="json-eval($.zohoWfTrigger)"/>	  
	  <!-- Quickbooks createCustomer parameters -->
		 <property name="qbApiUrl" expression="json-eval($.qbApiUrl)"/>
		 <property name="qbConsumerKey" expression="json-eval($.qbConsumerKey)"/>
         <property name="qbConsumerSecret" expression="json-eval($.qbConsumerSecret)"/>
		 <property name="qbAccessToken" expression="json-eval($.qbAccessToken)"/>
		 <property name="qbAccessTokenSecret" expression="json-eval($.qbAccessTokenSecret)"/>
		 <property name="qbResponseType" expression="json-eval($.qbResponseType)"/>
		 <property name="qbCompanyId" expression="json-eval($.qbCompanyId)"/>		 
		 <property name="qbPrimaryEmailAddr" expression="json-eval($.qbPrimaryEmailAddr)"/>
         <property name="qbDefaultTaxCodeRef" expression="json-eval($.qbDefaultTaxCodeRef)"/>
         <property name="qbPreferredDeliveryMethod" expression="json-eval($.qbPreferredDeliveryMethod)"/>
         <property name="qbFamilyName" expression="json-eval($.qbFamilyName)"/>
         <property name="qbGivenName" expression="json-eval($.qbGivenName)"/>
         <property name="qbResaleNum" expression="json-eval($.qbResaleNum)"/>
         <property name="qbWebAddr" expression="json-eval($.qbWebAddr)"/>
         <property name="qbBalanceWithJobs" expression="json-eval($.qbBalanceWithJobs)"/>
         <property name="qbBalance" expression="json-eval($.qbBalance)"/>
         <property name="qbTitle" expression="json-eval($.qbTitle)"/>
         <property name="qbLevel" expression="json-eval($.qbLevel)"/>
         <property name="qbSalesTermRef" expression="json-eval($.qbSalesTermRef)"/>
         <property name="qbPaymentMethodRef" expression="json-eval($.qbPaymentMethodRef)"/>
         <property name="qbFullyQualifiedName" expression="json-eval($.qbFullyQualifiedName)"/>
         <property name="qbMiddleName" expression="json-eval($.qbMiddleName)"/>
         <property name="qbParentRef" expression="json-eval($.qbParentRef)"/>
         <property name="qbBillAddr" expression="json-eval($.qbBillAddr)"/>
         <property name="qbFax" expression="json-eval($.qbFax)"/>
         <property name="qbTaxable" expression="json-eval($.qbTaxable)"/>
         <property name="qbShipAddr" expression="json-eval($.qbShipAddr)"/>
         <property name="qbJob" expression="json-eval($.qbJob)"/>
         <property name="qbCurrencyRef" expression="json-eval($.qbCurrencyRef)"/>
         <property name="qbCompanyName" expression="json-eval($.qbCompanyName)"/>
         <property name="qbSuffix" expression="json-eval($.qbSuffix)"/>
         <property name="qbOpenBalanceDate" expression="json-eval($.qbOpenBalanceDate)"/>
         <property name="qbPrintOnCheckName" expression="json-eval($.qbPrintOnCheckName)"/>
         <property name="qbPrimaryPhone" expression="json-eval($.qbPrimaryPhone)"/>
         <property name="qbActive" expression="json-eval($.qbActive)"/>
         <property name="qbDisplayName" expression="json-eval($.qbDisplayName)"/>
         <property name="qbNotes" expression="json-eval($.qbNotes)"/>
         <property name="qbBillWithParent" expression="json-eval($.qbBillWithParent)"/>
         <property name="qbAlternatePhone" expression="json-eval($.qbAlternatePhone)"/>
         <property name="qbMobile" expression="json-eval($.qbMobile)"/>	 	  
      <call-template target="zohocrm-convertLead">
	   <!-- parameter values will be passed on to a sequence template -->
	   (
	   <with-param name="zohoApiUrl" value="{$ctx:zohoApiUrl}" /> |
	   <with-param name="zohoAccessToken" value="{$ctx:zohoAccessToken}" /> |
	   <with-param name="zohoScope" value="{$ctx:zohoScope}" /> |
	   <with-param name="zohoLeadId" value="{$ctx:zohoLeadId}" /> |
	   <with-param name="zohoXmlData" value="{$ctx:zohoXmlData}" /> |
	   <with-param name="zohoNewFormat" value="{$ctx:zohoNewFormat}" /> |
	   <with-param name="zohoVersion" value="{$ctx:zohoVersion}" /> |
	   <with-param name="zohoWfTrigger" value="{$ctx:zohoWfTrigger}" />
	   ) *
	 </call-template>
	  <script language="js">		 
			var jsn = eval("(" + mc.getProperty("uri.var.contactAttributes") + ")");
			var billAddress = '';			
			for (var i = 0; i &lt; jsn.length ; i++) { 			
				if(jsn[i].val == "First Name"){
					var firstName = jsn[i].content;
					//Trims the first name, if it exceeds the maximum allowed length(25) in Quickbooks API
					if(firstName.length &gt; 25){
						firstName = firstName.substring(0, 25);
					}
					mc.setProperty('qbGivenName', firstName);
				}
				if(jsn[i].val == "Last Name"){
					var lastName = jsn[i].content;
					//Trims the last name, if it exceeds the maximum allowed length(25) in Quickbooks API					
					if(lastName.length &gt; 25){
						lastName = lastName.substring(0, 25);
					}
					mc.setProperty('qbFamilyName', lastName);
				}
				if(jsn[i].val == "Phone"){
					mc.setProperty('qbPrimaryPhone', '{\"FreeFormNumber\":\"' +jsn[i].content+'\"}');
				}
				if(jsn[i].val == "Mobile"){
					mc.setProperty('qbMobile', '{\"FreeFormNumber\":\"' +jsn[i].content+'\"}');
				}
				if(jsn[i].val == "Fax"){
					mc.setProperty('qbFax', '{\"FreeFormNumber\":\"' +jsn[i].content+'\"}');
				}
				if(jsn[i].val == "Email"){
					mc.setProperty('qbPrimaryEmailAddr','{\"Address\":\"' +jsn[i].content+'\"}');
				}	
				if(jsn[i].val == "Description"){
					mc.setProperty('qbDescription',jsn[i].content);
				}
				if(jsn[i].val == "Mailing Street"){
					billAddress = '\"Line1\":\"' + jsn[i].content + '\",';
				}
				if(jsn[i].val == "Mailing State"){
					billAddress = '\"Line2\":\"' + jsn[i].content + '\",';
				}
				if(jsn[i].val == "Mailing City"){
					billAddress = '\"City\":\"' + jsn[i].content + '\",';
				}
				if(jsn[i].val == "Mailing Country"){
					billAddress = '\"Country\":\"' + jsn[i].content + '\",';
				}				
			}			
			if(billAddress.length > 0){
				billAddress = '{' + billAddress.substring(0, billAddress.length -1) + '}';	
				mc.setProperty('uri.var.qbBillAddress', billAddress);
			}						
		</script>
		<property name="REQUEST_HOST_HEADER" expression="fn:concat(get-property('uri.var.hostHeader'),':443')" scope="axis2" />
		<property name="messageType" value="application/json" scope="axis2" />			 
		<quickbooks.init>
            <apiUrl>{$ctx:qbApiUrl}</apiUrl>
			<consumerKey>{$ctx:qbConsumerKey}</consumerKey>
            <accessToken>{$ctx:qbAccessToken}</accessToken>
            <accessTokenSecret>{$ctx:qbAccessTokenSecret}</accessTokenSecret>
            <responseType>{$ctx:qbResponseType}</responseType>            
            <companyId>{$ctx:qbCompanyId}</companyId>
            <consumerSecret>{$ctx:qbConsumerSecret}</consumerSecret>
			<notes>{$ctx:qbDescription}</notes>
		</quickbooks.init>		   
      <quickbooks.createCustomer>
            <givenName>{$ctx:qbGivenName}</givenName>
			<familyName>{$ctx:qbFamilyName}</familyName>
			<primaryPhone>{$ctx:qbPrimaryPhone}</primaryPhone>
			<mobile>{$ctx:qbMobile}</mobile>
			<fax>{$ctx:qbFax}</fax>
			<primaryEmailAddr>{$ctx:qbPrimaryEmailAddr}</primaryEmailAddr>
			<billAddr>{$ctx:qbBillAddress}</billAddr>
			<notes>{$ctx:qbDescription}</notes>
            <defaultTaxCodeRef>{$ctx:qbDefaultTaxCodeRef}</defaultTaxCodeRef>
            <preferredDeliveryMethod>{$ctx:qbPreferredDeliveryMethod}</preferredDeliveryMethod>
            <resaleNum>{$ctx:qbResaleNum}</resaleNum>
            <webAddr>{$ctx:qbWebAddr}</webAddr>
            <balanceWithJobs>{$ctx:qbBalanceWithJobs}</balanceWithJobs>
            <balance>{$ctx:qbBalance}</balance>
            <title>{$ctx:qbTitle}</title>
            <level>{$ctx:qbLevel}</level>
            <salesTermRef>{$ctx:qbSalesTermRef}</salesTermRef>
            <paymentMethodRef>{$ctx:qbPaymentMethodRef}</paymentMethodRef>
            <fullyQualifiedName>{$ctx:qbFullyQualifiedName}</fullyQualifiedName>
            <middleName>{$ctx:qbMiddleName}</middleName>
            <parentRef>{$ctx:qbParentRef}</parentRef>
            <taxable>{$ctx:qbTaxable}</taxable>
            <shipAddr>{$ctx:qbShipAddr}</shipAddr>
            <job>{$ctx:qbJob}</job>
            <currencyRef>{$ctx:qbCurrencyRef}</currencyRef>
            <companyName>{$ctx:qbCompanyName}</companyName>
            <suffix>{$ctx:qbSuffix}</suffix>
            <openBalanceDate>{$ctx:qbOpenBalanceDate}</openBalanceDate>
            <printOnCheckName>{$ctx:qbPrintOnCheckName}</printOnCheckName>
            <active>{$ctx:qbActive}</active>
            <displayName>{$ctx:qbDisplayName}</displayName>
            <billWithParent>{$ctx:qbBillWithParent}</billWithParent>
            <alternatePhone>{$ctx:qbAlternatePhone}</alternatePhone>
      </quickbooks.createCustomer>			
		<call-template target="responseHandlerTemplate">
			<!-- parameter values will be passed on to a sequence template -->
			(
			<with-param name="activityName" value="quickbooks_createCustomer" />|
			) *
		</call-template>	  
		 <loopback/>
      </inSequence>
      <outSequence>
	  <property name="messageType" value="application/json" scope="axis2" />
	  <log/>
	  	<!-- Generate the chained response of all the API calls in createLeads -->
		<payloadFactory media-type="json">
			<format>
				{
				"Response":[$1]
				}
			</format>
			<args>
				<arg expression="get-property('uri.var.responseString')" />
			</args>
		</payloadFactory>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>                                                                
Sample Request for Converting Leads
{
	"zohoApiUrl":"https://crm.zoho.com",
	"zohoAccessToken":"7c6fd52cbba36d4e2f52a0b72e3d0c3d",
	"zohoScope":"crmapi",
	"zohoXmlData":"<Potentials> <row no=\"1\"> <option val=\"createPotential\">false</option> <option val=\"assignTo\">sample@zoho.com</option> <option val=\"notifyLeadOwner\">true</option> <option val=\"notifyNewEntityOwner\">true</option> </row> </Potentials>",
	"zohoLeadId":"1243891000000075007",
	"zohoNewFormat":1,
	"zohoVersion":1,
	"qbConsumerKey": "qyprde65hxlj2f4bcmanHiYDRnxDKj",
	"qbConsumerSecret": "gJgH4P1wVFc6E2iJVvxqvGEyIn8nFNURL2T1dcgf",
	"qbAccessToken": "qyprdf1vWLRxPOKaLmn9Sm74PVOvylngPcmicHaZEEZGlQHF",
	"qbAccessTokenSecret": "lBJt7x0L0zHz5HLIWf2DxRQmsTmG83Z1Q8mUUmBQ",
	"qbResponseType": "application/json",
	"qbApiUrl": "https://qb.sbfinance.intuit.com:443",
	"qbCompanyId": "1280103025"
}