Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Integrate Flex with Salesforce

With out-of-the-box support for Salesforce Open CTI, you can now power your Salesforce environment with omnichannel communications offered by Flex. Both Salesforce Classic and Lightning Experience integrations are supported, allowing you to use Flex directly within your Salesforce instance.

In this guide, you will learn how to configure Flex within Salesforce, configure outbound calling, enable SSO (Single Sign-On), and launch your integration.

Please read the release notes for a complete list of supported features.

Let's get started!


Start by configuring your Flex-Salesforce Integration by navigating to the "Integrations" section in your Flex Admin view.

Flex Salesforce Integration

The following parameters are required for the configuration:

Parameter Name Description
Are you planning to use SSO for this integration?

Select this option if you want to deploy the Flex-Salesforce Integration using Single Sign-On (SSO).

Always check this option if you are operating in a production environment.

Leave this unchecked if you are planning to test the integration using your Twilio Account/Project login credentials.

Workflow SID

(Optional) If you want to use a different Workflow than the default Workflow, please supply the Workflow SID here. If not, leave it empty. If you are not sure what this is, then leave it empty

Task Channel SID

(Optional) If you want to use a different Task Channel than the default Voice Channel, please supply the Task Channel SID here. If not, leave it empty. If you are not sure what this is, then leave it empty.

Agent Caller ID (Required) This will be the caller ID used for outbound calls from the Flex-Salesforce Integration (via Click-to-Dial) if an agent does not have a defined caller ID.
Salesforce Base URL (Required) Your Salesforce domain URL.


  • Create Twilio Functions by clicking Generate Functions.
  • Click "Download" under the Files section to download the Call Center Definition file to be used in your Salesforce Call Center configuration. (Please note that different Call Center Definition Files are generated depending upon whether you use SSO or not.)
  • Configure your Salesforce instance by following the next steps below.

Flex-Salesforce Integration Section

If you selected "Are you planning to use SSO for this integration?" during the configuration step, you must update the "CTI Adapter URL" in your Call Center Definition file. Your file will contain:

Update "yourRuntime-Domain-3869" to your Twilio account's Runtime Domain. You can find your Runtime Domain here.

Need to create a new Salesforce organization for your proof of concept? Create a Salesforce developer account at

Configure Salesforce for your integration

Import the Flex Call Center Definition file

  1. Log into your Salesforce org
  2. In the top right of your Salesforce view, click Setup
    Go to Salesforce Setup
  3. In the left-hand search box, search for “Call Center.” Select Call Centers.
    Salesforce: Navigate to 'Call Centers'
  4. Click Import to import your Call Center Definition file.
    Salesforce: Import call definition file
  5. You should now see the Call Center Definition you just imported:
    Salesforce: Call center definition

Add users to your newly-imported Call Center

Add users to your newly-created Flex Call Center on Salesforce by clicking on Manage Call Center Users

Salesforce: manage call center users

Once you have finished adding users, you should see a screen that looks like this:

Salesforce: Flex call center UI

Configure the Salesforce Softphone layout

1. Under Call Center in the left-hand search bar, click on Softphone Layouts.

Salesforce: Find softphone layout settings

2. Set your Screen Pop Settings to the following values:

  • Screen Pops open within: New browser window or tab
  • No matching records: Pop to new Contact
  • Single-matching record: Pop detail page
  • Multiple-matching record: Pop to search page

Still Using Beta ?

(If you configured the Flex-Salesforce Integration using the above steps, please skip this section and proceed to "Set up TaskRouter for Outbound Calling")

If you deployed an older version of the Flex-Salesforce integration and still need to use that version, you will need the following assets during the setup process:

Asset Type Asset Source(s)
Flex-Salesforce Integration


Call Center Definition File (Twilio-Hosted Flex) callCentreDefinition_HostedFlex.xml
Call Center Definition File (Self-Hosted Flex) callCentreDefinition_selfHost.xml
Outbound Caller ID Phone Number
Flex-Salesforce Integration Configuration sfdcConfig.js

Please note that instead of downloading the above assets, you can also directly point your implementation to the Asset Source paths mentioned.

By default, pointing your implementation to the source paths will sign you up for automatic updates – if you do not wish to subscribe to automatic updates, it's best to download the assets instead.

Enable integrations with your Flex project

If any of the following applies to you, you will need to modify the Flex-Salesforce Integration Configuration file (sfdcConfig.js):

  • You want to set up outbound dialing
  • You want to use a global caller ID for agents who do not have a specified caller ID
  • You have your own custom workflow that you'd like to use
  • You have an existing customer channel that handles outbound voice calls

Your sfdcConfig.js file should look something like this:

