Skip to main content

How to integrate Salesforce to Wati and automatically sync Contacts and Leads

Summary

Managing contacts across multiple platforms can be time-consuming. With the Salesforce integration, Wati automatically keeps your Contacts and Leads up to date without requiring manual imports.

This guide walks you through setting up Salesforce → Wati synchronization, importing existing Salesforce records, and configuring field mappings so your teams always have access to the latest customer information.

For information about Wati → Salesforce synchronization, including how contacts are matched and synced to Salesforce, refer to our Wati → Salesforce synchronization guide.

Instructions

Key features in the Salesforce integration

The Salesforce integration includes the following capabilities:

  • Real-time contact sync from Salesforce to Wati

  • Configurable field selection for Contacts and Leads

  • Custom field mapping between Salesforce and Wati

  • One-time import of existing Salesforce Contacts and Leads

The integration uses Salesforce events to automatically update contacts in Wati whenever a Contact or Lead is created or updated - no manual imports required

How Two-Way Sync works

Two-Way Sync supports synchronization in both directions, but each direction works independently and uses a different mechanism:

Salesforce → Wati
Salesforce sends Contact and Lead record changes to Wati when a record is created or updated. This direction is configured on the Salesforce side using record-triggered Flows, an Apex action class, and Wati's webhook. The setup steps in this article cover this direction.

Wati → Salesforce
When a contact is updated in Wati, the change is pushed to Salesforce in real time using a webhook-based sync — not a scheduled batch or polling process. This direction is part of the Two-Way Sync functionality and does not depend on the Salesforce-side Flow configuration described in this article.

Important: The Salesforce configuration steps in this article (Remote Site, Apex class, record-triggered Flows) are specifically for setting up Salesforce → Wati synchronization. Wati → Salesforce synchronization is supported as part of Two-Way Sync, but its detailed setup steps are not covered in the Salesforce-side configuration section below.

Wati → Salesforce sync behaviour

New contacts: When a new contact is created in Wati and synced to Salesforce, it is created as a Salesforce Contact — not a Lead.

Trigger: The Wati → Salesforce direction is real-time and webhook-based. Changes in Wati are pushed to Salesforce immediately — there is no scheduled batch or polling interval.

Field mapping: Field mapping is configurable. Salesforce fields can be mapped to the corresponding Wati contact fields and adjusted based on your requirements. Both standard Salesforce fields and custom fields (ending in __c) are supported.

Business Plan requirement: Wati → Salesforce synchronization is available on the Wati Business Plan. Two-Way Sync, including this direction, requires a Business Plan subscription.

Before you begin

Make sure you have:

  • A Wati account on the Business Plan

  • A Salesforce account already connected to Wati through OAuth

  • Salesforce administrator access

  • The Webhook URL and Webhook Authentication Secret generated by Wati

Note: Salesforce-side configuration requires administrator access. Standard Salesforce users cannot complete the setup.

How the integration works

The setup process consists of two parts:

  • Configure Salesforce sync settings in Wati

  • Configure Salesforce to send updates to Wati

Part 1: Configure sync settings in Wati

Step 1: Open the Salesforce integration

  • In Wati, go to Connectors > Integrations > Salesforce.

  • Confirm that the Authentication step displays a green checkmark.

  • Verify that your Salesforce organization URL is displayed.

  • Copy the following values:

    • Webhook URL

    • Webhook Authentication Secret

These values will be required during the Salesforce configuration.

Step 2: Select the fields to sync

Choose the Salesforce fields that should be synchronized to Wati.

Default Contact fields

  • Business Phone

  • Contact ID*

  • Email

  • First Name

  • Last Name

  • Owner ID

Default Lead fields

  • Email

  • First Name

  • Last Name

  • Lead ID*

  • Owner ID

  • Phone

  • Status

Note: * Mandatory fields cannot be removed.

To sync additional fields:

  • Click the field selector.

  • Choose additional standard Salesforce fields.

Step 3: Map Salesforce fields to Wati fields

The selected Salesforce fields are automatically mapped to the corresponding Wati contact fields by default.

Review the mappings and make changes only if you want a Salesforce field to sync with a different Wati contact field.

Review all mappings carefully before proceeding.

Step 4: Enable automatic sync

Enable the Automatic data sync (Two-way Sync) toggle.

When Automatic data sync (Two-way Sync) is enabled, changes are synchronized between Salesforce and Wati in both directions. This helps keep customer data up to date across both platforms without requiring manual updates.

Step 5: Import existing Salesforce records

Run the one-time import process to bring your existing Salesforce Contacts and Leads into Wati.

This import only needs to be performed once during initial setup.

Part 2: Configure Salesforce

Salesforce administrator access is required for the following steps.

Step 1: Create a Remote Site

  • Go to Setup > Security > Remote Site Settings.

  • Select New Remote Site.

  • Enter the Remote Site URL using only the domain format:

https://<hostname>
  • Select Active.

  • Click Save.

Important: Do not include /api/v1/salesforce/processWebhook in the Remote Site URL. Adding the path will cause the integration to fail.

