Issue
Users of the Twilio for Salesforce managed package may experience repeated “Twilio Sync Job Failed” exception emails, and notice that the Message Sync option under Twilio Configuration becomes unscheduled. This results in messages not syncing properly from the server to Salesforce, impacting business processes. Common error messages reference Salesforce Apex heap size or CPU time limit exceptions.
Product
Twilio for Salesforce
Environment
Twilio Console
Cause
This issue is typically caused by Salesforce Apex governor limits being exceeded during the sync job. The most common root cause is synchronous custom automation (such as record-triggered Flows or Apex triggers) on the TwilioSF_Message__c object. These custom processes consume additional CPU time during message creation, which can push the sync job over Salesforce’s strict limits and cause it to fail. Additionally, running the sync job too frequently (e.g., every 2–5 minutes) can lead to overlapping jobs, causing the system to abort or unschedule the sync process.
Resolution
To resolve and prevent sync job failures:
-
Refactor Custom Logic to Run Asynchronously:
- Audit any custom Flows or triggers on the
TwilioSF_Message__cobject. - Ensure these are configured to run asynchronously to avoid conflicting with the managed package’s execution limits.
- Audit any custom Flows or triggers on the
-
Reduce “Get Message Size” Setting:
- Go to Setup > Custom Settings > Twilio Public App Config > Manage > Edit.
- Set the Get Message Size field to a lower value (minimum allowed is 100).
- Save the changes.
-
Increase Sync Retrieve Interval:
- In the Twilio Configuration tab, set the sync frequency to 5–10 minutes to prevent job overlaps and reduce the risk of hitting Salesforce limits.
-
Skip Lead/Contact Updates (if applicable):
- If you have heavy triggers on Lead or Contact objects, check the “Skip Lead/Contact update?” box in the Twilio Public App Config custom settings to bypass these updates during sync.
-
Verify Package Version:
- Ensure you are using the latest version of Twilio for Salesforce, as recent releases include optimizations for message sync and high-volume handling.
-
Suppress Failure Notifications (optional):
- To reduce exception emails, enable the “Stop Sync Job Failure Notification” option in the Twilio Public App Config custom settings.
Additional Information
- The minimum allowed value for “Get Message Size” is 100; setting it lower is not supported.
- If your message batches are already below this threshold, focus on optimizing custom automation and Lead/Contact updates.
- For more details, refer to the Twilio for Salesforce documentation.
For further assistance, please reach out Twilio Support.