• Home
  • Blog
  • Zapier Custom Trigger Integration for Referral Reactor & Salesforce
Zapier Custom Trigger with SF

In our previous blog on Dispatch-Salesforce integration, we demonstrated how to integrate Dispatch with Salesforce using Zapier. In this blog, we will discuss Zapier Custom Trigger Integration for Referral Reactor(Webhook) & Salesforce(REST API).

What is Referral Reactor ?

Referral Reactor is a referral management platform that allows businesses to track and manage their referral programs. A Salesforce Development Company in India uses Referral Reactor to easily track and manage referrals, set up and manage referral campaigns, and provide rewards to referral sources.

The platform integrates with a variety of other systems, including Salesforce, making it an attractive option for businesses looking to automate and streamline their referral processes.


Today we will discuss how to integrate Referral Reactor with Salesforce using Zapier.

The integration of Referral Reactor and Salesforce using Zapier can be done in a few simple steps. Firstly, businesses need to set up a Zapier account and connect both Referral Reactor and Salesforce to it. Then, they can create a Zap that automatically transfers data from Referral Reactor to Salesforce or vice versa.

For example, we can set up a Zap that creates a new Lead record in Salesforce when a new referral is created in Referral Reactor.

1. First we create a connected app in salesforce.

A Connected App in Salesforce is used to integrate external applications with Salesforce. To get the URL, client ID, and client secret key, you will need to create a Connected App in Salesforce. 

1.1 Go to your Salesforce account and click on the “Setup” button.

1.2 In the left-side menu, search for “App Manager” and click on it.

1.3 Click on the “New Connected App” button.

1.4 Fill in the required information for the Connected App, such as name, contact email, and API name.

1.5 Under “API (Enable OAuth Settings)”, check the “Enable OAuth Settings” checkbox and enter a callback URL.

1.6 Click on the “Save” button.

1.7 Once the Connected App has been created, you can find the “Client ID” and “Client Secret” in the “Consumer Key” and “Consumer Secret” sections.

1.8 The URL can be found in the “Callback URL” section, which you entered in step 1.5.

2. Now we move to zapier.

Now first we create a “zap” in Zapier

1. Catch Raw Hook in webhooks by Zapier.

First, we understand how this action works in Zapier.

  • Catch Hook is a feature in Zapier that allows you to capture data from a webhook and use it as a trigger for your Zap. A webhook is a mechanism that allows you to send data from one application to another over the internet.
  • When you create a Catch Hook, Zapier provides you with a unique URL. You can send data to this URL from another application, and Zapier will automatically capture that data and use it as the trigger for your Zap. 


2. POST in webhooks by Zapier.

How does this step work?

The “POST” action in a Webhook by Zapier is a type of HTTP request method used to send data to a server. In the context of Zapier, a POST request can be used to create a new record or update an existing record in an external application through a Zap. The POST action is typically used in the “Action” step of a Zap, and it requires a URL endpoint to be specified, along with any required headers and payload data that needs to be sent with the request. The response from the server can be used to trigger additional steps in the Zap or to pass data back to Salesforce or another app in the Zap.

In this step, when writing the URL, include the client ID and client secret obtained from the connected app inside.

3. Custom Request in Webhooks by Zapier.

What is the use of this step?

The Custom Request action in Webhook by Zapier allows you to make a custom HTTP request to an API. This action allows you to send data from Zapier to an external service or receive data from an external service to be used in a Zap. The Custom Request action can be used for a variety of purposes such as updating a database, creating a new entry, or retrieving data. It supports various HTTP methods such as GET, POST, PUT, PATCH, and DELETE. Additionally, it allows you to specify custom headers and payloads, giving you complete control over the format of the request being sent. The Custom Request action is a powerful tool that can be used to integrate Zapier with a wide range of APIs.

Here we use POST action.

The POST action in Zapier’s Webhook by Zapier action allows you to send data to a specified URL using the HTTP POST method. This is useful for triggering an action in another system or sending data to a third-party API. To use the POST action, you first need to specify the URL where you want to send the data. Then, you can configure the data that you want to send using the Body field. The Body field allows you to specify a JSON payload or other data format that will be sent in the body of the HTTP POST request. You can also use variables from previous steps in your Zap to dynamically generate the data that is sent. Once the Zap is triggered and the POST action runs, the data will be sent to the specified URL and can be used to trigger an action or update information in another system.

In this step, in the data variable of the Zap, select ‘Raw body’ obtained from the first step and add ‘Authorization’ with the value ‘Bearer [access token obtained from the second step of the Zap]’. The URL should be the base URL followed by ‘/services/apex/rest/contact’, which will call the Apex class annotated with ‘@RestResource(urlMapping=’/contact/*’)’. This data will be passed to the Apex class, where a new Lead record will be inserted in Salesforce using the information provided.

This is the Apex class used to create a Lead record.

global without sharing class referralreactor {
    global static string createContact() {
        Contact con= new Contact();
        RestRequest req = RestContext.request;
        String body = '';
        body = (String)JSON.deserializeUntyped(RestContext.request.requestBody.toString());
        ReferralJSON2Apex listLoc = (ReferralJSON2Apex)JSON.deserialize(body, ReferralJSON2Apex.class);
        RestResponse res = RestContext.response;
        if(listLoc.data.account != null && listLoc.data.account != ''){
            List accountList = new List();
            accountList = [SELECT Id FROM Account WHERE Id =: listLoc.data.account OR Referral_Account_Id__c =: listLoc.data.account];
                List newLeadList = new List(); 
                List newContactList = new List();
                List existingContactList = [SELECT Id FROM Contact WHERE Name =: listLoc.data.name];
                }else {
                    List customerActList = [SELECT Id FROM Account WHERE Name =: 'Customer' LIMIT 1];
                    Lead leadRecord = new Lead(FirstName = listLoc.data.name.split(' ')[0],
                                               LastName = listLoc.data.name.split(' ')[1],
                                               Phone = listLoc.data.phone,  State = 'TX', City = 'N/A',  Country = 'United States',Street = 'N/A', PostalCode = 'N/A');
                    insert newLeadList;
                List newRefContactList = new List();
                List newRefLeadList = new List();
                List existingRefContactList = [SELECT Id FROM Contact WHERE Name =: listLoc.data.referringUserName];             
                } else {
                    Lead leadRecord = new Lead(FirstName = listLoc.data.name.split(' ')[0],
                                               LastName = listLoc.data.name.split(' ')[1],
                                               Phone = listLoc.data.phone, State = 'TX',     City = 'N/A',  Country = 'United States',Street = 'N/A', PostalCode = 'N/A');
                        insert newRefLeadList;
                    return 'Success';
} catch (Exception e) { return e.getMessage() + e.getLineNumber(); } }else { return 'Please Provide Account Details !'; } return ''; } }


In this blog, we discussed the steps to integrate Referral Reactor with Salesforce using Zapier. We explained the process of creating a Connected App in Salesforce to obtain the necessary URL, client ID, and client secret key. Then, we walked through the steps of creating a “zap” in Zapier, including setting up a Catch Hook, making a POST request, and using a Custom Request in the Webhooks by Zapier action. By following these steps, businesses can automate the transfer of data between Referral Reactor and Salesforce, streamlining their referral processes. With this integration, businesses can efficiently track and manage their referral programs, set up referral campaigns, and provide rewards to referral sources.