Step 2: Create Custom Labels

Go to: Setup > Custom Code > Custom Labels

Create the following labels exactly as shown:

Label Name

Value

WATI_Webhook_Endpoint

Full Webhook URL from Wati

WATI_Webhook_Secret

Webhook Authentication Secret from Wati

Important: The label names must match exactly. Any variation will prevent the integration from working.

Step 3: Deploy the Apex class

  • Go to Setup > Developer Console.

  • Create a new Apex class.

  • Name the class:

WatiSalesforceWebhookSender
  • Paste the Apex code provided by Wati.

  • Save and compile the class.

This class creates the Salesforce action:

Notify WATI of Record Changes

This action will be used by Salesforce Flows.

Step 4: Create Record-Triggered Flows

Create two separate Flows:

  • Contact Flow

  • Lead Flow

Navigate to: Setup > Process Automation > Flows > New Flow

Configure both Flows using the following settings:

Setting

Value

Trigger Type

Record-Triggered Flow

Object

Contact or Lead

Trigger Event

Created or Updated

Run Mode

Asynchronously (after save)

Action Type

Apex

Action

Notify WATI of Record Changes

Activate both Flows after creation.

Important: Always use asynchronous mode. Synchronous execution can cause Salesforce transaction delays and timeout errors.

Step 5: Understanding how the Apex class uses Custom Labels

The Apex class references your Custom Labels automatically using System.Label.WATI_Webhook_Endpoint and System.Label.WATI_Webhook_Secret - no manual edits are needed.

Copy the full class as-is. Do not modify the class structure — only the Custom Labels configured in Step 2 need to be updated to match your Wati credentials.

public class WatiSalesforceWebhookSender {

private static String getEndpoint() {
return System.Label.WATI_Webhook_Endpoint;
}

private static String getWebhookSecret() {
return System.Label.WATI_Webhook_Secret;
}

private static final String PHONE_FIELD_DEFAULT = 'Phone';

@InvocableMethod(
label = 'Notify WATI of Record Changes',
description = 'POST Contact/Lead changes to WATI'
)
public static void sendRecords(List<Id> recordIds) {

if (recordIds == null || recordIds.isEmpty()) {
return;
}

String objectType = recordIds[0].getSObjectType().getDescribe().getName();
String baseUrl = Url.getOrgDomainUrl().toExternalForm();
String orgId = UserInfo.getOrganizationId();
String userId = UserInfo.getUserId();
String fullIdentityId = baseUrl + '/id/' + orgId + '/' + userId;

List<Map<String, Object>> events = new List<Map<String, Object>>();

for (Id rid : new Set<Id>(recordIds)) {

if (rid == null) {
continue;
}

events.add(new Map<String, Object>{
'salesForceOrgId' => fullIdentityId,
'recordId' => String.valueOf(rid),
'objectType' => objectType,
'eventType' => 'update',
'phoneField' => PHONE_FIELD_DEFAULT
});
}

if (!events.isEmpty()) {
makeCallout(JSON.serialize(events));
}
}

@future(callout = true)
private static void makeCallout(String jsonBody) {

HttpRequest req = new HttpRequest();

req.setEndpoint(getEndpoint());
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json;charset=UTF-8');
req.setHeader('X-Wati-Salesforce-Webhook-Key', getWebhookSecret());
req.setBody(jsonBody);

try {
HttpResponse res = new Http().send(req);
System.debug(LoggingLevel.INFO, 'WATI status: ' + res.getStatusCode());
} catch (Exception e) {
System.debug(LoggingLevel.ERROR, 'WATI error: ' + e.getMessage());
}
}
}

salesForceOrgId must contain your Salesforce identity URL. This is typically constructed using Url.getOrgDomainUrl(), followed by /id/, your Salesforce Organization ID, and your User ID.

Wati uses the Salesforce Organization ID within this identity URL to identify your connected Salesforce organization. The hostname does not need to match the one used during OAuth authentication. For example, both login.salesforce.com and your My Domain (*.my.salesforce.com) are supported, as long as the Organization ID is the same.

Alternatively, you can provide the 15- or 18-character Salesforce Organization ID directly if it matches the connected organization.

The Wati integration service stores this org segment at connect time and may normalize outbound webhook payloads before they reach Wati.

What happens after setup?

After setup is complete:

  • A Contact or Lead is created or updated in Salesforce.

  • Salesforce triggers the Flow.

  • The Flow calls the Apex action.

  • The Apex action sends the update to Wati.

  • Wati creates or updates the contact automatically.

No scheduled jobs or manual imports are required.

What happens when a Salesforce Lead linked to Wati is converted?

When a Salesforce Lead is converted and a new Contact record is created, the integration automatically updates the mapping from the old Lead to the new Contact — no manual re-linking is required.

Wati identifies records using the phone number. When the Lead is converted, the existing Wati contact is retained and associated with the resulting Salesforce Contact. No duplicate Wati contact is created as a result of the conversion.

Contact deduplication

