Syncing segments from Twilio Segment Audiences
Read time: 5 minutes
Last edited: Sep 20, 2023
Syncing segments from Twilio Segment Audiences is available to customers on an Enterprise plan. To learn more, read about our pricing. To upgrade your plan, contact Sales.
Syncing segments from Twilio Segment Audiences is only available to members of LaunchDarkly's Early Access Program (EAP). If you want access to this feature, join the EAP.
Overview
This topic explains how to create segments that sync with a Twilio Segment Audience. Segment syncing lets you import audiences from Twilio Segment to LaunchDarkly to more efficiently target and deliver feature flags.
The primary benefit of syncing segments with Twilio Segment is the automatic syncing between Twilio Segment and LaunchDarkly. This lets you concentrate more on deploying features and less on managing end users between platforms. You can connect a new or existing Twilio Segment Audience to LaunchDarkly. LaunchDarkly interprets each Audience as a segment.
The prerequisites for synced segments apply.
Prerequisites
In order to sync segments, you must meet the following prerequisites:
- You must have a Twilio Segment account with the Engage Audiences feature enabled. Contact your Twilio Segment Customer Success Manager to enable the Engage Audiences feature.
- You must have a Twilio Segment role that allows you to create destination connections and Engage Audiences. To learn more, read Roles.
- You must have a LaunchDarkly service token with write access for the project you want to connect to Twilio Segment. To learn more, read Configuring your service token.
- You must have a LaunchDarkly client-side ID for the environment you want to connect to Twilio Segment. To learn more, read Copying your LaunchDarkly client-side ID.
- If you are using server-side SDKs, or client-side SDKs with the Relay Proxy, there are additional prerequisites.
Creating a segment that syncs with Twilio Segment
To configure a segment that syncs with a Twilio Segment Audience, you must choose an Audience in Twilio Segment and configure it to use the LaunchDarkly Audiences destination. When you do this, the cohort appears as a segment in LaunchDarkly.
To do this, your will need to first configure the LaunchDarkly Audiences destination and then add the LaunchDarkly Audiences destination as a Twilio Segment Audience.
Configuring your service token
To add LaunchDarkly as a destination in Twilio Segment, you need a service token from your LaunchDarkly project. To learn how to create a service token, read Creating API access tokens.
Your service token must have either a Writer or custom role. If your service token has a custom role, it must have the actions createSegment
and updateIncluded
to sync a segment from Twilio Segment.
Below is an example of the permissions needed for your custom role:

[{"effect": "allow","actions": ["createSegment", "updateIncluded"],"resources": ["proj/*:env/*:segment/*"]}]
To learn more, read Custom roles and Segment actions.
Configuring the LaunchDarkly Audiences destination
To add LaunchDarkly as an Audiences destination:
- Sign in to Twilio Segment and observe the unique Twilio Segment workspace URL slug in the browser's address bar. This URL slug is unique to your account and is formatted as follows:
https://app.segment.com/<YOUR_SEGMENT_WORKSPACE_SLUG>/home
. - Navigate to the LaunchDarkly Audiences Catalog listing in Twilio Segment by visiting
https://app.segment.com/<YOUR_SEGMENT_WORKSPACE_SLUG>/destinations/catalog/actions-launchdarkly-audiences
in your browser. Be sure to replace<YOUR_SEGMENT_WORKSPACE_SLUG>
with your unique Twilio workspace slug. - Click Add destination.
- Select an existing Engage space as the data source. If you do not have an existing Engage space, follow Twilio Engage Foundations Onboarding Guide.
- Click Confirm source.
- On the Basic settings page, provide a human-readable Name for the destination. Because each instance of a LaunchDarkly Audiences destination can only sync to a single project and environment in LaunchDarkly, we recommend including project and environment information in the name.
- Enter the service token you created previously in the LaunchDarkly Service Token field.
- In the LaunchDarkly client-side ID field, enter the client-side ID corresponding to the environment where your synced segment will be created in LaunchDarkly. To learn more, read Copying your LaunchDarkly client-side ID.
- Click the Enable Destination toggle.

- Navigate to the Mappings tab of your LaunchDarkly Audiences destination configuration.
- Click New Mapping.
- Select the Sync Engage Audience to LaunchDarkly pre-built mapping.

-
Scroll to Select mappings and modify the following settings as needed:
- Context kind: The LaunchDarkly context kind for the LaunchDarkly synced segment. The default value is
user
. For more information, read Context kinds. - Context key: The Twilio Segment audience property that will be used as the context key. For most customers, the default value of Use Segment UserId only is recommended.
- Enable batching: Select Yes.
- Context kind: The LaunchDarkly context kind for the LaunchDarkly synced segment. The default value is

- Click Save.
- Ensure the Status toggle on the Mappings tab is enabled.

Adding the LaunchDarkly Audiences destination as a Twilio Segment Audience
To add the LaunchDarkly Audiences destination to your Twilio Segment Audience:
- Navigate to the Audiences page in Twilio Segment and select the Audience you would like to sync with LaunchDarkly.
- In the Destinations section of the Audience page, select Add destination.
- Select the LaunchDarkly Audiences destination that you configured previously.
- Click Save. The default values for Send Identify and Send Track are appropriate.
- Click Add 1 destination.
- Verify that your Audience now displays your LaunchDarkly Audiences destination as a synced destination.

- The first sync will start about ten minutes after adding the LaunchDarkly Audiences destination. A new LaunchDarkly segment will be created automatically. Navigate to the Segments tab in LaunchDarkly to verify your new synced segment exists in LaunchDarkly. The segment's name will be the same as the Twilio Segment Audience's name.
