Salesforce Live Agent Destination

Segment makes it easy to send your data to Salesforce Live Agent (and lots of other destinations). Once you've tracked your data through our open source libraries we'll translate and route your data to Salesforce Live Agent in the format they understand. Learn more about how to use Salesforce Live Agent with Segment.

Getting Started

To get started, please follow Salesforce’s instructions to create a live agent deployment. If you have already done this, please navigate to the “deployment code” of the Live Agent deployment you would like to have Segment integrate with. It will look something like this:

<script type='text/javascript' src='https://c.la3-c1cs-phx.salesforceliveagent.com/content/g/js/42.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://d.la3-c1cs-phx.salesforceliveagent.com/chat', '1111D00000000FT', '00D3D000000FObV');
</script>

When you toggle on Salesforce Live Agent in Segment, we’ll begin loading the Salesforce Live Agent web SDK on any pages you have Segment deployed. Their accompanying API functionality will be available to interact with however, we will not initialize their API automatically. This is because their API has two core functions:

  • Control the visual configuration of the chat experience (set the size of the chat window, conditionally display buttons based on whether the chat agent is online/offline, etc.)
  • Send data about the Case, Account, and Contact to your chat agent as well as your Salesforce CRM deployment using a pre-chat form

The latter functionality described above is what Segment integrates with. However, Salesforce’s API stipulates that you must define the data you want to send to your Agent/Salesforce instance before you initialize their SDK.

This presents a problem because this data is generally only available after some kind of form submission by the user. Because Segment has no way of knowing if the page the user is on will contain such a form submission, we cannot decide at page load whether we need to initialize the Live Agent SDK right away (to allow for chat window customization) or wait until sometime after page load (once the user has submitted the information you request).

In short, our integration cannot proactively initialize the Live Agent SDK on page load on your behalf. The specific instructions regarding initialization options are outlined below.

Initialization

In order to begin using the Salesforce Live Agent via Segment, please follow these implementation guidelines.

  1. On any page where you are not collecting user information, but do want to interact with the Salesforce Live Agent API (to achieve some of the functionality outlined here for example), you must implement all the Live Agent SDK functionality natively except the actual loading of their deployment.js JavaScript library (the first line of the sample deployment code shown earlier). This will always be handled by Segment anywhere you are loading our JavaScript SDK.
  2. On any page where you are collecting user information (using some kind of pre-chat form for example) that you would like to pass to Salesforce and/or your chat agent after the user completes the form, you must ensure you do not call liveagent.init natively anywhere on the page and ensure that you do invoke a properly formatted Identify event, Group event (this is optional), and finally a Live Chat Conversation Started event in that order.

Identify

Calling identify does not actually trigger any kind of corresponding functionality in Salesforce Live Agent. Instead, the traits you define in this event are cached in the browser and used anytime a Live Chat Conversation Started event is invoked sometime in the future. You can map the traits you pass in to Salesforce Contact fields, as well as information fields for your customer service agent to see in their chat console. These mappings are defined in the Contact Mappings integration setting.

Group

Similar to calling identify, invoking our group method does not actually trigger any kind of corresponding functionality in Salesforce Live Agent. Instead, the traits you define in this event are cached in the browser and used anytime a Live Chat Conversation Started event is invoked sometime in the future. You can map these properties to Salesforce Account fields, as well as information fields for your customer service agent to see in their chat console. These mappings are defined in the Account Mappings integration setting.

Live Chat Conversation Started

The Live Chat Conversation Started event is a track event that is part of our Live Chat event spec. When invoked, Segment will begin looking for any cached user traits (from previous identify events) as well as group traits (from previous group events) and map them to Salesforce’s API based on the mappings you defined in your settings.

The properties that you pass into the Live Chat Conversation Started event can also be mapped to a Salesforce Case object. These mappings are defined in the Case Mappings integration setting.

Important: If you have defined mappings to Salesforce Contact and/or Account objects in your settings, you must ensure that you have invoked an identify event and/or a group event sometime prior to invoking the Live Chat Conversation Started event.

Deployment Code Settings

Many of the settings required to allow Segment to integrate with your Live Agent deployment are located in your Live Agent “deployment code” snippet. The following code snippet can be used to reference where you can find the values these settings require (setting names are capitalized):

<script type='text/javascript' src='https://{HOSTNAME}.salesforceliveagent.com/content/g/js/42.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://{LIVE_AGENT_ENDPOINT_URL}.salesforceliveagent.com/chat', {DEPLOYMENT_ID}, {ORG_ID});
</script>

Supported Sources and Connection Modes

WebMobileServer
📱 Device-based
☁️ Cloud-based

To learn more about about Connection Modes and what dictates which we support, see here.

Settings

Segment lets you change these destination settings via your Segment dashboard without having to touch any code.

Account Mappings

The settings here are used to define the semantic mappings between the traits you pass in via your analytics.group events and the fields those values can be mapped to in your Salesforce CRM as Account Objects and the Chat Details page of the Salesforce Console where your agents respond to user requests.

Case Mappings

The settings here are used to define the semantic mappings between the properties you pass in via your Live Chat Conversation Started events and the fields those values can be mapped to in your Salesforce CRM as Case Objects and the Chat Details page of the Salesforce Console where your agents respond to user requests.

Contact Mappings

The settings here are used to define the semantic mappings between the traits you pass in via your analytics.identify calls and the fields those values can be mapped to in your Salesforce CRM as Contacts and the Chat Details page of the Salesforce Console where your agents respond to user requests.

Deployment Id

Your Salesforce Live Agent Deployment Id. This should look something like 1223D00000000FT and can be found in your deployment code snippet. Please reference the Deployment Code Settings section of the documentation above for more information.

Enable Logging

This setting can be enabled to activate the enableLogging functionality of the Salesforce Live Agent SDK. This can be useful in debugging.

Hostname

Your Salesforce Live Agent Hostname. This should look something like c.la3-c1cs-phx and can be found in your deployment code snippet. Please reference the Deployment Code Settings section of the documentation for more information.

Live Agent Endpoint URL

Your Salesforce Live Agent Endpoint URL. This should look something like d.la3-c1cs-phx and can be found in your deployment code snippet. Please reference the Deployment Code Settings section of the documentation for more information.

Org Id

Your Salesforce Live Agent Org Id. This should look something like 00D5D000000DIdG and can be found in your deployment code snippet. Please reference the Deployment Code Settings section of the documentation for more information.


If you have any questions, or see anywhere we can improve our documentation, please let us know!