Twilio and Salesforce Service Cloud integrate through Twilio Flex for omnichannel agent handling or through the Salesforce Twilio SMS connector to create SMS cases, send outbound notifications from case status changes, and log every SMS interaction as a Salesforce Activity on the related Contact or Case record automatically. This integration is used by customer service teams running Service Cloud as their CRM of record who want to handle inbound customer SMS as Cases, provide agents with full Salesforce context alongside each text interaction, and trigger automated outbound Twilio SMS from Salesforce Process Builder or Flow automations when cases are created or updated. The connection uses either the Twilio for Salesforce managed package from the Salesforce AppExchange or a custom Salesforce Apex callout that calls the Twilio REST API directly.
What You Need Before You Start
Install the Twilio for Salesforce managed package from the Salesforce AppExchange by searching for Twilio for Salesforce, clicking Get It Now, selecting your Salesforce org, and completing the installation wizard, which adds Twilio configuration objects, Apex classes, and a Visualforce page for credential management to your Salesforce org. Configure the Twilio credentials in Salesforce by navigating to the Twilio Settings custom object installed by the package, creating a new record, and entering your Twilio Account SID, Auth Token, and From Number, which are stored as Salesforce Custom Settings and retrieved by the package's Apex code for all API calls. Add the Twilio Remote Site Setting by navigating to Setup, then Security, then Remote Site Settings, clicking New Remote Site, and adding api.twilio.com as an approved remote site so Salesforce's Apex HTTP callout mechanism allows outbound requests to the Twilio API. From Twilio, provision an SMS-capable phone number under A2P 10DLC and configure the inbound SMS webhook URL to your Salesforce org's Twilio package webhook endpoint, which is typically at https://{yourOrgDomain}.my.salesforce.com/services/apexrest/twilio/sms.
Step-by-Step Integration Guide
Configure inbound SMS to create Salesforce Cases by opening the Twilio for Salesforce configuration in your Salesforce org, selecting the option to create a new Case on inbound SMS, mapping the Twilio From phone to the Salesforce Contact Phone field for contact matching, and setting the Case Origin to SMS and the Case Status to New so inbound texts create properly categorized cases in your service queue. Send outbound Twilio SMS from a Salesforce Flow by adding a Salesforce Flow action step using the Twilio Send SMS Apex action installed by the package, mapping the Flow's record variable's Contact.MobilePhone to the To parameter and composing the Body text using Flow formulas that reference Case fields such as the case number, subject, and status. Create a custom Apex trigger on the Case object that fires on case status updates: trigger CaseStatusSMS on Case (after update) { List<Case> statusChanges = new List<Case>(); for (Case c : Trigger.new) { Case old = Trigger.oldMap.get(c.Id); if (c.Status != old.Status && c.ContactId != null) { statusChanges.add(c); } } TwilioSMSService.sendStatusUpdateSMS(statusChanges); } where TwilioSMSService is a custom Apex class that calls the Twilio REST API using an HTTP callout. Log every Twilio interaction as a Salesforce Task Activity by creating a Task record in Apex after each outbound SMS call, setting the Subject to SMS Sent, the Status to Completed, the WhatId to the Case record ID, and the WhoId to the Contact record ID, building a complete SMS interaction history on the Salesforce record timeline.
Common Issues and How to Fix Them
Salesforce Apex callouts to the Twilio API fail in trigger context with a Callout from triggers are not allowed error because synchronous HTTP callouts cannot be made from Apex trigger bodies in Salesforce, which executes synchronously within the database transaction. Refactor the Apex trigger to enqueue a Queueable Apex job using System.enqueueJob(new TwilioSMSQueueable(cases)) where TwilioSMSQueueable implements Queueable and Database.AllowsCallouts, moving the Twilio HTTP callout to an asynchronous context that Salesforce permits for outbound callouts. The Twilio for Salesforce package stores the Auth Token as a Salesforce Custom Setting which can be visible to Salesforce admins with View All Data permission, creating a security risk in multi-admin orgs where the Twilio Auth Token should be restricted. Replace the Custom Settings storage with a Salesforce Named Credential by creating a Named Credential under Setup, then Security, then Named Credentials, pointing it to https://api.twilio.com with Basic authentication using your Account SID and Auth Token, and referencing the Named Credential in your Apex callout using HttpRequest.setEndpoint('callout:Twilio_API/2010-04-01/Accounts/{sid}/Messages.json'), which keeps the Auth Token encrypted and invisible even to admins. Inbound Twilio SMS webhooks from customers who are not in your Salesforce Contact database fail to create Cases because the package cannot match the From phone to an existing Contact, and the package may create orphaned Cases without a ContactId depending on its configuration. Add a Contact creation step in the package configuration or in a custom Apex webhook handler that creates a new Salesforce Contact with the From phone as the MobilePhone field when no existing contact match is found, ensuring every inbound SMS creates a Case with a linked Contact for complete interaction tracking.
How to Get More from This Integration
Build a case status notification sequence using Salesforce Flow by creating a Record-Triggered Flow on the Case object that fires when Status changes to In Progress, Pending Customer, or Resolved, adding a Twilio Send SMS action in each flow path with a case-status-specific message body referencing the Case Number and a self-service portal link, keeping customers informed at every stage of their support case without agent manual intervention. Add Twilio WhatsApp notifications for high-priority cases by detecting Case records with Priority set to High in the Apex trigger, checking a custom WhatsApp_Opted_In checkbox field on the Contact, and dispatching the status update to whatsapp:{contactPhone} via the Twilio API using the whatsapp: prefix on the From and To parameters when the contact has opted in, delivering richer rich-media capable notifications for your most important cases. Create a Salesforce Omni-Channel SMS routing integration by using Twilio Flex embedded in the Salesforce Service Console via the Twilio Flex Salesforce integration package, routing inbound SMS interactions as Omni-Channel work items to available agents, and surfacing the customer's Salesforce 360 view alongside each SMS so agents have complete context without switching tabs. Extend the integration with Twilio Verify for contact identity verification by adding a Verify SMS OTP step to your Case creation Flow when sensitive account information is requested, dispatching a Twilio Verify OTP to the customer's phone, recording the verification timestamp and result in a custom Case field, and gating agent access to account information until successful verification is recorded.
Conclusion
Twilio and Salesforce Service Cloud together create a fully CRM-integrated SMS support channel where every customer text becomes a tracked Case with complete interaction history logged automatically on the Salesforce record. Reach out to Telphi Consulting to implement the Twilio Salesforce Service Cloud SMS integration for your customer support operations.
Ready to Transform Your Business Communications?
Get a free consultation with our VoIP experts and discover how we can help you save costs, improve efficiency, and scale your business.
Comments (0)
Join the discussion and share your thoughts (AI-moderated for quality)
Be the first to comment
No comments yet. Share your thoughts below.