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 real-time synchronization between Salesforce and Wati, importing existing records, and configuring field mappings so your teams always have access to the latest customer information.b
Instructions
What's new in the Salesforce integration?
The Salesforce integration now includes several improvements:
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
Previously, users had to manually select Import from Salesforce to sync data. The new integration uses Salesforce events to automatically update contacts in Wati whenever a Contact or Lead is created or updated.
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.
This activates real-time synchronization from Salesforce to Wati whenever Contacts or Leads are created or updated.
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: Configure the endpoint and secret using Custom Labels
Create the WATI_Webhook_Endpoint and WATI_Webhook_Secret Custom Labels using the Webhook URL and Webhook Authentication Secret generated by Wati.
In your Apex class, reference these values using System.Label.WATI_Webhook_Endpoint and System.Label.WATI_Webhook_Secret.
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.
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
Only standard Salesforce fields are supported.
Custom Salesforce fields ending in __c cannot currently be synchronized.
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
Updating contacts in Wati and pushing those changes back to Salesforce is not available for all accounts.
Contact your account manager to confirm eligibility.
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 |
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 Salesforce integration do?
The Salesforce integration automatically synchronizes Salesforce Contacts and Leads with Wati. It supports real-time synchronization, configurable field selection, custom field mapping, and a one-time import of existing Salesforce records.
2. What do I need before setting up the Salesforce integration?
Before setting up the integration, you need:
A Wati Business plan account
A Salesforce account connected to Wati through OAuth
Salesforce administrator access
The Webhook URL and Webhook Authentication Secret generated by Wati
Salesforce administrator access is required because part of the configuration must be completed in Salesforce.
3. Does the Salesforce integration automatically sync contact updates?
Yes. After setup is complete and automatic sync is enabled, Salesforce automatically sends Contact and Lead updates to Wati whenever a record is created or updated. Manual imports are no longer required for ongoing synchronization.
Synchronization and data mapping
4. How are Salesforce fields mapped to Wati fields?
The selected Salesforce fields are automatically mapped to the corresponding Wati contact fields by default. You can review and modify the mappings if you want a Salesforce field to sync with a different Wati contact field.
5. How does Wati prevent duplicate contacts during synchronization?
Wati uses phone numbers to identify existing contacts. If a matching phone number already exists, the existing contact is updated. If no matching phone number is found, Wati creates a new contact.
6. Are custom Salesforce fields supported?
No. The integration currently supports only standard Salesforce fields. Custom Salesforce fields that end with __c cannot be synchronized.
Limitations
7. What happens if I delete a Contact or Lead in Salesforce?
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.
8. Does the Salesforce Connected status confirm that the integration is fully configured?
No. The Connected status only confirms that Salesforce OAuth authentication was successful. It does not verify the Salesforce-side configuration, including the Remote Site, Apex class, Custom Labels, or Salesforce Flows.
9. Is synchronization from Wati back to Salesforce supported?
Synchronization from Wati to Salesforce is not available for all accounts. Contact your account manager to confirm whether your account is eligible for this capability.












