Capturingng live agent status change to custom object for forecasting.

Issue: LiveAgentSession will not capture the details until unless user puts status offline.

Solution: Using service console toolkit & the console component we can trigger every status change events which can stored in a custom object.

Components:

  1. Custom object with custom fields.
  2. VF page 
  3. Console component
  4. Console app settings


VF page:

<apex:page sidebar="false" showHeader="false" standardStylesheets="false">
<apex:includeScript value="/support/console/36.0/integration.js"/>
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<script src="../../soap/ajax/38.0/connection.js" type="text/javascript"></script>
<script type="text/javascript">
var _laEventHandler = function (result) {
var _laStatusObj = new sforce.SObject("pradeep_dani__Live_Agent_Status__c");
_laStatusObj.Name = result.state;
var _result = sforce.connection.create([_laStatusObj]);
if(_result && _result[0].getBoolean("success")){
alert('Live_Agent_Status__c Record inserted successfully :' + _result[0] );
}
else{
alert('Error : '+_result);
}
};
sforce.console.chat.onAgentStateChanged(_laEventHandler);
</script>
</apex:page>
Console component:

<?xml version="1.0" encoding="UTF-8"?>
<CustomApplicationComponent xmlns="http://soap.sforce.com/2006/04/metadata">
<buttonText>Live Agent Toolkit</buttonText>
<isHeightFixed>false</isHeightFixed>
<isHidden>true</isHidden><!—This setting will not display the button in the service console?
<isWidthFixed>false</isWidthFixed>
<visualforcePage>LiveAgentToolKit</visualforcePage>
</CustomApplicationComponent>
Console app settings:

<?xml version="1.0" encoding="UTF-8"?>
<CustomApplication xmlns="http://soap.sforce.com/2006/04/metadata">
<customApplicationComponents>
<alignment>right</alignment>
<customApplicationComponent>Console.BuiltInComponent.mostRecentlyUsed</customApplicationComponent>
<customApplicationComponent>LiveAgentToolkit</customApplicationComponent>
</customApplicationComponents>
<!----Rest of the XML---->
</CustomApplication>
Object XML:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<actionOverrides>
<actionName>Accept</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>CancelEdit</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Clone</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Delete</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Edit</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Follow</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>List</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>New</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>SaveEdit</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Tab</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>View</actionName>
<type>Default</type>
</actionOverrides>
<allowInChatterGroups>false</allowInChatterGroups>
<compactLayoutAssignment>SYSTEM</compactLayoutAssignment>
<deploymentStatus>Deployed</deploymentStatus>
<enableActivities>false</enableActivities>
<enableBulkApi>false</enableBulkApi>
<enableFeeds>false</enableFeeds>
<enableHistory>false</enableHistory>
<enableReports>true</enableReports>
<enableSearch>true</enableSearch>
<enableSharing>false</enableSharing>
<enableStreamingApi>false</enableStreamingApi>
<fields>
<fullName>Status__c</fullName>
<externalId>false</externalId>
<label>Status</label>
<length>100</length>
<required>false</required>
<trackTrending>false</trackTrending>
<type>Text</type>
<unique>false</unique>
</fields>
<label>Live Agent Status</label>
<listViews>
<fullName>All</fullName>
<filterScope>Everything</filterScope>
<label>All</label>
</listViews>
<nameField>
<label>Live Agent Status Name</label>
<type>Text</type>
</nameField>
<pluralLabel>Live Agent Status</pluralLabel>
<searchLayouts/>
<sharingModel>ReadWrite</sharingModel>
</CustomObject>
Thanks
Pradeepkumar Dani

Comments