Specbee: Simplifying Drupal and Salesforce integration: A how-to guide

“Teamwork makes the dream work” – and that’s especially true for marketing, sales, and operations. When these teams are aligned, you deliver consistent messaging and improve customer experience. The result? Faster conversions and greater efficiency.
How do you make this happen?
By integrating your CMS with your CRM! So if you have a Drupal website and you use a CRM like Salesforce, you must bring them together. With this integration you can connect your website with your favorite CRM and share customer data across teams. Marketing knows what leads are coming in, sales can act on them quickly, and operations ensure a flawless delivery. Everyone’s on the same page, and things move faster!
If you’re looking to sync data with your Salesforce instance automatically, this blog is the perfect starting point for you. We will be using the Salesforce Suite module to help you understand the integration in this blogpost. But first, let us give a brief overview of Salesforce integration and its benefits.

What is Salesforce
Salesforce is a leading cloud-based enterprise customer relationship management system. It makes it easy for businesses to track customer activity which helps effectively manage sales, analytics, customer service, marketing automation, and many more.
Salesforce-Drupal integration use cases
Drupal websites have the advantage of integrating seamlessly with third-party systems. In fact, Drupal offers several modules to make these integrations smooth.
The main goal of a CRM system integration with Drupal is to have seamless data transfer between the systems and make some meaningful decisions using the data from both ends.
Now, let us see where and what are the specific use cases in the business this integration is required:

User activities tracking: The activities such as page views, interactions, downloads, etc. can be captured and analyzed by the CRM to create personalized user segments.
Lead Generation: You can have lead generation forms, for example, contact forms and webforms to send the user information to the CRM that can be analyzed.
Commerce Sites: The user’s order history, account information, and product interaction can be displayed in a dashboard.
Product Suggestions: Personalized recommendations can be created on the website based on the user activities on the CRM
Sales Opportunities: Lead generation forms can be converted into sales or business opportunities.
Consolidated data: You can have sync user profiles between the CRM and CMS for a more complete view.

Benefits of integrating Salesforce and Drupal
Integrating Drupal with Salesforce brings a lot of benefits. Here are a few:

Enhanced customer engagement: With data synchronization, the customer data is regularly updated, providing timely information on user actions and preferences. We can have faster issue resolution processes, and better custom responses, and as a result, we will have improved customer service.
Easier data management: With the integration, there is no need to transfer customer data between CMS and CRM, which otherwise happens by copying and pasting the data. All relevant data is readily available to businesses to make decisions.
Collaboration between departments: Thanks to the CRM integration, accurate, comprehensive, and timely data is shared among various departments, minimizing the risk of data discrepancies. The communication within the departments will be better and communication of all the departments with the customers will be more consistent and aligned.
Actionable insights: With the consolidated data present in the CRM and website, the business has a comprehensive understanding of customers’ needs and preferences. This gives valuable insights for personalized and targeted marketing campaigns.

The Salesforce Suite Drupal module
This module is the most robust and reliable tool for integrating Drupal with Salesforce CRM, making it an ideal starting point for your integration.
The module created a seamless integration between Drupal and Salesforce that synchronizes Salesforce objects, such as Contacts and Accounts, with Drupal entities, such as nodes, terms, and users.
Prerequisites for the integration:

Create a salesforce developer account. You can either start from https://developer.salesforce.com/signup or use this video to create one.
Create a New Salesforce Connected App for authentication purposes.
Add the API settings for JWT auth or basic auth,
Download and install the Salesforce Suite module into the Drupal site.
Enable the required module for integration.

The Salesforce Suite module features various submodules that perform different tasks. Let’s see a few modules which are generally used:

Salesforce Integration: Maintains integration between Salesforce and Drupal
Salesforce OAuth: For Basic OAuth authorization
Salesforce JWT Auth: Provides functionality for key-based authentication system for Salesforce
Salesforce Mapping and UI: Provides mapping interface to map Drupal entities to Salesforce objects.
Salesforce Push & Salesforce Pull: Provides functionalities to have data sync between Salesforce and Drupal based on the mappings created. 
Salesforce Logger: Consolidated logger for logging Salesforce events.

