Skip to contentSkip to navigationSkip to topbar
Page tools
Useful for sharing or LLM
Accelerate development with AI

On this page
Looking for more inspiration?Visit the

Set up Salesforce BYOC CCaaS with Twilio SMS and WhatsApp Channels


This guide walks you through configuring Salesforce Bring Your Own Channel for Contact Center as a Service (BYOC CCaaS)(link takes you to an external page) with Twilio SMS and WhatsApp channels. BYOC CCaaS allows you to surface Twilio-powered messaging channels directly in Salesforce Messaging, so agents can handle SMS and WhatsApp conversations from within the Salesforce interface.


Prerequisites

prerequisites page anchor

Before starting, make sure you have the following:

  • A Flex account.
  • A Salesforce org with Service Cloud and Messaging enabled.
  • A Twilio SMS number or WhatsApp sender configured in your Twilio account.

Configure SSO for Salesforce and Flex

configure-sso-for-salesforce-and-flex page anchor

You need single sign-on (SSO) for both your Flex account and your Salesforce account. You can use Salesforce, Okta, or another identity provider (IdP) that supports SAML 2.0.

Follow Configure SSO for Salesforce and Flex in the Salesforce Service Cloud Voice (SCV) guide, then return to this guide.


For Salesforce to integrate with Twilio, you need your Twilio Account SID and Auth Token, and matching credentials in your Salesforce org.

Follow Create credentials in the SCV guide, then return to this guide. That section covers finding your Account SID and Auth Token, creating external credentials, and creating named credentials.


Install the Twilio package

install-the-twilio-package page anchor

Before you can create Twilio messaging channels, you must install the Twilio BYOC CCaaS managed package in your Salesforce org.

  1. While logged in to your Salesforce org, open the Twilio BYOC CCaaS listing(link takes you to an external page) on Salesforce AppExchange.
  2. Click Get It Now and select the Salesforce org where you want to install the package.
  3. Select Install for All Users.
  4. Expand Advanced Options and select Compile only the Apex in the package.
  5. Click Install and wait for the installation to complete.
(warning)

Warning

When installing in a Production or Sandbox environment that already contains Apex classes, always select Compile only the Apex in the package. Using the default compilation option may cause conflicts and fail the installation.


Create and configure your Salesforce contact center

create-and-configure-your-salesforce-contact-center page anchor

You link your Twilio messaging channels to a Partner Telephony contact center, so create the contact center before you create the channels.

Follow Create and configure your Salesforce contact center in the SCV guide, then return to this guide.


Add users to the contact center

add-users-to-the-contact-center page anchor

Add the users who need to handle Twilio conversations to the contact center you created. Note that Salesforce users can only belong to one call center or contact center at a time, so you may need to remove a user from an existing call center first.

Follow Configure contact center settings in the SCV guide, then return to this guide.


Assign the Twilio Config Admin permission set

assign-the-twilio-config-admin-permission-set page anchor

The Twilio Config tab only appears for users who have the Twilio Config Admin permission set assigned. Assign it to any user who needs to access the Twilio Config page, such as the admin completing this setup.

  1. From the Salesforce Setup Home page, search for and select Permission Sets.
  2. Select Twilio Config Admin.
  3. Click Manage Assignments, then click Add Assignments.
  4. Select the user(s) who need access to the Twilio Config page and click Assign.

Enable Messaging in Salesforce

enable-messaging-in-salesforce page anchor
  1. From the Salesforce Setup Home page, search for and select Messaging Settings.
  2. Toggle Messaging to On.

Create Twilio messaging channels

create-twilio-messaging-channels page anchor
  1. In Messaging Settings, click New Channel.
  2. Select Bring Your Own Channel.
  3. Because the Twilio package is installed, you will see two Twilio channel options: SMS and WhatsApp.
  4. Select the channels you want to configure (you can select both).
  5. Link the selected channels to the contact center you created in Create and configure your Salesforce contact center.

Create an integration user

create-an-integration-user page anchor
  1. From the Salesforce Setup Home page, search for and select Users.
  2. Create a new user with the Salesforce API Only System Integrations profile.

Configure integration user permissions

configure-integration-user-permissions page anchor