Wati uses phone numbers to identify existing contacts.

  • If a matching phone number already exists, the contact is updated.

  • If no matching phone number exists, a new contact is created.

Important notes

Salesforce connection status

The green Connected indicator only confirms OAuth authentication.

It does not verify:

  • Remote Site configuration

  • Apex class deployment

  • Custom Labels

  • Salesforce Flows

Always test the integration after setup by updating a Contact or Lead.

Supported fields

  • Standard Salesforce fields are supported.

  • Custom Salesforce fields ending in __c are supported.

Record deletion

Deleting a Contact or Lead in Salesforce does not delete the corresponding contact in Wati.

The Salesforce relationship is removed, but the Wati contact remains.

Phone number formatting

Use a consistent phone number format across Salesforce records.

Inconsistent formatting can create duplicate contacts in Wati instead of updating existing records.

Wati-to-Salesforce sync

Wati → Salesforce synchronization is available on the Wati Business Plan as part of the Two-Way Sync functionality.

Troubleshooting

If Salesforce contacts or leads are not syncing correctly, review the symptoms below to identify the likely cause and the recommended resolution.

Symptom

Possible Cause

Resolution

HTTP 401 error in Apex logs

Incorrect webhook authentication secret

Copy the latest authentication secret from Wati and update the WATI_Webhook_Secret Custom Label.

HTTP 404 error in Apex logs

Incorrect Webhook URL

Copy the latest Webhook URL from Wati and update the WATI_Webhook_Endpoint Custom Label.

Unauthorized endpoint or callout exception in Apex logs

Remote Site is missing or configured incorrectly

Verify that the Remote Site URL contains only https://<hostname> and does not include any URL path.

No debug logs generated

Salesforce Flow is not triggering

Verify that:

• The Flow is active

• Entry conditions are met

• The Flow is configured to run in Asynchronous mode

Contacts are not syncing, but Salesforce shows Connected

Salesforce-side configuration is incomplete

Verify that all Salesforce setup steps have been completed and both Flows are active. If sync was previously working and has stopped, contact Wati Support.

Sync stopped working after previously working

Salesforce OAuth token expired or a Flow was deactivated

Verify that both Flows are active. If the issue persists, disconnect and reconnect Salesforce in Wati.

Duplicate contacts are being created

Phone number formatting differs between Salesforce and Wati

Ensure phone numbers use a consistent format across Salesforce and Wati.

How to view Salesforce debug logs

To view Salesforce logs:

  • Go to Setup > Environments > Logs > Debug Logs.

  • Enable logging for your Salesforce user.

  • Update a Contact or Lead to generate log entries.

Frequently Asked Questions (FAQs)

Integration Overview

1. What does the Wati Salesforce integration support?

The Wati Salesforce integration supports real-time synchronization between Salesforce and Wati, configurable field selection, custom field mapping, and a one-time import of existing Salesforce Contacts and Leads. Two-Way Sync supports synchronization in both directions: Salesforce → Wati and Wati → Salesforce.

2. How does Two-Way Sync work between Salesforce and Wati?

Salesforce → Wati synchronization sends Contact and Lead changes to Wati when records are created or updated. It uses Salesforce record-triggered Flows, an Apex action, and a Wati webhook.

Wati → Salesforce synchronization sends Wati contact updates to Salesforce in real time using a webhook-based sync. It does not depend on the Salesforce-side Flow configuration.

3. Is Two-Way Sync available on all Wati plans?

No. Wati → Salesforce synchronization and the full Two-Way Sync functionality require the Wati Business Plan.

4. When Wati syncs a contact to Salesforce, is it created as a Lead or a Contact?

It is created as a Salesforce Contact, not a Lead.

5. Does Wati → Salesforce sync happen in real time?

Yes. The Wati → Salesforce direction is webhook-based and triggers in real time when a contact is updated in Wati. It does not rely on a scheduled batch or polling process.

6. If a Salesforce Lead linked to Wati is converted, do I need to re-link it manually?

No. Wati matches records by phone number and automatically updates the mapping to the resulting Salesforce Contact when a Lead is converted. The existing Wati contact is preserved and no duplicate is created.

7. How can I troubleshoot Salesforce contacts or leads that are not syncing?

First, verify that the Salesforce Connected indicator is not being treated as proof that the entire integration is configured. It only confirms OAuth authentication. Verify that the Remote Site, Custom Labels, Apex class, and both Salesforce Flows are configured correctly and active.

Common errors include:

  • HTTP 401: Update the WATI_Webhook_Secret Custom Label with the latest Wati authentication secret.

  • HTTP 404: Update the WATI_Webhook_Endpoint Custom Label with the latest Wati Webhook URL.

  • Unauthorized endpoint or callout exception: Verify that the Remote Site contains only https://<hostname> and no URL path.

  • No debug logs: Verify that the Flow is active, its entry conditions are met, and it runs asynchronously.

  • Duplicate contacts: Use a consistent phone number format across Salesforce and Wati.

Salesforce debug logs are available under Setup > Environments > Logs > Debug Logs.

Did this answer your question?