Skip to main content


Enhancing the Twilio Flex Experience with Segment

Istock 1069272512

Customers want to interact with a website that adapts to their needs, and as a result, the key segments of the modern customer digital experience are personalization and convenience. Customers not only expect the ability to make purchases or leave comments, but they also expect those interactions to be saved for the purpose of updated account preferences and future recommendations.

These same expectations are changing the world of customer service and contact center experience. To keep up with rising challenges, contact centers need to provide a personalized experience to their customers and this is where Segment comes in. It provides a unified customer profile that can be used to create a consistent and customized customer experience across multiple platforms.

Our team has been working to create a Segment / Twilio Flex integration that an agent can use to assist a customer, especially while they navigate through a connected website. Segment uses powerful tools to process customer data that Twilio Flex then channels through a customizable user-friendly interface. This integration paves the way for a more efficient contact center and its use cases include:

  • Enabling agents to view the customer journey to quickly solve issues with a customer’s most recent order
  • Allowing agents to change a customer’s preferred method of communication for marketing campaigns
  • Adding and removing customers from marketing campaigns
  • The automatic detection of customers across all contact channels, especially SMS and Voice
  • Items left in a cart triggering an SMS message for a customer to which the customer can respond to receive help from an agent.

Creating a Source

There are a plethora of different kinds of sources that can funnel data into Segment. One of the most basic is the JavaScript source, which is simply any JavaScript-based application that sends data to the Analytics API. We utilized a retail-style website as our source and there we created a few hard-coded example users.

When a customer is selected an identify call is made. This call tells Segment that the customer has signed in and identifies the user as a unique profile. A unique customer identifier is included in the call and is used consistently throughout the website to identify the customer.


There are also several track calls made to the Analytics API. These correspond with key events such as adding an item to the cart or making a purchase. Whenever a customer performs one of these actions, a track call is sent. In addition to notifying Segment of the action itself, the track calls also provide any relevant information about the action, such as the name and the price of an item added to the cart.


Handling the data in Segment

The lovely thing about Segment is that it does all the heavy lifting. Once it receives the information, it automates all sorts of related tasks and data analytics. The info from the identify and track calls Segment received is gathered and sent to the Segment Personas platform to be refined. The Personas platform consists of the following tools – Profiles, Audiences, and Journeys.

The users and all their relevant data reside within the Profiles tool. Traits provided in identity calls, like name, email, and preferred contact method, show up here as Custom Traits. Custom Traits appear alongside values called Computed Traits, such as last purchase date and lifetime spend, which are calculated based on events or other traits.


Groups of users from the Profiles tool can be defined and calculated based on events and traits using the Audiences tool. These groups or “audiences” are analyzed based on common traits and behavioral patterns and they can also be imported into the Journeys tool where they can be singled out for channels like SMS and email campaigns.


Integrating Segment into a Twilio Flex Plugin

The key to putting all this data to work is in Twilio Flex. By integrating Segment into a Twilio Flex plugin, agents are not only given access to relevant customer information but also given the ability to edit customer info as needed.

It’s possible to query Segment for an individual customer profile through the Profile API and information such as user traits, events, external IDs, and more can be requested. In our plugin, we utilized the call and SMS external identifiers we defined to retrieve customer data depending on what channel the customer used to contact the contact center.


If a customer profile is found within Segment, their information is displayed in the CRM panel. If that is not the case, a form to add the customer’s information is displayed instead. Once this form is submitted, an identify call is sent to the Analytics API where Segment adds a new user to the list of profiles. Editing a customer’s contact info can be achieved with the same method, the primary difference being that when Segment receives the identify call it does not create a new profile. It updates the existing one with the new information instead.


Using a drop-down menu below the customer’s profile, the agent can add or remove the customer from any of the campaigns managed in Segment. This is done through a track call to the Analytics API that represents an Enroll or Unenroll action.  Campaigns provide a consistent point of contact with customers, and they can include anything from coupon email lists and SMS marketing campaigns to newsletters. Not only does this allow agents to efficiently enroll customers in relevant campaigns based on their profile, but it also gives customers more control over their privacy by making it easier to opt out of unwanted campaigns.

8 7

In the CRM panel, we can also find the entire customer journey that shows all the track events recorded for that user, capped at any specified number. For example, we capped our instance at 20 track events. By looking at these events, an agent can see what the customer is doing on the website and can better assist them.



In our project, we have only just scratched the surface of how Segment integrations can be used to enhance not only the Twilio Flex experience but also customer data management. With the versatility of Twilio Flex contact centers and the powerful customer data management of Segment, the possibilities are endless. We plan to continue delving into this topic and I encourage others to explore what this software power couple can do for them as well.

Why Perficient?

We are a Twilio Gold Partner with a team of certified Twilio Flex engineers and more than 20 years of experience delivering unparalleled customer engagement and contact center experience solutions. For more information on our Twilio Flex practice and capabilities visit us on our Twilio partner page!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Drak Twining

Drak Twining is an Associate Software Engineer in Custom Product Development. They primarily work on internal projects with Twilio Flex and related Cloud Contact Center software.

More from this Author

Follow Us