The integration user must have the correct permissions to read and publish platform events.

  1. Ensure the integration user created in Create an integration user has the Salesforce API Only System Integrations profile.

  2. Edit the profile to grant it access to the platform events:

    1. From the Salesforce Setup Home page, search for and select Profiles.
    2. Select the Salesforce API Only System Integrations profile, then click Edit.
    3. Under Platform Event Permissions, grant Read and Create access to all platform events.
    4. Click Save.
  3. From the Salesforce Setup Home page, search for and select Permission Sets.

  4. Select the SCRT2 Integration User permission set.

  5. Click Object Settings, then grant Read and Create access to the platform events for the channels you configured:

    • Sms Events (Twilio_Scv__Sms_Event__e) — required for the SMS channel.
    • Whatsapp Events (Twilio_Scv__Whatsapp_Event__e) — required for the WhatsApp channel.

    If you configured both channels, grant access to both platform events. For more information, see Task 3: Assign permissions to the platform event(link takes you to an external page) in the Salesforce documentation.


Create an External Client App

create-an-external-client-app page anchor
  1. From the Salesforce Setup Home page, search for and select App Manager.
  2. Click New External Client App.
  3. Fill in the Basic Information fields:
    FieldValue
    External Client App NameFor example, Twilio Byoccaas
    API NameFor example, Twilio_Byoccaas
    Contact EmailYour contact email
    Distribution StateLocal
  4. Under App Settings, configure OAuth:
    • Set Callback URL to https://login.salesforce.com.
    • In Selected OAuth Scopes, add:
      • Perform requests at any time (refresh_token, offline_access)
      • Access Interaction API resources (interaction_api)
  5. Under Flow Enablement, enable JWT Bearer Flow.
  6. Under Certificate Upload, upload the Twilio certificate. To download the certificate:
    1. From the Salesforce Setup Home page, search for and select App Manager.
    2. Find Twilio for Service Cloud in the list and launch it.
    3. Navigate to the Twilio Config tab. If the tab is not visible, go to App Manager, find Twilio for Service Cloud, click Edit, click Navigation Items, and add both Twilio Config and Messaging Sessions to the app's selected items. Messaging Sessions is needed so that agents can open messaging conversations in the app.
    4. In the Certificate Information section, click Download Certificate.
    5. Return to your External Client App and upload the downloaded certificate file.
  7. Save the External Client App.

Add the integration profile to the External Client App

add-the-integration-profile-to-the-external-client-app page anchor
  1. Open the External Client App you created.
  2. Go to Policies.
  3. Set Permitted Users to Admin approved users are pre-authorized. This is required before the profile and permission set options become available.
  4. Under Select Profiles, add Salesforce API Only System Integrations to the Selected Profiles list.
  5. Under Select Permission Sets, add:
    • SCRT2 Integration User
    • Partner Telephony Permission Set
  6. Click Save.

  1. Open the External Client App you created.
  2. Navigate to Settings > Consumer Key and Secret.
  3. Copy the Consumer Key. You will need it when configuring the Twilio Config page.

Activate your messaging channels

activate-your-messaging-channels page anchor

Each channel must be set to Active and linked to your External Client App. Conversations won't reach your agents until you complete this step.

  1. From the Salesforce Setup Home page, go to Messaging Settings > Channels.
  2. Open your Twilio SMS or WhatsApp channel.
  3. Click Modify Conversation Channel Definition and link the channel to the External Client App you created in Create an External Client App.
  4. Confirm that the channel's status is Active.
  5. Repeat for each Twilio channel you created in Create Twilio messaging channels.

Get the channel identifier

get-the-channel-identifier page anchor
  1. From the Salesforce Setup Home page, go to Messaging Settings > Channels.
  2. Find your Twilio SMS or WhatsApp channel.
  3. Note down the Channel Identifier (also called the Messaging Platform Key). You will need this in the next step.

Configure the Twilio Config page

configure-the-twilio-config-page page anchor
(warning)

Warning

