Skip to main content

Connecting Copilot to Salesforce

Enable Live Chat with Salesforce

Once you’ve completed the basic Salesforce API integration, you may enable live chat between your Salesforce agents and your users in the Copilot Chat interface by leveraging the Salesforce LiveAgent API. You will need to get 4 pieces of information from Salesforce:

  1. Base URL
  2. Organization ID
  3. Deployment ID
  4. Chat Button ID

Step 1: For the first three. Create a Chat Deployment in Salesforce

  1. In Salesforce, click the gear icon in the upper right-hand corner and select Service Setup.
  2. In the Quick Find search field, search for deploy. Under the heading Chat or Live Agent, select Deployments. Click New to create a new chat deployment.
FieldNotes
Chat Deployment NameInput a name such as “CommandAI”
Developer NameKeep the default.
Chat Window TitleYour choice.
Idle Connection Warning DurationThe duration, in seconds, that the customer can remain unavailable or disconnected before a warning is sent to the agent. The default value is 40 seconds. Select the checkbox to enable custom timeouts.
Idle Connection Timeout DurationThe duration, in seconds, that the customer can remain unavailable or disconnected before the chat ends. The default value is 110 seconds. Select the checkbox to enable custom timeouts.
  1. Click Save to create your new chat deployment and obtain the deployment code, which contains information to pass on to CommandAI.

There are 3 values that are relevant here, and they are contained within the parenthesis following liveagent.init.

Example:

liveagent.init('https://d.la4-c2-ia9.salesforceliveagent.com/chat', '572Ho000000ToRn', '00DHo000002CMr8');

The first item in that code (looks something like: https://d.la4-c2-ia9.salesforceliveagent.com/chat) is your BASE URL.

The second (looks like 572Ho000000ToRn) is your Organization ID

The third (looks like 00DHo000002CMr8) is your Deployment ID

Step 2: Get your chat button ID from Salesforce

  1. In Salesforce, click the gear icon and select Service Setup.
  2. In the Quick Find search field at the top of the left hand menu, search for "chat button" and select Chat Buttons & Invitations under the heading Chat or Live Agent.
  3. Create a new chat button.
  4. Complete the Basic Information and Routing Information sections. Use the Salesforce Chat Button Settings guide for help with each of the fields.
  5. Save your new chat button.
  6. Once saved, find the Chat Button Code they provide at the bottom of the page. It should look something like this:
<a id="liveagent_button_online_573Ho000000QRTx" href="javascript://Chat" style="display: none;" onclick="liveagent.startChat('573Ho000000QRTx')"><!-- Online Chat Content --></a><div id="liveagent_button_offline_573Ho000000QRTx" style="display: none;"><!-- Offline Chat Content --></div><script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('573Ho000000QRTx', document.getElementById('liveagent_button_online_573Ho000000QRTx'));
liveagent.showWhenOffline('573Ho000000QRTx', document.getElementById('liveagent_button_offline_573Ho000000QRTx'));
});</script>
  1. The same button ID will be listed a number of times (in the example above it's 573Ho000000QRTx), record it as ‘Button ID’ along with the values from Step 1.