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?

Create your Flex-Salesforce Integration

With out-of-the-box support for Salesforce CTI Connector, you are now able to power your Salesforce CRM with Omnichannel Communications offered by Flex. Both Salesforce Classic and Lightning integrations are supported, allowing you to use Flex directly within your Salesforce instance.

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

[ Please read release notes for list of Supported Features ]

Let's get started!


You can configure your Flex-Salesforce Integration by navigating to "Integrations" Option in Flex Admin

Flex Salesforce Integration

Following Parameters are required for the configuration

Parameter Name Description
Are you planning to use SSO

Select this option if you want to implement Flex-Salesforce Integration behind an SSO.

**In a production environment, you might always want to check this option

*** Leave this unchecked if you are planning to test out the Integration using your Twilio Account/Project Login credentials

Workflow SID

(Optional) If you want use a Workflow different than the default Workflow, please supply the Workflow SID here . If not, leave it empty.

** If you are not sure what it is, then leave it empty

Task Channel SID

(Optional) If you want use a Task Channel different than the default Voice Channel, please supply the TaskChannel SID here . If not, leave it empty.

** If you are not sure what it is, then leave it empty

Outbound Caller ID (Mandatory) This will be the caller-Id used for outbound calls from the Flex-Salesforce Integration (via Click to Dial) if any agent does not have defined caller Id
Salesforce Base URL (Mandatory) Your salesforce URL


  • Create Twilio Functions by clicking the "Helper Functions" Create Option
  • Download the Call Centre Definition File to be used in your Salesforce Call Centre Configuration. (Please note that different Call centre Definition Files are generated depending upon whether you used SSO or not )
  • Configure your Salesforce by following our docs here

Flex Salesforce Integration (Configuration )

If you selected "Are you planning to use SSO" during the configuration step, you must update the "CTI Adapter URL" within your Call Centre Definition file. Your file will contain:

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

Need to create a new Salesforce project 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 in to your Salesforce org
  2. In the top right of your Salesforce view, click on Setup
    Go to Salesforce Setup
  3. In the left-hand search box, search for “Call Center.” Then, click on Call Centers.
    Salesforce: Navigate to 'Call Centers'
  4. Click on Import and continue to import the right Call Center definition file. If your Flex instance is the default hosted Flex (, then use Call Center Definition File (Hosted Flex) . Alternatively if you have deployed Flex on your own infrastructure, please use Call Center Definition File(Self Hosted Flex)
    Salesforce: Import call definition file
  5. Once you press Import button, you should see the Call Center Definition:
    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

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

Salesforce: Find softphone layout settings

Your Screen Pop Settings should be the following:

  • 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 have configured Flex-Salesforce Integration using above steps, please skip this section and proceed to "Setup Taskrouter for Outbound Calling")

If you are still using an older Integration,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 Path mentioned.

By default, pointing your implementation to the source path 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 the bare minimum, you must define a global default CallerId 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 has been deployed successfully.

Create Twilio Functions for Outbound Calling

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

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

Migrate from Beta to GA

Migration from the Beta version to GA version is trivial and involves the following steps:

  1. Make a note of entries in your sfdcConfig.js file – you will need these values while Configuring the GA version of your Flex Salesforce Integration
  2. Navigating 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 the call to the worker that clicked the phone number, we'll need to create a routing rule.

Navigate to Taskrouter Workspace and go to the Workflow that you are using for the Outbound Call. 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, do 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 Credential to log in as admin via the Flex login screen.

For any Production implementation, you might want to configure Single Sign-on on 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, you'll need to follow these steps first.

  1. Log in to 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 and ready for use!

Full Flex-Salesforce Integration.

Launch with Salesforce-Classic

  1. Log in to 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 right corner of the screen and click on it.
    Log in to Twilio Flex via Salesforce Classic.
  4. Log in to Flex.
  5. Once logged in, you will have Twilio Flex inside of Salesforce Classic and ready for use!

Full Flex-Salesforce (Classic) Integration

Configure Salesforce for Open CTI

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

Go to Setup > search bar > App Manager

Salesforce classic: navigate to the app manager.

Go to Utility Items

Salesforce lightning: Utility items.

Add Open CTI Softphone to your list of utilities

Salesforce Lightning: Add Open CTI softphone.

Configure the Open CTI Softphone

Salesforce Lightning: Configure Open CTI Softphone for Flex.

And 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.