Complete every preceding step in this guide before you configure the Twilio Config page. This page ties the whole integration together, so any step that was skipped or misconfigured earlier — such as integration user permissions, the External Client App policies and certificate, or channel activation — surfaces here as a broken integration. In that case, agent messages may never reach the customer, even though the configuration appears to save successfully.

  1. In your Salesforce org, open the Twilio for Service Cloud app.
  2. Navigate to the Twilio Config tab.
  3. Complete the configuration form:
    FieldValue
    Consumer KeyThe Consumer Key from Note the Consumer Key
    UsernameThe integration user created in Create an integration user
    Connected App API NameThe API Name of your External Client App (for example, Twilio_Byoccaas)
  4. Under Select Channels, check SMS, WhatsApp, or both.
  5. For each selected channel, enter the Channel Address Identifier you noted in Get the channel identifier.
  6. Under Outbound Config, select the Workflow and Queue to use for outbound messages, then enter the Phone Number to send from. Copy this number from the Twilio Console (Phone Numbers > Manage > Active Numbers) and enter it in E.164 format (for example, +15017122661).
  7. Click Save Configuration.

Enable agent-initiated outbound messaging in Salesforce

enable-agent-initiated-outbound-messaging-in-salesforce page anchor

By default, agents can only reply to inbound conversations. To let agents start a new SMS or WhatsApp conversation with a customer, enable agent-initiated outbound messaging. For more information, see Send a Message to a Customer(link takes you to an external page) in the Salesforce documentation.

  1. From the Salesforce Setup Home page, search for and select Permission Sets (or edit the relevant profile).
  2. Assign the following user permissions to your agents:
    • Messaging Agent
    • Initiate Messaging Sessions (required for enhanced channels, which BYOC CCaaS uses)
    • Access Conversation Entries
    • End Messaging Session
  3. Add the Send a Message action so it's available to reps. The Send a Message button is automatically available when messaging from the Omni-Channel widget in the Salesforce mobile app, but you must add the action to the desktop UI yourself. You can add it to the global action menu, to certain record detail pages, and to the activity timeline. Choose the location or locations that best fit your outreach process.
    • Add the Send a Message action to the global action layout. This lets reps send a message from any Salesforce page.
      1. From the Salesforce Setup Home page, search for and select Publisher Layouts.
      2. Drag the Send a Message action to the Mobile and Lightning Actions section of the palette. This action is available only if you have an active enhanced Messaging or Messaging for In-App channel.
      3. Save your changes.
    • Optionally, add the Send a Message quick action to your lead, contact, person account, or messaging user record page layouts. This lets reps send a message from these types of records.
    • Optionally, add the Send a Message quick action to the activity timeline. This lets reps click the timeline action to send a message.

Enable messaging to new Contacts with no existing conversation (optional)

enable-messaging-to-new-contacts-with-no-existing-conversation-optional page anchor

Agents can only send a message to a MessagingEndUser record, and Salesforce creates that record automatically only when a conversation first starts (for example, when the customer sends an inbound message). This means that, out of the box, agents can't send an outbound message to a Contact that has never messaged in on a channel, since no MessagingEndUser exists for them yet.

If you need to reach brand-new Contacts that have no prior conversation (for example, for proactive outreach or broadcast messaging), you must create the MessagingEndUser record yourself ahead of time. This requires custom Apex in your org, generally structured as:

  • A trigger on Contact (after insert) that hands off the new Contact records to a service class.
  • A service class that looks up your org's active MessagingChannel records and inserts a MessagingEndUser for each Contact/channel combination, using the Contact's phone number as the messaging platform key (formatted per channel, for example prefixed with whatsapp: for WhatsApp).
  • Logic to skip Contacts that already have a matching MessagingEndUser, so the trigger doesn't create duplicates on subsequent updates.

The following illustrates the general shape of this pattern; treat it as a starting point rather than production-ready code:

ContactAfterInsert.trigger

contactafterinserttrigger page anchor
1
trigger ContactAfterInsert on Contact (after insert) {
2
MessagingUserProvisioner.createForContacts(Trigger.new);
3
}

MessagingUserProvisioner.cls