Salesforce Authorization
There are two commonly used techniques within the Salesforce suite module for Drupal-Salesforce Authentication i.e Basic User Agent oAuth & JWT based oAuth.
Setting up of the Salesforce-Drupal authorization can be divided to two steps as mentioned below:
Step 1. Salesforce Connected App

Setup a Connected App on Salesforce instance
Login to Salesforce, navigate to Setup → Platform Tools → Apps → App Manager → New Connected App. This navigation path is applicable only,  if you are using lightning experience UI on the salesforce
If you are using Salesforce class UI, navigate to Setup → Manage Apps → Connected Apps → New
In the new connected App, there are some basic settings like names and contact details to be provided.
In the API settings section:

Check the “Enable oAuth Settings” checkbox.
Add the callback URL for the site, site_url/salesforce/oauth_callback
Select the OAuth Scopes, we need to select the four mandatory scopes:

Full access (full)
Manage user data via APIs (api)
Manage user data via Web browsers (web)
Perform request at anytime (refresh_token, offline_access)

Save the connected App
Gather the salesforce key and secret details as they are needed to configure in the Drupal website for successfully establishing the connection.

If you want to use JWT based authentication, there are few more steps to be followed while creating the Connected App

Generate the public/private key using the below command

openssl req -newkey rsa:2048 -nodes -keyout privatekey.pem -x509 -days 365 -out publickey.pem
The private key “privatekey.pem” must be added in Drupal as an authentication key in the key settings page.
Login into Drupal as admin, navigate to “admin/config/system/keys”.
In the Drupal keys configuration page, make sure to select “File” as the “Key provider” dropdown.
Check the “Strip trailing line breaks” checkbox in the “Provider settings” tab, and specify the right path for “privatekey.pem”
The public key “publickey.pem” must be uploaded on salesforce.

On the connected App, all the basic settings as mentioned in the above section remain the same.
Additionally, we must do the following in the API settings:

Check the “Use digital signatures” checkbox
The public key “publickey.pem” must be uploaded using the “Choose File” button.

 

Save the connected App.
Gather the salesforce key and secret details as they are needed to configure in the Drupal website for successfully establishing the connection.

Step 2. Connecting the app on Drupal

Once the Authorization is completed on Salesforce and we have the consumer key, secret details, we can start configuring the connection on the Drupal site
Login as admin on Drupal website
Navigate to Configuration → Salesforce → Salesforce Authorization or visit “admin/config/salesforce/authorize”
This page will list all the providers that exist in our Drupal website.

Click on “Add Salesforce Auth Provider” button
As mentioned in the above section, we have two different “Auth providers”:

Salesforce OAuth User-Agent:

 

Add the Label, consumer key and consumer secret and save the form
This will redirect the user to salesforce login and post doing auth activities on the salesforce it will return to Drupal screen with successful established connection.
Salesforce JWT OAuth

Add the Label, consumer key and login user. Select the private key that we have added while generating the keys. Save the form.
On save, it will redirect to the auth providers page with a successful established connection.

Salesforce Mappings
On successful authorization, we must tell both Drupal and Salesforce how to talk to each other. Please find the steps to below:

Login as admin into your Drupal site
Head to Salesforce mappings page, Structure → Salesforce → Salesforce Mappings

Click on “Add Mapping” to map a new one
Fill in the basic information, add the Drupal entity and select the Salesforce object to sync the data. Add the action triggers on which the sync has to take place

Once the basic settings are set we head on the field mapping screen where we map Drupal entity fields to Salesforce object properties.

We must set the direction in which the field data sync has to take place. We have three different sync mechanisms; “Drupal to SF”, “SF to Drupal” and  “Sync”
After setting up mappings to all the fields, save the mapping

After the authorization and mappings are set up properly, each time the cron runs, if a new record is added, an existing record is updated, or a record is deleted, the data will be synced between Drupal and Salesforce according to the direction and trigger selected in the mappings.
Final thoughts
This is just the basic guide for integrating Drupal with Salesforce. There’s a lot more you can do, like customizing queries for specific use cases. No matter what you need, Drupal allows for seamless implementation. By integrating Salesforce CRM with Drupal, you can enhance your customer management workflows, streamline operations, and boost overall efficiency. If you’re ready to kick off your next big integration, reach out to our Drupal development company, and one of our experts will guide you every step of the way.