Back to Blog
Integration Guides

How to Integrate Twilio with Salesforce Marketing Cloud: Step-by-Step Guide

Connect Twilio to Marketing Cloud to send transactional SMS from Journey Builder, sync opt-outs, and track SMS engagement alongside email.

DA
Danial A
Senior Twilio Consultant, Telphi Consulting
June 22, 2026
7 min read
Twilio
Integration
Contact Centre
Enterprise
How to Integrate Twilio with Salesforce Marketing Cloud: Step-by-Step Guide

Twilio and Salesforce Marketing Cloud integrate through Marketing Cloud's Journey Builder Custom Activity framework and the Twilio Messages API to add Twilio-powered SMS as a step in Marketing Cloud customer journeys, enabling marketers to send transactional and promotional SMS alongside email communications with unified contact management, opt-out syncing, and engagement tracking. This integration is used by marketing teams running Salesforce Marketing Cloud who want to leverage Twilio's higher SMS deliverability, A2P 10DLC compliance, and global reach to supplement Marketing Cloud Mobile Connect, particularly for use cases requiring two-way SMS, dynamic send-time optimization, and integration with Twilio Verify for subscription confirmations. The connection uses Marketing Cloud's Journey Builder Custom Activity API to call a Twilio-connected serverless endpoint when a contact reaches the SMS step in a journey.

What You Need Before You Start

Create a Marketing Cloud API Integration by navigating to Marketing Cloud Setup, then Apps, then Installed Packages, clicking New, adding an API Integration component with the Perform Server-to-Server Requests permission, and noting the Client ID, Client Secret, and REST API endpoint URL for authenticating your middleware against the Marketing Cloud REST API. Build the Journey Builder Custom Activity backend by creating a Node.js or Python application that exposes four HTTPS endpoints: /config, /publish, /save, and /execute, following the Marketing Cloud Custom Activity specification where /config returns a JSON manifest describing the activity UI and schema, and /execute is called by Journey Builder when a contact enters the activity step. Store your Twilio Account SID, Auth Token, and From Number as environment variables in your Custom Activity backend and retrieve them at runtime for the Twilio Messages API calls that dispatch SMS to contacts entering the Journey Builder step. From Twilio, provision an SMS-capable phone number under A2P 10DLC for US-bound marketing SMS and collect your Account SID and Auth Token.

Step-by-Step Integration Guide

Implement the /config endpoint to return the Custom Activity manifest JSON that defines the activity name, category, endpoint, and the configurationArguments schema including fields for smsBody and twilioFromNumber, which the Journey Builder UI presents to the marketer when configuring the SMS activity step. Implement the /execute endpoint to receive the Journey Builder contact execution payload containing the contact's subscriberKey and the configurationArguments set by the marketer, retrieve the contact's mobile phone by querying the Marketing Cloud Data Extension using the Marketing Cloud REST API at POST https://{subdomain}.rest.marketingcloudapis.com/data/v1/query with a SOQL query filtering on the subscriberKey, and dispatch the Twilio SMS with the contact's phone and the configured message body. Sync Marketing Cloud opt-outs to Twilio by configuring your Twilio inbound SMS STOP keyword handler to call the Marketing Cloud REST API at POST https://{subdomain}.rest.marketingcloudapis.com/contacts/v1/contacts/actions/delete to unsubscribe the contact by their mobile phone number, and conversely handle Marketing Cloud unsubscribes by listening to Marketing Cloud's REST API subscription status changes and adding the contact's phone to a Twilio opt-out list using the Twilio REST API. Track SMS engagement by logging each Twilio message SID and dispatched contact back to a Marketing Cloud Data Extension via POST https://{subdomain}.rest.marketingcloudapis.com/hub/v1/dataevents/{externalKey}/rowset, storing the MessageSid, ContactPhone, JourneyName, ActivityName, and DispatchTimestamp fields for use in Marketing Cloud reporting.

Common Issues and How to Fix Them

Marketing Cloud Journey Builder calls the /execute endpoint with a 5-second timeout, and if your Custom Activity backend takes longer than 5 seconds to retrieve the contact's phone from the Data Extension and dispatch the Twilio SMS, the Journey Builder marks the step as failed and retries, causing the contact to receive multiple SMS. Return a 200 response to the /execute endpoint within 2 seconds by immediately acknowledging the request and processing the Data Extension query and Twilio dispatch asynchronously in a background job, storing the outcome in a log that your backend can reference if Journey Builder queries the activity status. Marketing Cloud Custom Activity /config responses must be served over HTTPS with a valid SSL certificate from a trusted certificate authority, and self-signed certificates cause Journey Builder to reject the activity entirely with a connection error in the Marketing Cloud Setup UI. Use a production SSL certificate from Let's Encrypt or a commercial CA for your Custom Activity backend domain, and verify the certificate chain is complete by testing the endpoint URL in an SSL checker before registering the activity in Marketing Cloud. The Marketing Cloud REST API token expires after 20 minutes, and a Custom Activity backend that does not refresh the token proactively will begin returning 401 errors from Marketing Cloud Data Extension queries during the same day as the token is issued, causing failed SMS dispatches and journey stalls. Implement token caching with expiry tracking and refresh the Marketing Cloud token 1 minute before expiry using your stored Client ID and Client Secret, or use the Marketing Cloud Node.js SDK which handles token lifecycle automatically.

How to Get More from This Integration

Build a two-way SMS engagement step in Marketing Cloud Journey Builder by adding a second Custom Activity that pauses the journey and waits for an inbound Twilio SMS reply, using a Marketing Cloud Event activity downstream of the SMS send step, and when the customer replies having your Twilio inbound webhook handler call the Marketing Cloud Interaction API at POST https://{subdomain}.rest.marketingcloudapis.com/interaction/v1/events to fire the Event that advances the customer to the next journey step based on their reply keyword. Add A/B testing to your Twilio SMS journey step by creating a Journey Builder custom split activity alongside the SMS activity, randomly assigning contacts to two message variant configurations stored in configurationArguments, tracking the variant in your SMS log Data Extension, and reporting click-through rates by comparing link click data from a Twilio URL-shortened link against the variant assignments. Create a transactional triggered send by bypassing Journey Builder entirely for time-sensitive transactional SMS such as OTPs and order confirmations, using the Marketing Cloud REST API at POST https://{subdomain}.rest.marketingcloudapis.com/messaging/v1/messageDefinitionSends/key:{externalKey}/send to trigger a Twilio SMS template send for a single contact, providing sub-second dispatch latency for transactional messages where journey latency is unacceptable. Extend the integration with Twilio WhatsApp as a second channel in the same Journey Builder path by adding a decision split after the initial SMS step that checks whether the contact has a WhatsApp opt-in field set to true in the Data Extension, routing opted-in contacts to a WhatsApp Custom Activity step that dispatches through the Twilio WhatsApp Business API and routing all other contacts through the standard SMS activity.

Conclusion

Twilio and Salesforce Marketing Cloud together add a high-deliverability, compliant SMS channel to your Marketing Cloud journeys with full contact, opt-out, and engagement data synchronized across both platforms. Contact Telphi Consulting to build and configure the Twilio Marketing Cloud Custom Activity and journey integration for your marketing team.

Share this article:
0 views

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)

Protected by AI moderation

Be the first to comment

No comments yet. Share your thoughts below.