messaginguserprovisionercls page anchor
1
public with sharing class MessagingUserProvisioner {
2
3
public static void createForContacts(List<Contact> contacts) {
4
List<MessagingChannel> channels = [
5
SELECT Id, DeveloperName
6
FROM MessagingChannel
7
WHERE IsActive = true
8
WITH SECURITY_ENFORCED
9
];
10
11
List<MessagingEndUser> newEndUsers = new List<MessagingEndUser>();
12
13
for (Contact c : contacts) {
14
if (String.isBlank(c.MobilePhone)) {
15
continue;
16
}
17
for (MessagingChannel channel : channels) {
18
newEndUsers.add(new MessagingEndUser(
19
ContactId = c.Id,
20
MessagingChannelId = channel.Id,
21
MessagingPlatformKey = formatKey(c.MobilePhone, channel),
22
Name = c.Name + ' - ' + channel.DeveloperName
23
));
24
}
25
}
26
27
if (!newEndUsers.isEmpty()) {
28
insert newEndUsers;
29
}
30
}
31
32
// Prefix with "whatsapp:" for WhatsApp channels; adjust per channel type as needed
33
private static String formatKey(String phone, MessagingChannel channel) {
34
Boolean isWhatsApp = channel.DeveloperName.containsIgnoreCase('WhatsApp');
35
return isWhatsApp ? 'whatsapp:' + phone : phone;
36
}
37
}
(information)

Info

This sample omits production concerns such as phone number normalization and de-duplication against existing MessagingEndUser records — add those before using this in a live org.

(information)

Info

This is a customization built on top of the Twilio managed package, not something it provides out of the box. Have your Salesforce development team implement and test this trigger/service pattern against the MessagingEndUser and MessagingChannel objects before relying on it for proactive outreach.

Alternative: build this with a Flow instead of Apex

alternative-build-this-with-a-flow-instead-of-apex page anchor

If you'd rather avoid custom code, you can implement the same logic with a Record-Triggered Flow instead of an Apex trigger:

  1. Create a Record-Triggered Flow that runs After Save when a Contact is created.
  2. Add a Get Records element to retrieve active MessagingChannel records (IsActive equals True).
  3. Add a Loop over the retrieved MessagingChannel records.
  4. Inside the loop, use a Formula resource to build the messaging platform key from the Contact's phone number, adding the whatsapp: prefix when the channel's DeveloperName contains WhatsApp.
  5. Add a Create Records element inside the loop to insert a MessagingEndUser using the current Contact, the loop's MessagingChannel, and the formula value from Step 4.

Turn on messaging transfers in Twilio Console

turn-on-messaging-transfers-in-twilio-console page anchor

For agents to transfer an SMS or WhatsApp conversation to another agent or to a queue, you must turn on messaging transfers in Twilio Console. Transfers are off by default.

  1. In Twilio Console(link takes you to an external page), go to Flex > Channel management > Transfers, and then click the Messaging tab.
  2. Turn on Enable messaging transfers.
  3. Optionally, turn on Enable messaging transfer notes to let agents send a note along with a transfer.

For more information, see Turn on messaging transfers for Conversations.


Enable After Conversation Work (ACW) for messaging

enable-after-conversation-work-acw-for-messaging page anchor

We recommend that you enable ACW for your messaging conversations.

Without ACW, an agent's capacity stays consumed until they close the conversation. The agent has to close the conversation to complete the work item and become available for the next conversation. When you enable ACW, the agent gets a defined wrap-up period after the conversation ends, and their capacity is released when the ACW timer ends.

To enable ACW, and to add the After Conversation Work component to the Messaging Session page so agents can see the ACW countdown, follow the Salesforce documentation Configure After Conversation Work Time(link takes you to an external page).


Verify agent and org prerequisites

verify-agent-and-org-prerequisites page anchor

Before going live, confirm the following:

  • Agents have the Contact Center Bring Your Own Channel user permission set assigned.
  • Presence statuses (for example, Available) are added to the new channels.
  • Each channel is set to Active in Messaging Settings, as described in Activate your messaging channels.

Once configuration is saved, log in as an agent, set your status to Available, and send a test SMS or WhatsApp message to your Twilio number. The conversation should appear in the agent's Salesforce Omni-Channel widget.

If the conversation does not appear, verify that the Enhanced Conversation component has been added to the relevant Lightning page. Open the page in the Lightning App Builder, add the Enhanced Conversation component, and save.