Integrate preconfigured service agent in Salesforce
Article
You can embed preconfigured agents directly into the Salesforce desktop with contextual awareness of the underlying platform. This integration helps agents provide better responses, and helps to further streamline the workflow for your customer service representatives.
Prerequisites
Before you begin, you must have the following environments and console:
A Copilot for Service instance connected to a Salesforce environment.
A Salesforce production environment or trial environment with access to the Salesforce Service console.
Additionally, for your service representatives to be able to use Copilot for Service in Salesforce, you must assign the Basic User and Omnichannel agent roles to them. Learn more in Assign a security role to a user.
Integrate preconfigured service agents
Sign in to your Copilot for Service instance.
On the sitemap, select Channels, and then select Salesforce.
Select Import > Choose File, and then navigate to and select the CopilotForServiceConfig.xml file you saved in step 4.
Select Import.
Select Edit, and then in the CTI Adapter URL field, paste the URL for the Copilot for Service widget URL you saved in Step 1.
Select Save.
Perform the following steps to add Salesforce users:
In the Salesforce Service console, select Manage Call Center Users > Add more users.
Add each Salesforce user you want to access the Copilot for Service widget.
Perform the following steps to add the softphone utility:
Select Setup, and then search for and select App Manager.
Find the Service Console app, select the upside-down triangle on the same row, and then select Edit.
Select Utility Items > Add Utility Item.
Search for and select Open CTI Softphone.
Type a name for your widget, such as "Microsoft Copilot for Service."
Set the width to 450 and height to 600.
Select Save.
Perform the following steps to enable popups:
In Salesforce, go to the service console from the Apps page.
Enable popups by selecting Always allow pop-ups and redirects from <url>.
Select Done.
Refresh your browser. The Copilot for Service add-on should now be available on the toolbar of your agent console.
Perform the following steps to configure the Copilot for Service widget in Salesforce:
Open the Salesforce Service console and select the Gear icon.
Select the Developer Console from the dropdown. If it doesn't load, copy the URL from the pop-up window and open it in a new tab.
In the Developer Console, select File > New > Apex class. Specify the name as ObjectService and select Create, and then paste the following code into the editor:
public class ObjectService {
@AuraEnabled
public static String getObjectType(String objectId) {
Id conId = objectId;
return String.valueOf(conId.getSobjectType());
}
}
Perform the following steps to create a lightning component:
Select File > New > Lightning component.
Specify a name for the component. For example, CopilotForService.
Select Controller from the bundle panel that displays when the component is created, and then paste the following code:
JavaScript
({
onTabFocused : function(component, event, helper) {
var currentTabId = event.getParam('currentTabId');
var previousTabId = event.getParam('previousTabId');
var workspaceAPI = component.find("workspace");
if(currentTabId) {
workspaceAPI.getTabInfo({
tabId : currentTabId
}).then(function(response) {
var action = component.get("c.getObjectType");
var recordId = response.recordId;
action.setParams({"objectId": recordId});
action.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS") {
component.set("v.objectType",response.getReturnValue());
var type = response.getReturnValue();
console.log("Object details:", recordId, type);
var objectType = 0;
if (type == 'Case') {
objectType = 1;
} elseif (type == 'EmailMessage') {
objectType = 2;
} elseif (type == "LiveChatTranscript") {
objectType = 8;
}
console.log("iframe: ", document.querySelector('iframe.CFSLightning'));
// Invoke adapter to navigate based on objectid and objecttypedocument.querySelector('iframe.CFSLightning').contentWindow.postMessage({
messageType: "onPageNavigateFromSFLightningComponent",
messageData: JSON.stringify({
value: JSON.stringify({
objectId: recordId,
objectType: objectType,
sourceId: "b54abfa8-3d78-4aa0-ae3f-1e2ffbc56850"
})
})
}, "*");
} else {
console.log('Problem updating the case, response state: ' + state);
}
});
$A.enqueueAction(action);
});
} else {
// When user navigates to the entity list page, switch to global sessionconsole.log("global!");
document.querySelector('iframe.CFSLightning').contentWindow.postMessage({
messageType: "onPageNavigateFromSFLightningComponent",
messageData: JSON.stringify({
value: JSON.stringify({
objectId: "",
objectType: 0,
sourceId: "b54abfa8-3d78-4aa0-ae3f-1e2ffbc56850"
})
})
}, "*");
}
}
})
Select Save.
Select Component, and then copy the following code:
Improve business processes for customer service functions, such as automatic case creation and queue management with Microsoft Dynamics 365 Customer Service.