/*in Beta/GA, this will move to CRM configuration screens */
var sfdcConfig = {};

sfdcConfig.globalParams = {
 outboundWorkflowSid: "", //leave it empty,if using default Workflow
 outboundTaskChannel: "", //leave it empty,if using default Voice Channel
 SFDCBaseUrl: "" // Your SFDC Org

sfdcConfig.agentParams = [];

// default Global Caller Id for outbound calls, when not specific caller Id has been
//defined for an agent in the worker attribute viz. callerId or below agentParams
window.sfdcConfig.defaultAgentParam = {
 outboundCallerId: "+447777777777"

// these are caller ids for various agents
//- you can use this setting here if not defining in worker attribute 
sfdcConfig.agentParams["user1"] = {
 outboundCallerId: "+44777777777"

sfdcConfig.agentParams["user2"] = {
 outboundCallerId: "+44777777771"

Populate the relevant information in this file depending on your needs.

At a bare minimum, you must define a global default Caller ID in the sfdcConfig.js file if you have not defined a unique caller ID for each agent in their worker attribute.

Next, navigate to Runtime>Assets in your Twilio Console.

Import the Flex-Salesforce Integration plugin and Flex-Salesforce Integration Configuration:

Flex assets: Import the Flex-Salesforce integration file.

Confirm your asset upload. You will see a green notification banner letting you know when your function deployed successfully.

Create Twilio Functions for Outbound Calling

Navigate to the Flex-Salesforce integration template in the Twilio console and click Create.

Close the window once the functions are created and visible in Runtime>Functions.

Migrate from Beta to GA

Migrating from Beta to GA is trivial and requires the following steps:

  1. Make a note of entries in your sfdcConfig.js file – you will need these values when configuring the GA version of your Flex-Salesforce Integration
  2. Navigate to Runtime>Assets in your Twilio Console to delete the plugin (i.e. Beta version).
  3. Delete the Functions created in the above steps by navigating to Runtime>Functions.
  4. Follow the steps described in the Setup above

Set up TaskRouter for Outbound Calling

To ensure that we only route calls to workers that click on phone numbers in Click-to-Dial scenarios, we need to create a routing rule.

Navigate to your TaskRouter Workspace and select the Workflow you will use for outbound calls. Then, add a filter as shown in the following screenshot:

TR Workflow Filter for Outbound Calls

The default Flex Project configures Studio Flows with some default Task attributes. If you are modifying the flow or creating a new one, make sure you add the following attributes:

{ "type": "inbound", "name": "{{}}" }

Enable SSO

For your Proof-of-Concept, MVP, or development project, you can use your Twilio credentials to log in as an admin via the Flex login screen.

For any Production implementation, you might want to configure Single Sign-On with Twilio Flex by integrating your Identity Provider. See this guide to learn more about configuring SSO for Flex.

Make sure you define a worker attribute callerId through your SSO setup. We recommend defining a default outbound Caller ID as described above.

If you haven't configured any Salesforce application to use OpenCTI in the utility bar, follow these steps first.

  1. Log into your Salesforce account.
  2. Click on the App Launcher and go to the application that you've configured with Open CTI.
  3. Find Twilio Flex in the bottom left corner of the screen and click on it.
    Find Flex in your Salesforce app.
  4. You will be prompted to log in:
    Log in to Twilio Flex via Salesforce.

  5. Once logged in, you will have Twilio Flex inside of Salesforce Lightning Experience, ready to use!

Full Flex-Salesforce Integration.

Launch with Salesforce - Classic

  1. Log into your Salesforce account.
  2. Click on the App Launcher and select the Console application that you configured with Open CTI
  3. Find Twilio Flex in the bottom right corner of the screen and select it.
    Log in to Twilio Flex via Salesforce Classic.
  4. Log into Flex.
  5. Once logged in, you will have Twilio Flex inside of Salesforce Classic, ready to use!

Full Flex-Salesforce (Classic) Integration

Configure Salesforce for Open CTI

Add your Softphone to your utility bar in Salesforce Lightning Experience by following these steps:

Go to Setup > Search Bar > App Manager

Select your App and click Edit in the dropdown menu.

Salesforce classic: navigate to the app manager.

Go to Utility Items

Salesforce lightning: Utility items.

Add Open CTI Softphone to your list of Utility Items.

Salesforce Lightning: Add Open CTI softphone.

Configure the Open CTI Softphone with the below values:

Salesforce Lightning: Configure Open CTI Softphone for Flex.

That's it! See our guide on Call Flows to take it for a spin.

What's next?

Now that you've integrated Flex with your Salesforce instance, learn more about customizing your integration and managing interactions with your users:

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.