# How to integrate Salesforce

Use integration with [Salesforce](https://salesforce.com/) to automatically sync client data from B2CORE to Salesforce. This integration helps centralize client information, streamline internal processes, and support sales and marketing workflows within your Salesforce environment.

This integration currently supports one-way data transfer from B2CORE to Salesforce; reverse syncing isn’t available.

{% hint style="info" %}
Before proceeding with the instructions, you must sign up for Salesforce and create an **External client app**, which enables external services to interact with the Salesforce API. If you have any questions, consult the official [Salesforce Help Center](https://help.salesforce.com/) or contact their support team.
{% endhint %}

## Create an External client app in Salesforce

To create an External client app in Salesforce:

{% stepper %}
{% step %}
In Salesforce, go to **Settings** > **Setup**.
{% endstep %}

{% step %}
In the **Setup** section, enter **App Manager** in the search box, and then click it in the search results.
{% endstep %}

{% step %}
Click **New External Client App**.
{% endstep %}

{% step %}
In the **Basic Information** section, fill in the following fields:

* **External client app name** — specify the name of your B2CORE instance. If you have several instances, use different names when configuring External client apps for each one in Salesforce.
* **API name** — auto-filled based on the app name.
* **Contact email** — enter the email address of the contact user.
* **Distribution site** — select **Local**. This setting determines who can view and authorize in the created External client app. **Local** means that it's accessible only within your organization.
  {% endstep %}

{% step %}
Expand the **API (Enable OAuth Settings)** section and select the **Enable OAuth** checkbox.

* In the **Callback URL**, specify `https://login.salesforce.com/services/oauth2/success`.
* In the **OAuth scopes**, select the required permissions. The minimum set for API access is:
  * Manage user data via APIs (api)
  * Perform requests at any time (refresh\_token, offline\_access)
  * Access the Salesforce API Platform (sfap\_api)
* Select the **Introspect all tokens** checkbox (recommended). This allows the resource server to validate access tokens without calling Salesforce for every request.
  {% endstep %}

{% step %}
In the **Flow Enablement** section, select **Enable Client Credentials Flow**.
{% endstep %}

{% step %}
In the **Security** section, select the following:

* Enable Client Credentials Flow
* Require secret for Web Server Flow
* Require secret for Refresh Token Flow
* Require Proof Key for Code Exchange (PKCE) extension for Supported Authorization Flows
* Issue JWT Web Token (JWT)-based access tokens for named users
  {% endstep %}

{% step %}
Click **Save** to create the app.
{% endstep %}
{% endstepper %}

After creating the app, Salesforce generates the **Consumer key** and **Consumer secret**, which serve as the app’s identifier and secret key. You can find them by opening the app card, navigating to **Settings** > **OAuth Settings**, and clicking the **Consumer Key and Secret** button.

The **Consumer key** and **Consumer secret** are required for configuring the connection to Salesforce in the B2CORE Back Office.

## Further External client app configuration

After creating your External client app, proceed with the additional configuration steps:

{% stepper %}
{% step %}
In Salesforce, go to **Setup** > **Users** > **Users** and find the contact user specified during your **External client app** registration.
{% endstep %}

{% step %}
Open the user’s card and in the **Permission set assignments** section, add the **API Enabled permission**.
{% endstep %}

{% step %}
Copy the name from the **Username** field.
{% endstep %}

{% step %}
Go to **Setup** > **External Client Apps** > **External Client App Manager**, and open your app card.
{% endstep %}

{% step %}
In the app card, go to **Policies** > **OAuth Policies** > **OAuth Flows and External Client App Enhancements**, select the checkbox **Enable Client Credentials Flow** and enter the previously copied username.
{% endstep %}

{% step %}
In **Policies** > **OAuth Policies** > **App Authorization**, select **Expire refresh token after specific time** and fill in the following parameters:

* **Refresh Token Validity Period** — set to `365`.
* **Refresh Token Validity Unit** — select `Days`.
* **IP Relaxation** — select `Enforce IP restrictions`.
* **Named User JWT-Based Access Token Settings** — select `Set app-specific token timeout (1 Hour)`.
  {% endstep %}

{% step %}
Click **Save** to apply the changes.
{% endstep %}
{% endstepper %}

## Get your Salesforce domain

{% stepper %}
{% step %}
In Salesforce, go to **Setup** > **Settings** > **Company Settings** > **My Domain**.
{% endstep %}

{% step %}
Copy the value from the **Current My Domain URL** field.
{% endstep %}
{% endstepper %}

The Salesforce domain is required for configuring the connection to Salesforce in the B2CORE Back Office.

## How to configure a connection to Salesforce in the B2CORE Back Office

To configure a connection to Salesforce in the B2CORE Back Office:

{% stepper %}
{% step %}
Navigate to **System** > **External connections**.
{% endstep %}

{% step %}
Click **+Create** in the upper-right page corner.
{% endstep %}

{% step %}
On the **Create connection** page, fill in the following fields:

* In the **Name** field, enter a name for the connection. The name must be unique.
* In the **Caption** field, enter a caption that will be applied to the connection in the Back Office.
* In the **Provider** dropdown, select **Salesforce**.
  {% endstep %}

{% step %}
Click **Save** to create the connection.

The **Salesforce** connection will appear in the list of external connections.
{% endstep %}

{% step %}
Click **Edit** to enter the connection details and complete the following fields:

* In the **Domain URL** field, provide the URL of your Salesforce instance, such as:

  `https://{your-domain}.my.salesforce.com`

  The domain URL can be found in Salesforce by navigating to **Setup** > **Settings** > **Company Settings** > **My Domain**.
* In the **Consumer key** field, specify the consumer key generated by Salesforce after creating your **External client app**.
* In the **Consumer secret** field, specify the consumer secret generated in the same Salesforce Connected App. The secret is used together with the **Consumer Key** to authenticate API requests.

  Both the **Consumer key** and **Consumer secret** can be found in the Salesforce app card by navigating to **Settings** > **OAuth Settings** and clicking the **Consumer Key and Secret** button.
* In the **Company (applied to all new leads)** field, enter the company name that should appear in Salesforce when creating new lead records, which are the Salesforce records created for each client synced from B2CORE. This field is required for Salesforce.
  {% endstep %}

{% step %}
Check the connection status.

If the connection is inactive (**No** is displayed in the **Enabled** field), activate it by setting the **Enabled** dropdown to **Yes**.
{% endstep %}

{% step %}
Click **Save** to apply the changes.
{% endstep %}
{% endstepper %}

After configuring the connection, all clients listed under **Clients** > **General** in the B2CORE Back Office will be automatically synced with Salesforce, where each client is added as a separate lead record. Any further updates to client personal details will also be synced with Salesforce.

## Overview of client data synced with Salesforce

The following required and optional client fields are synced from B2CORE to Salesforce in lead records:

### Required fields

The following required client fields are always synced from B2CORE to Salesforce:

* **Last name** — if not specified, `Undefined` is sent to Salesforce.
* **Company** — the company name specified in the **Company (applied to all new leads)** field of the external connection configured in the B2CORE Back Office is sent to Salesforce.

### Optional fields

The following optional fields, which can be useful for business processes, are synced from B2CORE to Salesforce if they are specified in the client details in the B2CORE Back Office:

* **First name**
* **Middle name**
* **Email**
* **City**
* **State**
* **Address**
* **Postal code**
* **Country** and **Country code (ISO)**
* **Phone** — if multiple phone numbers are specified for a client in the B2CORE Back Office, the confirmed number is sent to Salesforce; if none is confirmed, the most recently updated number is used.

## How to add custom fields for syncing from B2CORE to Salesforce

You can sync additional fields from B2CORE to Salesforce, such as a client’s **Status**, **Verification level**, and **Client type** to reflect them in lead records in Salesforce.

In **Salesforce**, add these fields:

{% stepper %}
{% step %}
Sign in to Salesforce.
{% endstep %}

{% step %}
Go to **Setup** > **Object Manger**.
{% endstep %}

{% step %}
Select the **Lead** object.
{% endstep %}

{% step %}
In the object details, select **Fields & Relationships** and click **New**.
{% endstep %}

{% step %}
Select the filed type, such as **Text**.
{% endstep %}

{% step %}
Enter the **Field Label**. The **Field Name** will be auto-filled based on the label.

If needed, you can specify additional field parameters. Refer to the [Salesforce Help Center](https://help.salesforce.com/) for more information.
{% endstep %}

{% step %}
Save the changes to add the new field to the object.
{% endstep %}
{% endstepper %}

In the **B2CORE Back Office**, set up field mapping:

{% stepper %}
{% step %}
Navigate to **System** > **External connections**.
{% endstep %}

{% step %}
Find the connection configured for Salesforce and click **Edit** to open the connection details.
{% endstep %}

{% step %}
Set up the field mapping by selecting the corresponding fields created in Salesforce for **Status**, **Client type**, and **Verification level**.

<figure><img src="/files/W7jkHruVTu3j4fo6IoHI" alt="Set up field mapping"><figcaption><p>Set up field mapping</p></figcaption></figure>
{% endstep %}

{% step %}
Click **Save** to apply the changes.
{% endstep %}
{% endstepper %}

Once the fields are added and mapped, the client’s **Status**, **Client type**, and **Verification level** are automatically synced from B2CORE and displayed in lead records in Salesforce. If one or more fields aren't mapped, they won't be synced to Salesforce.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.b2core.b2broker.com/how-to-articles/manage-system-settings/how-to-integarte-salesforce.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
