Hi all,
we are implementing the integration between GenesysCloud and Salesforce using the Connector.
The use case is:
when a call arrive to the agent, the last SF case must be opened.
we already set the ParticipantData on the Architect flow with SF_SearchValue, passing the customer mobile number.
When the call arrives to the agent on the embeddable framework in Salesforce, SF opens the correct customer page.
Now we would like to open the last case associate to the customer using Extension Points.
We deveoped the follow script but on the ScreenPop event nothing is happening:
global with sharing class MyCTIExtensions implements
purecloud.CTIExtension.ScreenPop,
purecloud.CTIExtension.SaveLog {
/*public String onClickToDial(String data) {
// Example: Specify On Behalf of Queue, Caller ID and Name for click-to-dial.
Map<String, Object> clickToDialData = (Map<String, Object>) JSON.deserializeUntyped(data);
clickToDialData.put('queueId', '04a183b6-de9e-4c01-9e88-eab81799ad0d');
clickToDialData.put('callerIdName', 'John Smith');
clickToDialData.put('callerId', '+13175550123');
return JSON.serialize(clickToDialData);
}*/
public String onScreenPop(String data) {
system.debug('sono entrato in MyCTIExtensions');
// Example: Find a recent Case record by phone number. if not found, fall back to default screen pop behavior.
Map<String, Object> screenPopData = (Map<String, Object>) JSON.deserializeUntyped(data);
Map<String, Object> dataToReturn = new Map<String, Object>();
String phoneNumber = (String) screenPopData.get('searchValue');
if (String.isNotBlank(phoneNumber)) {
List<Case> cases = [SELECT Id FROM Case WHERE ContactMobile =: phoneNumber ORDER BY LastModifiedDate DESC LIMIT 1];
if (cases.size() > 0) {
dataToReturn.put('/', cases.get(0).Id);
return JSON.serialize(dataToReturn);
}
}
dataToReturn.put('defaultScreenPop', true);
return JSON.serialize(dataToReturn);
}
public String onSaveLog(String data) {
system.debug('debug MyCTIExtensions.onSaveLog');
// Example: Save interaction log as Task record after interaction is disconnected.
Map<String, Object> saveLogData = (Map<String, Object>) JSON.deserializeUntyped(data);
Map<String, Object> interaction = ( Map<String, Object>) saveLogData.get('interaction');
Map<String, Object> callLog = ( Map<String, Object>) saveLogData.get('callLog');
Boolean isDisconnected = (Boolean) interaction.get('isDisconnected');
String callLogId = '';
if (isDisconnected) {
Task t = (Task) JSON.deserialize(JSON.serialize(callLog), Task.class);
upsert t;
callLogId = t.Id;
}
return callLogId;
}
}
There is an error on the script?
Do you have any suggests?
Thank you!